From 699987217f5fc0141fa08b52aab0e93c32d2d7c0 Mon Sep 17 00:00:00 2001 From: Suha Can Date: Fri, 11 Jun 2010 11:32:46 -0700 Subject: [PATCH 1/3] - Modifying Has and Get methods of the ContentPart, parts can contain multiple fields of the same type. --HG-- branch : dev --- src/Orchard/ContentManagement/ContentField.cs | 2 +- src/Orchard/ContentManagement/ContentPart.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Orchard/ContentManagement/ContentField.cs b/src/Orchard/ContentManagement/ContentField.cs index e1edebb52..111ce6310 100644 --- a/src/Orchard/ContentManagement/ContentField.cs +++ b/src/Orchard/ContentManagement/ContentField.cs @@ -5,7 +5,7 @@ using Orchard.ContentManagement.Utilities; namespace Orchard.ContentManagement { public class ContentField : ContentPart { public virtual ContentPart ContentPart { get; set; } - public string Name { get; set; } + public string Name { get { return PartFieldDefinition.Name; } } public IDictionary Settings { get; private set; } public new ContentPartDefinition PartDefinition { get { return ContentPart.PartDefinition; } } diff --git a/src/Orchard/ContentManagement/ContentPart.cs b/src/Orchard/ContentManagement/ContentPart.cs index 5c3f35728..7c6f2d7d6 100644 --- a/src/Orchard/ContentManagement/ContentPart.cs +++ b/src/Orchard/ContentManagement/ContentPart.cs @@ -20,14 +20,14 @@ namespace Orchard.ContentManagement { public IEnumerable Fields { get { return _fields; } } - public bool Has(Type fieldType) { - return fieldType == typeof(ContentItem) || _fields.Any(field => fieldType.IsAssignableFrom(field.GetType())); + public bool Has(Type fieldType, string fieldName) { + return fieldType == typeof(ContentItem) || _fields.Any(field => fieldType.IsAssignableFrom(field.GetType()) && field.Name == fieldName); } - public IContent Get(Type fieldType) { + public IContent Get(Type fieldType, string fieldName) { if (fieldType == typeof(ContentItem)) return this; - return _fields.FirstOrDefault(field => fieldType.IsAssignableFrom(field.GetType())); + return _fields.FirstOrDefault(field => fieldType.IsAssignableFrom(field.GetType()) && field.Name == fieldName); } public void Weld(ContentField field) { From e7c7ae79e0e70c69dcb3736ffd4b23ff119c2a68 Mon Sep 17 00:00:00 2001 From: Suha Can Date: Fri, 11 Jun 2010 11:51:17 -0700 Subject: [PATCH 2/3] - ContentPartDefinitionBuilder --HG-- branch : dev --- .../Builders/ContentPartDefinitionBuilder.cs | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs b/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs index 4e9fc0de6..15f93026d 100644 --- a/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs +++ b/src/Orchard/ContentManagement/MetaData/Builders/ContentPartDefinitionBuilder.cs @@ -1,18 +1,36 @@ -using System; +using System.Collections.Generic; +using System.Linq; using Orchard.ContentManagement.MetaData.Models; namespace Orchard.ContentManagement.MetaData.Builders { public class ContentPartDefinitionBuilder { - public ContentPartDefinitionBuilder(ContentPartDefinition partDefinition) { - throw new NotImplementedException(); + private readonly string _name; + private readonly IList _fields; + private readonly IDictionary _settings; + + public ContentPartDefinitionBuilder() + : this(new ContentPartDefinition(null)) { + } + + public ContentPartDefinitionBuilder(ContentPartDefinition existing) { + if (existing == null) { + _fields = new List(); + _settings = new Dictionary(); + } + else { + _name = existing.Name; + _fields = existing.Fields.ToList(); + _settings = existing.Settings.ToDictionary(kv => kv.Key, kv => kv.Value); + } } public ContentPartDefinition Build() { - throw new NotImplementedException(); + return new ContentPartDefinition(_name, _fields, _settings); } public ContentPartDefinitionBuilder WithSetting(string name, string value) { - throw new NotImplementedException(); + _settings[name] = value; + return this; } } From 8096a4234e22e3c4f4aef0d4a9ecb16e1b2cf0c6 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Fri, 11 Jun 2010 14:46:18 -0700 Subject: [PATCH 3/3] Prepared Azure projects for .NET 4.0 Changed Azure references to SDK 1.2 Added a hack for the ASP.NET 4 bug in HttpEncoder Converted projects to VS10 --HG-- branch : dev --- .hgignore | 7 +- src/Orchard.Azure.Tests/App.config | 6 +- .../Orchard.Azure.Tests.csproj | 44 +++- src/Orchard.Azure.sln | 4 +- src/Orchard.Azure/AzureFileSystem.cs | 46 +++- src/Orchard.Azure/AzureHelper.cs | 33 +++ .../AzureShellSettingsManager.cs | 62 +++-- .../Orchard.Azure.CloudService.sln | 4 +- .../Orchard.Azure.CloudService.ccproj | 4 +- .../ServiceDefinition.csdef | 2 +- .../Orchard.Azure.Web.csproj | 37 +-- .../Orchard.Azure.Web/Web.config | 245 ++++++------------ .../Orchard.Azure.Web/WebRole.cs | 42 +-- src/Orchard.Azure/Orchard.Azure.csproj | 46 +++- 14 files changed, 315 insertions(+), 267 deletions(-) create mode 100644 src/Orchard.Azure/AzureHelper.cs diff --git a/.hgignore b/.hgignore index 8ec3e6972..3472a64ec 100644 --- a/.hgignore +++ b/.hgignore @@ -2,7 +2,6 @@ glob:bin glob:obj glob:App_Data glob:_ReSharper* -glob:src/Orchard.suo glob:*.user glob:*.patch glob:*.hg @@ -11,8 +10,8 @@ glob:artifacts glob:*.sln.cache glob:src/Orchard.Web/Media/* glob:desktop.ini -glob:src/Orchard.Azure.suo -glob:src/Orchard.5.0.ReSharper glob:log.xml glob:profiling -glob:*.csproj.orig +glob:src/*.suo +glob:src/*.ReSharper +glob:*.orig diff --git a/src/Orchard.Azure.Tests/App.config b/src/Orchard.Azure.Tests/App.config index c244681d2..b6e948b4a 100644 --- a/src/Orchard.Azure.Tests/App.config +++ b/src/Orchard.Azure.Tests/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj b/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj index 1e1dc42b3..ecdce0f39 100644 --- a/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj +++ b/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,8 +10,28 @@ Properties Orchard.Azure.Tests Orchard.Azure.Tests - v3.5 + v4.0 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + true @@ -21,6 +41,7 @@ DEBUG;TRACE prompt 4 + AllRules.ruleset pdbonly @@ -29,6 +50,7 @@ TRACE prompt 4 + AllRules.ruleset @@ -47,6 +69,7 @@ 3.5 + 3.5 @@ -75,6 +98,23 @@ + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + - $(MSBuildExtensionsPath)\Microsoft\Cloud Service\v1.0\ + $(MSBuildExtensionsPath)\Microsoft\Cloud Service\1.0\Visual Studio 10.0\ \ No newline at end of file diff --git a/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceDefinition.csdef b/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceDefinition.csdef index c1f66c33a..7fccedb76 100644 --- a/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceDefinition.csdef +++ b/src/Orchard.Azure/Orchard.Azure.CloudService/ServiceDefinition.csdef @@ -2,7 +2,7 @@ - + diff --git a/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj b/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj index 2d5045c4d..ab6d7c41c 100644 --- a/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj +++ b/src/Orchard.Azure/Orchard.Azure.Web/Orchard.Azure.Web.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -11,8 +11,13 @@ Properties Orchard.Azure.Web Orchard.Azure.Web - v3.5 + v4.0 false + + + 3.5 + + true @@ -22,6 +27,7 @@ DEBUG;TRACE prompt 4 + AllRules.ruleset pdbonly @@ -30,6 +36,7 @@ TRACE prompt 4 + AllRules.ruleset @@ -56,23 +63,18 @@ 3.5 - - 3.5 - - - 3.5 - + + + + + False ..\..\..\..\..\..\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\\Assemblies\System.Web.Mvc.dll True - - 3.5 - - @@ -80,6 +82,7 @@ + @@ -98,7 +101,9 @@ - + + + {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6} @@ -109,11 +114,9 @@ Orchard.Azure - - - + - + - - - - -
- -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Azure/Orchard.Azure.Web/WebRole.cs b/src/Orchard.Azure/Orchard.Azure.Web/WebRole.cs index e5b12b130..832917606 100644 --- a/src/Orchard.Azure/Orchard.Azure.Web/WebRole.cs +++ b/src/Orchard.Azure/Orchard.Azure.Web/WebRole.cs @@ -8,45 +8,19 @@ namespace Orchard.Azure.Web { public override bool OnStart() { DiagnosticMonitor.Start("DiagnosticsConnectionString"); - #region Setup CloudStorageAccount Configuration Setting Publisher - - // This code sets up a handler to update CloudStorageAccount instances when their corresponding - // configuration settings change in the service configuration file. - CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { - // Provide the configSetter with the initial value - configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); - - RoleEnvironment.Changed += (sender, arg) => { - if ( arg.Changes.OfType() - .Any(change => ( change.ConfigurationSettingName == configName )) ) { - // The corresponding configuration setting has changed, propagate the value - if ( !configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)) ) { - // In this case, the change to the storage account credentials in the - // service configuration is significant enough that the role needs to be - // recycled in order to use the latest settings. (for example, the - // endpoint has changed) - RoleEnvironment.RequestRecycle(); - } - } - }; - }); - #endregion - - // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. - RoleEnvironment.Changing += (sender, e) => { - // If a configuration setting is changing - if ( - e.Changes.Any( - change => change is RoleEnvironmentConfigurationSettingChange) ) { - // Set e.Cancel to true to restart this role instance - e.Cancel = true; - } - }; + RoleEnvironment.Changing += RoleEnvironmentChanging; return base.OnStart(); } + private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e) { + // If a configuration setting is changing + if ( e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange) ) { + // Set e.Cancel to true to restart this role instance + e.Cancel = true; + } + } } } diff --git a/src/Orchard.Azure/Orchard.Azure.csproj b/src/Orchard.Azure/Orchard.Azure.csproj index bdd1d9fc8..22be35fc4 100644 --- a/src/Orchard.Azure/Orchard.Azure.csproj +++ b/src/Orchard.Azure/Orchard.Azure.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,8 +10,28 @@ Properties Orchard.Azure Orchard.Azure - v3.5 + v4.0 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + true @@ -21,6 +41,7 @@ DEBUG;TRACE prompt 4 + AllRules.ruleset pdbonly @@ -29,13 +50,16 @@ TRACE prompt 4 + AllRules.ruleset + 3.5 + 3.5 @@ -50,6 +74,7 @@ + @@ -63,6 +88,23 @@ Orchard.Framework + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + +