diff --git a/Jabberwocky.Core/Cryptography/AesHmacCryptoService.cs b/Jabberwocky.Core/Cryptography/AesHmacCryptoService.cs index 219bdde..8316f19 100644 --- a/Jabberwocky.Core/Cryptography/AesHmacCryptoService.cs +++ b/Jabberwocky.Core/Cryptography/AesHmacCryptoService.cs @@ -18,15 +18,15 @@ public class AesHmacCryptoService : IHmacCryptoService protected ISerializationProvider SerializationProvider { get; } /// - /// Symmetric Key size for 256-bit cipher + /// Symmetric Key size for 256-bit cipher (in bytes) /// private const int KeySize = 32; /// - /// AES cipher block-size + /// AES cipher block-size (in bytes) /// - private const int BlockSize = 128; + private const int BlockSize = 16; /// - /// Initialization Vector size + /// Initialization Vector size (in bytes) /// private const int SaltSize = 16; @@ -45,6 +45,7 @@ public static AesHmacCryptoService Create(string secretKey, string digestKey, st public AesHmacCryptoService(CryptoConfiguration config, ISerializationProvider serializationProvider) { if (serializationProvider == null) throw new ArgumentNullException(nameof(serializationProvider)); + if (!IsCryptoConfigurationValid(config)) throw new ArgumentException("All configuration properties must be valid.", nameof(config)); SerializationProvider = serializationProvider; _lazyDerivedBytes = new Lazy(() => GenerateDerivedBytes(config)); @@ -122,9 +123,11 @@ protected virtual byte[] GenerateNonce() protected virtual byte[] CryptContent(byte[] contentBytes, Func cryptorFunc) { + const int blockSizeInBits = BlockSize * 8; + using (var aes = new RijndaelManaged()) { - aes.BlockSize = BlockSize; + aes.BlockSize = blockSizeInBits; aes.Mode = CipherMode.CBC; aes.Key = SymmetricKey; aes.IV = Salt; @@ -147,7 +150,9 @@ protected virtual byte[] ComputeHash(byte[] content) private static KeySaltPair GenerateDerivedBytes(CryptoConfiguration config) { var saltBytes = new byte[SaltSize]; - Encoding.UTF8.GetBytes(config.InitializationVector, 0, config.InitializationVector.Length, saltBytes, 0); + var charSizeInBytes = sizeof(char); + var characterCount = Math.Min(SaltSize / charSizeInBytes, config.InitializationVector.Length); + Encoding.UTF8.GetBytes(config.InitializationVector, 0, characterCount, saltBytes, 0); using (var derivePassword = new Rfc2898DeriveBytes(config.SecretKey, saltBytes)) { @@ -163,6 +168,13 @@ private static KeySaltPair GenerateDerivedBytes(CryptoConfiguration config) } } + private static bool IsCryptoConfigurationValid(CryptoConfiguration config) + { + return !string.IsNullOrEmpty(config.DigestKey) + && !string.IsNullOrEmpty(config.InitializationVector) + && !string.IsNullOrEmpty(config.SecretKey); + } + #endregion protected struct KeySaltPair diff --git a/Jabberwocky.Core/Properties/AssemblyInfo.cs b/Jabberwocky.Core/Properties/AssemblyInfo.cs index 8b00c43..c9affb8 100644 --- a/Jabberwocky.Core/Properties/AssemblyInfo.cs +++ b/Jabberwocky.Core/Properties/AssemblyInfo.cs @@ -8,9 +8,9 @@ [assembly: AssemblyTitle("Jabberwocky.Core")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyCompany("Velir")] [assembly: AssemblyProduct("Jabberwocky.Core")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2014")] +[assembly: AssemblyCopyright("Copyright © Velir 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.2.0")] -[assembly: AssemblyFileVersion("1.0.2.0")] +[assembly: AssemblyVersion("1.0.3.0")] +[assembly: AssemblyFileVersion("1.0.3.0")] [assembly: InternalsVisibleTo("Jabberwocky.Core.Tests")] \ No newline at end of file diff --git a/Jabberwocky.Glass.Autofac.Mvc.Tests/Jabberwocky.Glass.Autofac.Mvc.Tests.csproj b/Jabberwocky.Glass.Autofac.Mvc.Tests/Jabberwocky.Glass.Autofac.Mvc.Tests.csproj index fa180c0..18d3df2 100644 --- a/Jabberwocky.Glass.Autofac.Mvc.Tests/Jabberwocky.Glass.Autofac.Mvc.Tests.csproj +++ b/Jabberwocky.Glass.Autofac.Mvc.Tests/Jabberwocky.Glass.Autofac.Mvc.Tests.csproj @@ -51,19 +51,7 @@ False ..\packages\Glass.Mapper.Sc.4.0.3.51\lib\72\Glass.Mapper.Sc.dll - - ..\lib\Sitecore\Testing\HtmlAgilityPack.dll - - - ..\lib\Sitecore\Testing\ITHit.WebDAV.Server.dll - - - ..\lib\Sitecore\Testing\Lucene.Net.dll - - - False - ..\lib\Sitecore\Testing\Mvp.Xml.dll @@ -79,13 +67,6 @@ False ..\lib\Sitecore\Sitecore.Kernel.dll - - FakesAssemblies\Sitecore.Kernel.7.0.0.0.Fakes.dll - - - False - ..\lib\Sitecore\Testing\Sitecore.Logging.dll - False ..\lib\Sitecore\Sitecore.Mvc.dll @@ -103,11 +84,9 @@ - - @@ -119,11 +98,16 @@ {5EAD110F-F074-47E4-8B93-C0EECB9FC27A} Jabberwocky.Glass.Autofac.Mvc + + {dd17db22-247c-44a6-b0dd-091786863626} + Jabberwocky.Glass.Mvc + {13E08D30-B2A4-45EF-A28E-C916EB80B70D} Jabberwocky.Glass + diff --git a/Jabberwocky.Glass.Autofac.Mvc.Tests/Models/Factory/AutofacViewModelFactoryTests.cs b/Jabberwocky.Glass.Autofac.Mvc.Tests/Models/Factory/AutofacViewModelFactoryTests.cs index 9517c57..c96d898 100644 --- a/Jabberwocky.Glass.Autofac.Mvc.Tests/Models/Factory/AutofacViewModelFactoryTests.cs +++ b/Jabberwocky.Glass.Autofac.Mvc.Tests/Models/Factory/AutofacViewModelFactoryTests.cs @@ -3,8 +3,8 @@ using Jabberwocky.Glass.Autofac.Mvc.Models; using Jabberwocky.Glass.Autofac.Mvc.Models.Attributes; using Jabberwocky.Glass.Autofac.Mvc.Models.Factory; -using Jabberwocky.Glass.Autofac.Mvc.Services; using Jabberwocky.Glass.Models; +using Jabberwocky.Glass.Mvc.Services; using NSubstitute; using NUnit.Framework; using Sitecore.Mvc.Presentation; diff --git a/Jabberwocky.Glass.Autofac.Mvc/Extensions/MvcRegistrationExtensions.cs b/Jabberwocky.Glass.Autofac.Mvc/Extensions/MvcRegistrationExtensions.cs index e8605e7..b675896 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Extensions/MvcRegistrationExtensions.cs +++ b/Jabberwocky.Glass.Autofac.Mvc/Extensions/MvcRegistrationExtensions.cs @@ -5,7 +5,8 @@ using Glass.Mapper.Sc.ModelCache; using Jabberwocky.Glass.Autofac.Mvc.Models; using Jabberwocky.Glass.Autofac.Mvc.Models.Factory; -using Jabberwocky.Glass.Autofac.Mvc.Services; +using Jabberwocky.Glass.Mvc.Services; +using IViewModelFactory = Jabberwocky.Glass.Mvc.Models.Factory.IViewModelFactory; namespace Jabberwocky.Glass.Autofac.Mvc.Extensions { diff --git a/Jabberwocky.Glass.Autofac.Mvc/Jabberwocky.Glass.Autofac.Mvc.csproj b/Jabberwocky.Glass.Autofac.Mvc/Jabberwocky.Glass.Autofac.Mvc.csproj index 6c26c35..db9ee74 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Jabberwocky.Glass.Autofac.Mvc.csproj +++ b/Jabberwocky.Glass.Autofac.Mvc/Jabberwocky.Glass.Autofac.Mvc.csproj @@ -99,14 +99,10 @@ - - - - @@ -114,10 +110,6 @@ - - - - @@ -130,6 +122,10 @@ {EA620F62-8D08-4031-BAC4-1C60D5C5CBC9} Jabberwocky.Glass.Autofac + + {dd17db22-247c-44a6-b0dd-091786863626} + Jabberwocky.Glass.Mvc + {13E08D30-B2A4-45EF-A28E-C916EB80B70D} Jabberwocky.Glass diff --git a/Jabberwocky.Glass.Autofac.Mvc/Models/Factory/AutofacViewModelFactory.cs b/Jabberwocky.Glass.Autofac.Mvc/Models/Factory/AutofacViewModelFactory.cs index 2d8bb51..991cfad 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Models/Factory/AutofacViewModelFactory.cs +++ b/Jabberwocky.Glass.Autofac.Mvc/Models/Factory/AutofacViewModelFactory.cs @@ -5,12 +5,12 @@ using Autofac; using Autofac.Core; using Jabberwocky.Glass.Autofac.Mvc.Models.Attributes; -using Jabberwocky.Glass.Autofac.Mvc.Services; using Jabberwocky.Glass.Models; +using Jabberwocky.Glass.Mvc.Services; namespace Jabberwocky.Glass.Autofac.Mvc.Models.Factory { - public class AutofacViewModelFactory : IViewModelFactory + public class AutofacViewModelFactory : Jabberwocky.Glass.Mvc.Models.Factory.IViewModelFactory { private static readonly ConcurrentDictionary ViewModelTypeCache = new ConcurrentDictionary(); diff --git a/Jabberwocky.Glass.Autofac.Mvc/Models/GlassViewModel.cs b/Jabberwocky.Glass.Autofac.Mvc/Models/GlassViewModel.cs index 2b54f28..d29a661 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Models/GlassViewModel.cs +++ b/Jabberwocky.Glass.Autofac.Mvc/Models/GlassViewModel.cs @@ -1,4 +1,5 @@ using Jabberwocky.Glass.Models; +using Jabberwocky.Glass.Mvc.Models; namespace Jabberwocky.Glass.Autofac.Mvc.Models { @@ -7,9 +8,9 @@ public abstract class GlassViewModel : InjectableGlassViewModelBase public virtual TGlassModel GlassModel => InternalDatasourceModel as TGlassModel; } - public abstract class GlassViewModel : GlassViewModel - where TDatasource : class, IGlassBase where TRenderingParameter : class - { - public virtual TRenderingParameter RenderingParameters => InternalRenderingParameterModel as TRenderingParameter; - } + public abstract class GlassViewModel : GlassViewModel + where TDatasource : class, IGlassBase where TRenderingParameter : class + { + public virtual TRenderingParameter RenderingParameters => InternalRenderingParameterModel as TRenderingParameter; + } } diff --git a/Jabberwocky.Glass.Autofac.Mvc/Models/InjectableGlassViewModelBase.cs b/Jabberwocky.Glass.Autofac.Mvc/Models/InjectableGlassViewModelBase.cs index de38c10..4cfa1d8 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Models/InjectableGlassViewModelBase.cs +++ b/Jabberwocky.Glass.Autofac.Mvc/Models/InjectableGlassViewModelBase.cs @@ -1,9 +1,9 @@ -namespace Jabberwocky.Glass.Autofac.Mvc.Models +namespace Jabberwocky.Glass.Autofac.Mvc.Models { public abstract class InjectableGlassViewModelBase { internal object InternalDatasourceModel; - internal object InternalRenderingParameterModel; + internal object InternalRenderingParameterModel; } } diff --git a/Jabberwocky.Glass.Autofac.Mvc/Pipelines/Processors/GetModelFromViewProcessor.cs b/Jabberwocky.Glass.Autofac.Mvc/Pipelines/Processors/GetModelFromViewProcessor.cs index a6fda69..8f793c1 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Pipelines/Processors/GetModelFromViewProcessor.cs +++ b/Jabberwocky.Glass.Autofac.Mvc/Pipelines/Processors/GetModelFromViewProcessor.cs @@ -6,7 +6,7 @@ using Sitecore.Diagnostics; using Sitecore.Mvc.Pipelines.Response.GetModel; using Glass.Mapper; -using Jabberwocky.Glass.Autofac.Mvc.Models.Factory; +using Jabberwocky.Glass.Mvc.Models.Factory; using Sitecore.Data.Items; namespace Jabberwocky.Glass.Autofac.Mvc.Pipelines.Processors diff --git a/Jabberwocky.Glass.Autofac.Mvc/Pipelines/Processors/GetModelProcessor.cs b/Jabberwocky.Glass.Autofac.Mvc/Pipelines/Processors/GetModelProcessor.cs index d7d9d0c..61b6208 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Pipelines/Processors/GetModelProcessor.cs +++ b/Jabberwocky.Glass.Autofac.Mvc/Pipelines/Processors/GetModelProcessor.cs @@ -1,7 +1,7 @@ using System; using Glass.Mapper.Sc.Configuration.Attributes; -using Jabberwocky.Glass.Autofac.Mvc.Models.Factory; using Jabberwocky.Glass.Autofac.Pipelines.Processors; +using Jabberwocky.Glass.Mvc.Models.Factory; using Sitecore.Data; using Sitecore.Data.Items; using Sitecore.Mvc.Configuration; diff --git a/Jabberwocky.Glass.Autofac.Mvc/Properties/AssemblyInfo.cs b/Jabberwocky.Glass.Autofac.Mvc/Properties/AssemblyInfo.cs index 1015844..5b5a9df 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Properties/AssemblyInfo.cs +++ b/Jabberwocky.Glass.Autofac.Mvc/Properties/AssemblyInfo.cs @@ -8,9 +8,9 @@ [assembly: AssemblyTitle("Jabberwocky.Glass.Autofac.Mvc")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyCompany("Velir")] [assembly: AssemblyProduct("Jabberwocky.Glass.Autofac.Mvc")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[assembly: AssemblyCopyright("Copyright © Velir 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,7 +32,23 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.1.0")] -[assembly: AssemblyFileVersion("1.1.1.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] -[assembly: InternalsVisibleTo("Jabberwocky.Glass.Autofac.Mvc.Tests")] \ No newline at end of file +[assembly: InternalsVisibleTo("Jabberwocky.Glass.Autofac.Mvc.Tests")] + +#pragma warning disable 612 +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Attributes.HttpGetOrInvalidHttpPostAttribute))] +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Attributes.ValidateFormHandlerAttribute))] +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Attributes.ValidHttpPostAttribute))] + +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Models.Factory.IViewModelFactory))] + +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Services.IRenderingContextService))] +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Services.RenderingContextService))] +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Services.DatasourceNestingOptions))] + +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Util.CustomSitecoreHelper))] + +[assembly: TypeForwardedTo(typeof(Jabberwocky.Glass.Autofac.Mvc.Views.CustomGlassView<>))] +#pragma warning restore 612 \ No newline at end of file diff --git a/Jabberwocky.Glass.Autofac.Mvc/Services/IRenderingContextService.cs b/Jabberwocky.Glass.Autofac.Mvc/Services/IRenderingContextService.cs deleted file mode 100644 index e8f100c..0000000 --- a/Jabberwocky.Glass.Autofac.Mvc/Services/IRenderingContextService.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using Jabberwocky.Glass.Models; -using Sitecore.Mvc.Presentation; - -namespace Jabberwocky.Glass.Autofac.Mvc.Services -{ - public interface IRenderingContextService - { - Rendering GetCurrentRendering(); - - T GetCurrentRenderingDatasource(DatasourceNestingOptions options = DatasourceNestingOptions.Default) where T : class, IGlassBase; - - T GetCurrentRenderingParameters() where T : class; - - object GetCurrentRenderingParameters(Type renderingParamType); - } - - public enum DatasourceNestingOptions - { - Default, - Never, - Always - } -} diff --git a/Jabberwocky.Glass.Autofac/Properties/AssemblyInfo.cs b/Jabberwocky.Glass.Autofac/Properties/AssemblyInfo.cs index 2423141..52f1e32 100644 --- a/Jabberwocky.Glass.Autofac/Properties/AssemblyInfo.cs +++ b/Jabberwocky.Glass.Autofac/Properties/AssemblyInfo.cs @@ -8,9 +8,9 @@ [assembly: AssemblyTitle("Jabberwocky.Glass.Autofac")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyCompany("Velir")] [assembly: AssemblyProduct("Jabberwocky.Glass.Autofac")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2014")] +[assembly: AssemblyCopyright("Copyright © Velir 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Jabberwocky.Glass.Autofac.Mvc.Tests/Fakes/Sitecore.Kernel.fakes b/Jabberwocky.Glass.Mvc.Tests/Fakes/Sitecore.Kernel.fakes similarity index 100% rename from Jabberwocky.Glass.Autofac.Mvc.Tests/Fakes/Sitecore.Kernel.fakes rename to Jabberwocky.Glass.Mvc.Tests/Fakes/Sitecore.Kernel.fakes diff --git a/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.dll b/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.dll new file mode 100644 index 0000000..7a2aa7b Binary files /dev/null and b/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.dll differ diff --git a/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.fakesconfig b/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.fakesconfig new file mode 100644 index 0000000..8bae71b Binary files /dev/null and b/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.fakesconfig differ diff --git a/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.xml b/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.xml new file mode 100644 index 0000000..f10d0c3 --- /dev/null +++ b/Jabberwocky.Glass.Mvc.Tests/FakesAssemblies/Sitecore.Kernel.7.0.0.0.Fakes.xml @@ -0,0 +1,653 @@ + + + + Sitecore.Kernel.7.0.0.0.Fakes + + + + Shim type of Sitecore.Data.Items.Item + + + Initializes a new shim instance + + + Initializes a new shim for the given instance + + + Sets the shim of Item.get_Access() + + + Sets the shim of Item.Add(String name, BranchId branchId) + + + Sets the shim of Item.Add(String name, BranchItem branch) + + + Sets the shim of Item.Add(String name, TemplateID templateID) + + + Sets the shim of Item.Add(String name, TemplateItem template) + + + Sets the shim of Item.AddToItemCloningRelationsCache(Item item, ItemUri uri) + + + Define shims for all instances members + + + Sets the shim of Item.get_Access() + + + Sets the shim of Item.Add(String name, BranchId branchId) + + + Sets the shim of Item.Add(String name, BranchItem branch) + + + Sets the shim of Item.Add(String name, TemplateID templateID) + + + Sets the shim of Item.Add(String name, TemplateItem template) + + + Sets the shim of Item.get_Appearance() + + + Sets the shim of Item.get_Axes() + + + Sets the shim of Item.BeginEdit() + + + Sets the shim of Item.get_Branch() + + + Sets the shim of Item.get_BranchId() + + + Sets the shim of Item.set_BranchId(ID value) + + + Sets the shim of Item.get_Branches() + + + Sets the shim of Item.ChangeTemplate(TemplateItem template) + + + Sets the shim of Item.get_Children() + + + Sets the shim of Item.Clone(ID cloneID, Database ownerDatabase) + + + Sets the shim of Item.Clone(Item item) + + + Sets the shim of Item.CloneTo(Item destination) + + + Sets the shim of Item.CloneTo(Item destination, Boolean deep) + + + Sets the shim of Item.CloneTo(Item destination, String name, Boolean deep) + + + Sets the shim of Item.CopyTo(Item destination, String copyName) + + + Sets the shim of Item.CopyTo(Item destination, String copyName, ID copyID, Boolean deep) + + + Sets the shim of Item.get_Database() + + + Sets the shim of Item.Delete() + + + Sets the shim of Item.Delete(Boolean removeBlobs) + + + Sets the shim of Item.DeleteChildren() + + + Sets the shim of Item.get_DisplayName() + + + Sets the shim of Item.Duplicate() + + + Sets the shim of Item.Duplicate(String copyName) + + + Sets the shim of Item.get_Editing() + + + Sets the shim of Item.get_Empty() + + + Sets the shim of Item.EndEdit() + + + Sets the shim of Item.get_Fields() + + + Sets the shim of Item.GetChanges(Boolean force) + + + Sets the shim of Item.GetChildren() + + + Sets the shim of Item.GetChildren(ChildListOptions options) + + + Sets the shim of Item.GetClones() + + + Sets the shim of Item.GetClones(Boolean processChildren) + + + Sets the shim of Item.GetFullChanges() + + + Sets the shim of Item.GetOuterXml(Boolean includeSubitems) + + + Sets the shim of Item.GetOuterXml(ItemSerializerOptions options) + + + Sets the shim of Item.GetProperty(String name) + + + Sets the shim of Item.GetUniqueId() + + + Sets the shim of Item.get_HasChildren() + + + Sets the shim of Item.get_HasClones() + + + Sets the shim of Item.get_Help() + + + Sets the shim of Item.get_ID() + + + Sets the shim of Item.get_InnerData() + + + Sets the shim of Item.get_IsClone() + + + Sets the shim of Item.get_IsEditing() + + + Sets the shim of Item.get_IsItemClone() + + + Sets the shim of Item.get_Key() + + + Sets the shim of Item.get_Language() + + + Sets the shim of Item.get_Languages() + + + Sets the shim of Item.get_Links() + + + Sets the shim of Item.get_Locking() + + + Sets the shim of Item.get_Master() + + + Sets the shim of Item.get_MasterID() + + + Sets the shim of Item.set_MasterID(ID value) + + + Sets the shim of Item.get_Masters() + + + Sets the shim of Item.get_Modified() + + + Sets the shim of Item.MoveTo(Item destination) + + + Sets the shim of Item.get_Name() + + + Sets the shim of Item.set_Name(String value) + + + Sets the shim of Item.get_OriginatorId() + + + Sets the shim of Item.get_Parent() + + + Sets the shim of Item.get_ParentID() + + + Sets the shim of Item.PasteItem(String xml, Boolean changeIDs, PasteMode mode) + + + Sets the shim of Item.Paste(String xml, Boolean changeIDs, PasteMode mode) + + + Sets the shim of Item.get_Paths() + + + Sets the shim of Item.get_Publishing() + + + Sets the shim of Item.Recycle() + + + Sets the shim of Item.RecycleChildren() + + + Sets the shim of Item.RecycleVersion() + + + Sets the shim of Item.RejectChanges() + + + Sets the shim of Item.Reload() + + + Sets the shim of Item.get_RuntimeSettings() + + + Sets the shim of Item.get_Security() + + + Sets the shim of Item.set_Security(ItemSecurity value) + + + Sets the shim of Item.SetChanges(ItemChanges changes) + + + Sets the shim of Item.SetDatabase(Database database) + + + Sets the shim of Item.SetInnerData(Item item) + + + Sets the shim of Item.SetProperty(String name, ID value, ID originalValue) + + + Sets the shim of Item.SetProperty(String name, String value, String originalValue) + + + Sets the shim of Item.get_SharedFieldsSource() + + + Sets the shim of Item.get_Source() + + + Sets the shim of Item.get_SourceUri() + + + Sets the shim of Item.get_State() + + + Sets the shim of Item.get_Statistics() + + + Sets the shim of Item.get_SyncRoot() + + + Sets the shim of Item.get_Template() + + + Sets the shim of Item.get_TemplateID() + + + Sets the shim of Item.set_TemplateID(ID value) + + + Sets the shim of Item.get_TemplateName() + + + Sets the shim of Item.get_Uri() + + + Sets the shim of Item.get_Version() + + + Sets the shim of Item.get_Versions() + + + Sets the shim of Item.get_Visualization() + + + Sets the shim of Item.<Delete>b__1b(ID id) + + + Sets the shim of Item.get_Appearance() + + + Sets the shim of Item.get_Axes() + + + Sets the shim of Item.BeginEdit() + + + Assigns the 'Current' behavior for all methods of the shimmed type + + + Assigns the 'NotImplemented' behavior for all methods of the shimmed type + + + Assigns the behavior for all methods of the shimmed type + + + Binds the members of the interface to the shim. + + + Sets the shim of Item.get_Branch() + + + Sets the shim of Item.get_BranchId() + + + Sets the shim of Item.set_BranchId(ID value) + + + Sets the shim of Item.get_Branches() + + + Sets the shim of Item.ChangeTemplate(TemplateItem template) + + + Sets the shim of Item.get_Children() + + + Sets the shim of Item.Clone(ID cloneID, Database ownerDatabase) + + + Sets the shim of Item.Clone(Item item) + + + Sets the shim of Item.CloneTo(Item destination) + + + Sets the shim of Item.CloneTo(Item destination, Boolean deep) + + + Sets the shim of Item.CloneTo(Item destination, String name, Boolean deep) + + + Sets the shim of Item.Item(ID itemID, ItemData data, Database database) + + + Sets the shim of Item.CopyTo(Item destination, String copyName) + + + Sets the shim of Item.CopyTo(Item destination, String copyName, ID copyID, Boolean deep) + + + Sets the shim of Item.get_Database() + + + Sets the shim of Item.Delete() + + + Sets the shim of Item.Delete(Boolean removeBlobs) + + + Sets the shim of Item.DeleteChildren() + + + Sets the shim of Item.get_DisplayName() + + + Sets the shim of Item.Duplicate() + + + Sets the shim of Item.Duplicate(String copyName) + + + Sets the shim of Item.get_Editing() + + + Sets the shim of Item.get_Empty() + + + Sets the shim of Item.EndEdit() + + + Sets the shim of Item.get_Fields() + + + Sets the shim of Item.GetCacheKey(Item item) + + + Sets the shim of Item.GetChanges(Boolean force) + + + Sets the shim of Item.GetChildren() + + + Sets the shim of Item.GetChildren(ChildListOptions options) + + + Sets the shim of Item.GetClones() + + + Sets the shim of Item.GetClones(Boolean processChildren) + + + Sets the shim of Item.GetClonesInternal(Item item, Boolean processChildren) + + + Sets the shim of Item.GetFullChanges() + + + Sets the shim of Item.GetOuterXml(Boolean includeSubitems) + + + Sets the shim of Item.GetOuterXml(ItemSerializerOptions options) + + + Sets the shim of Item.GetProperty(String name) + + + Sets the shim of Item.GetUniqueId() + + + Sets the shim of Item.get_HasChildren() + + + Sets the shim of Item.get_HasClones() + + + Sets the shim of Item.get_Help() + + + Sets the shim of Item.get_ID() + + + Sets the shim of Item.get_InnerData() + + + Sets the shim of Item.get_IsClone() + + + Sets the shim of Item.get_IsEditing() + + + Sets the shim of Item.IsEmpty(ID itemID, Database database) + + + Sets the shim of Item.get_IsItemClone() + + + Sets the shim of Item.get_Key() + + + Sets the shim of Item.get_Language() + + + Sets the shim of Item.get_Languages() + + + Sets the shim of Item.get_Links() + + + Sets the shim of Item.get_Locking() + + + Sets the shim of Item.get_Master() + + + Sets the shim of Item.get_MasterID() + + + Sets the shim of Item.set_MasterID(ID value) + + + Sets the shim of Item.get_Masters() + + + Sets the shim of Item.get_Modified() + + + Sets the shim of Item.MoveTo(Item destination) + + + Sets the shim of Item.get_Name() + + + Sets the shim of Item.set_Name(String value) + + + Sets the shim of Item.get_OriginatorId() + + + Sets the shim of Item.get_Parent() + + + Sets the shim of Item.get_ParentID() + + + Sets the shim of Item.PasteItem(String xml, Boolean changeIDs, PasteMode mode) + + + Sets the shim of Item.Paste(String xml, Boolean changeIDs, PasteMode mode) + + + Sets the shim of Item.get_Paths() + + + Sets the shim of Item.get_Publishing() + + + Sets the shim of Item.Recycle() + + + Sets the shim of Item.RecycleChildren() + + + Sets the shim of Item.RecycleVersion() + + + Sets the shim of Item.RejectChanges() + + + Sets the shim of Item.Reload() + + + Sets the shim of Item.RemoveItemFromCloningCache(Item item) + + + Sets the shim of Item.get_RuntimeSettings() + + + Sets the shim of Item.get_Security() + + + Sets the shim of Item.set_Security(ItemSecurity value) + + + Sets the shim of Item.SetChanges(ItemChanges changes) + + + Sets the shim of Item.SetDatabase(Database database) + + + Sets the shim of Item.SetInnerData(Item item) + + + Sets the shim of Item.SetProperty(String name, ID value, ID originalValue) + + + Sets the shim of Item.SetProperty(String name, String value, String originalValue) + + + Sets the shim of Item.get_SharedFieldsSource() + + + Sets the shim of Item.get_Source() + + + Sets the shim of Item.get_SourceUri() + + + Sets the shim of Item.get_State() + + + Sets the shim of Item.Item() + + + Sets the shim of Item.get_Statistics() + + + Sets the shim of Item.get_SyncRoot() + + + Sets the shim of Item.get_Template() + + + Sets the shim of Item.get_TemplateID() + + + Sets the shim of Item.set_TemplateID(ID value) + + + Sets the shim of Item.get_TemplateName() + + + Sets the shim of Item.TryGetCacheValue(Item item, ItemUri& itemUri) + + + Sets the shim of Item.get_Uri() + + + Sets the shim of Item.get_Version() + + + Sets the shim of Item.get_Versions() + + + Sets the shim of Item.get_Visualization() + + + Sets the shim of Item.<Delete>b__19(TemplateField f) + + + Sets the shim of Item.<Delete>b__1a(TemplateField f) + + + Sets the shim of Item.<Delete>b__1b(ID id) + + + Sets the shim of Item.<Delete>b__1c(Guid guid) + + + diff --git a/Jabberwocky.Glass.Mvc.Tests/Jabberwocky.Glass.Mvc.Tests.csproj b/Jabberwocky.Glass.Mvc.Tests/Jabberwocky.Glass.Mvc.Tests.csproj new file mode 100644 index 0000000..91c85db --- /dev/null +++ b/Jabberwocky.Glass.Mvc.Tests/Jabberwocky.Glass.Mvc.Tests.csproj @@ -0,0 +1,119 @@ + + + + + Debug + AnyCPU + {949B682F-643F-4422-B598-9F5176DB8E2A} + Library + Properties + Jabberwocky.Glass.Mvc.Tests + Jabberwocky.Glass.Mvc.Tests + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll + True + + + ..\packages\Glass.Mapper.Sc.4.0.3.51\lib\net45\Glass.Mapper.dll + True + + + ..\packages\Glass.Mapper.Sc.4.0.3.51\lib\72\Glass.Mapper.Sc.dll + + + ..\packages\Glass.Mapper.Sc.4.0.3.51\lib\Mvc5\Glass.Mapper.Sc.Mvc.dll + + + ..\lib\Sitecore\Testing\HtmlAgilityPack.dll + + + ..\lib\Sitecore\Testing\ITHit.WebDAV.Server.dll + + + ..\lib\Sitecore\Testing\Lucene.Net.dll + + + + ..\lib\Sitecore\Testing\Mvp.Xml.dll + + + ..\packages\NSubstitute.1.8.1.0\lib\net45\NSubstitute.dll + True + + + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + True + + + ..\lib\Sitecore\Sitecore.Kernel.dll + + + FakesAssemblies\Sitecore.Kernel.7.0.0.0.Fakes.dll + + + ..\lib\Sitecore\Testing\Sitecore.Logging.dll + + + ..\lib\Sitecore\Sitecore.Mvc.dll + + + + + + + + + + + + + + + + + {dd17db22-247c-44a6-b0dd-091786863626} + Jabberwocky.Glass.Mvc + + + {13e08d30-b2a4-45ef-a28e-c916eb80b70d} + Jabberwocky.Glass + + + + + + + + + + + + + \ No newline at end of file diff --git a/Jabberwocky.Glass.Mvc.Tests/Properties/AssemblyInfo.cs b/Jabberwocky.Glass.Mvc.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dcc89a0 --- /dev/null +++ b/Jabberwocky.Glass.Mvc.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Jabberwocky.Glass.Mvc.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Jabberwocky.Glass.Mvc.Tests")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("949b682f-643f-4422-b598-9f5176db8e2a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Jabberwocky.Glass.Autofac.Mvc.Tests/Services/RenderingContextServiceTests.cs b/Jabberwocky.Glass.Mvc.Tests/Services/RenderingContextServiceTests.cs similarity index 98% rename from Jabberwocky.Glass.Autofac.Mvc.Tests/Services/RenderingContextServiceTests.cs rename to Jabberwocky.Glass.Mvc.Tests/Services/RenderingContextServiceTests.cs index f70389c..34c3faa 100644 --- a/Jabberwocky.Glass.Autofac.Mvc.Tests/Services/RenderingContextServiceTests.cs +++ b/Jabberwocky.Glass.Mvc.Tests/Services/RenderingContextServiceTests.cs @@ -1,7 +1,7 @@ -using System; +using System; using Glass.Mapper.Sc; -using Jabberwocky.Glass.Autofac.Mvc.Services; using Jabberwocky.Glass.Models; +using Jabberwocky.Glass.Mvc.Services; using Microsoft.QualityTools.Testing.Fakes; using NSubstitute; using NUnit.Framework; @@ -10,7 +10,7 @@ using Sitecore.Mvc.Common; using Sitecore.Mvc.Presentation; -namespace Jabberwocky.Glass.Autofac.Mvc.Tests.Services +namespace Jabberwocky.Glass.Mvc.Tests.Services { [TestFixture] public class RenderingContextServiceTests diff --git a/Jabberwocky.Glass.Mvc.Tests/app.config b/Jabberwocky.Glass.Mvc.Tests/app.config new file mode 100644 index 0000000..d7256aa --- /dev/null +++ b/Jabberwocky.Glass.Mvc.Tests/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Jabberwocky.Glass.Mvc.Tests/packages.config b/Jabberwocky.Glass.Mvc.Tests/packages.config new file mode 100644 index 0000000..7cc1878 --- /dev/null +++ b/Jabberwocky.Glass.Mvc.Tests/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Jabberwocky.Glass.Autofac.Mvc/Attributes/HttpGetOrInvalidHttpPostAttribute.cs b/Jabberwocky.Glass.Mvc/Attributes/HttpGetOrInvalidHttpPostAttribute.cs similarity index 78% rename from Jabberwocky.Glass.Autofac.Mvc/Attributes/HttpGetOrInvalidHttpPostAttribute.cs rename to Jabberwocky.Glass.Mvc/Attributes/HttpGetOrInvalidHttpPostAttribute.cs index a837044..6c469cc 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Attributes/HttpGetOrInvalidHttpPostAttribute.cs +++ b/Jabberwocky.Glass.Mvc/Attributes/HttpGetOrInvalidHttpPostAttribute.cs @@ -1,9 +1,11 @@ -using System; +using System; using System.Reflection; using System.Web.Mvc; -namespace Jabberwocky.Glass.Autofac.Mvc.Attributes +namespace Jabberwocky.Glass.Mvc.Attributes { + // This type is forwarded... until the obolete version is deprecated, any changes here should be evaluated against the forwarded type + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class HttpGetOrInvalidHttpPostAttribute : ActionMethodSelectorAttribute { diff --git a/Jabberwocky.Glass.Autofac.Mvc/Attributes/ValidHttpPostAttribute.cs b/Jabberwocky.Glass.Mvc/Attributes/ValidHttpPostAttribute.cs similarity index 92% rename from Jabberwocky.Glass.Autofac.Mvc/Attributes/ValidHttpPostAttribute.cs rename to Jabberwocky.Glass.Mvc/Attributes/ValidHttpPostAttribute.cs index ae5f698..24444e9 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Attributes/ValidHttpPostAttribute.cs +++ b/Jabberwocky.Glass.Mvc/Attributes/ValidHttpPostAttribute.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Web.Mvc; -namespace Jabberwocky.Glass.Autofac.Mvc.Attributes +namespace Jabberwocky.Glass.Mvc.Attributes { public class ValidHttpPostAttribute : ActionMethodSelectorAttribute { diff --git a/Jabberwocky.Glass.Autofac.Mvc/Attributes/ValidateFormHandlerAttribute.cs b/Jabberwocky.Glass.Mvc/Attributes/ValidateFormHandlerAttribute.cs similarity index 95% rename from Jabberwocky.Glass.Autofac.Mvc/Attributes/ValidateFormHandlerAttribute.cs rename to Jabberwocky.Glass.Mvc/Attributes/ValidateFormHandlerAttribute.cs index 98d1a84..96a2dd4 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Attributes/ValidateFormHandlerAttribute.cs +++ b/Jabberwocky.Glass.Mvc/Attributes/ValidateFormHandlerAttribute.cs @@ -2,7 +2,7 @@ using System.Reflection; using System.Web.Mvc; -namespace Jabberwocky.Glass.Autofac.Mvc.Attributes +namespace Jabberwocky.Glass.Mvc.Attributes { public class ValidateFormHandlerAttribute : ActionMethodSelectorAttribute { diff --git a/Jabberwocky.Glass.Mvc/Internals/AssemblyConstants.cs b/Jabberwocky.Glass.Mvc/Internals/AssemblyConstants.cs new file mode 100644 index 0000000..5f5b024 --- /dev/null +++ b/Jabberwocky.Glass.Mvc/Internals/AssemblyConstants.cs @@ -0,0 +1,21 @@ +// ReSharper disable InconsistentNaming +namespace Jabberwocky.Glass.Mvc.Internals +{ + internal static class AssemblyConstants + { + // Forwarded Types + internal const string HttpGetOrInvalidHttpPostAttributeType = "Jabberwocky.Glass.Autofac.Mvc.Attributes.HttpGetOrInvalidHttpPostAttribute, Jabberwocky.Glass.Autofac.Mvc"; + internal const string ValidateFormHandlerAttributeType = "Jabberwocky.Glass.Autofac.Mvc.Attributes.ValidateFormHandlerAttribute, Jabberwocky.Glass.Autofac.Mvc"; + internal const string ValidHttpPostAttributeType = "Jabberwocky.Glass.Autofac.Mvc.Attributes.ValidHttpPostAttribute, Jabberwocky.Glass.Autofac.Mvc"; + + internal const string IViewModelFactoryType = "Jabberwocky.Glass.Autofac.Mvc.Models.Factory.IViewModelFactory, Jabberwocky.Glass.Autofac.Mvc"; + + internal const string IRenderingContextServiceType = "Jabberwocky.Glass.Autofac.Mvc.Services.IRenderingContextService, Jabberwocky.Glass.Autofac.Mvc"; + internal const string RenderingContextServiceType = "Jabberwocky.Glass.Autofac.Mvc.Services.RenderingContextService, Jabberwocky.Glass.Autofac.Mvc"; + internal const string DatasourceNestingOptionsType = "Jabberwocky.Glass.Autofac.Mvc.Services.DatasourceNestingOptions, Jabberwocky.Glass.Autofac.Mvc"; + + internal const string CustomSitecoreHelperType = "Jabberwocky.Glass.Autofac.Mvc.Util.CustomSitecoreHelper, Jabberwocky.Glass.Autofac.Mvc"; + + internal const string CustomGlassViewType = "Jabberwocky.Glass.Autofac.Mvc.Views.CustomGlassViewType, Jabberwocky.Glass.Autofac.Mvc"; + } +} diff --git a/Jabberwocky.Glass.Mvc/Internals/ForwardedTypes/AutofacMvcTypes.cs b/Jabberwocky.Glass.Mvc/Internals/ForwardedTypes/AutofacMvcTypes.cs new file mode 100644 index 0000000..49f484f --- /dev/null +++ b/Jabberwocky.Glass.Mvc/Internals/ForwardedTypes/AutofacMvcTypes.cs @@ -0,0 +1,78 @@ +using System; +using System.Runtime.CompilerServices; +using System.Web.Mvc; +using Glass.Mapper.Sc; +using Jabberwocky.Glass.Mvc.Internals; + +// ReSharper disable once CheckNamespace +namespace Jabberwocky.Glass.Autofac.Mvc.Attributes +{ + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.HttpGetOrInvalidHttpPostAttributeType)] + public class HttpGetOrInvalidHttpPostAttribute : Glass.Mvc.Attributes.HttpGetOrInvalidHttpPostAttribute + { + } + + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.ValidateFormHandlerAttributeType)] + public class ValidateFormHandlerAttribute : Glass.Mvc.Attributes.ValidateFormHandlerAttribute + { + } + + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.ValidHttpPostAttributeType)] + public class ValidHttpPostAttribute : Glass.Mvc.Attributes.ValidHttpPostAttribute + { + } +} + +namespace Jabberwocky.Glass.Autofac.Mvc.Models.Factory +{ + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.IViewModelFactoryType)] + public interface IViewModelFactory : Glass.Mvc.Models.Factory.IViewModelFactory { } +} + +namespace Jabberwocky.Glass.Autofac.Mvc.Services +{ + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.IRenderingContextServiceType)] + public interface IRenderingContextService : Glass.Mvc.Services.IRenderingContextService { } + + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.RenderingContextServiceType)] + public class RenderingContextService : Glass.Mvc.Services.RenderingContextService { + public RenderingContextService(IGlassHtml glassHtml, ISitecoreContext context) : base(glassHtml, context) + { + } + } + + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.DatasourceNestingOptionsType)] + public enum DatasourceNestingOptions + { + Default, + Never, + Always + } +} + +namespace Jabberwocky.Glass.Autofac.Mvc.Util +{ + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.CustomSitecoreHelperType)] + public class CustomSitecoreHelper : Glass.Mvc.Util.CustomSitecoreHelper { + public CustomSitecoreHelper(HtmlHelper htmlHelper) : base(htmlHelper) + { + } + } +} + +namespace Jabberwocky.Glass.Autofac.Mvc.Views +{ + [Obsolete] + [TypeForwardedFrom(AssemblyConstants.CustomGlassViewType)] + public abstract class CustomGlassView : Glass.Mvc.Views.CustomGlassView where TModel : class + { + } +} \ No newline at end of file diff --git a/Jabberwocky.Glass.Mvc/Jabberwocky.Glass.Mvc.csproj b/Jabberwocky.Glass.Mvc/Jabberwocky.Glass.Mvc.csproj new file mode 100644 index 0000000..3d17049 --- /dev/null +++ b/Jabberwocky.Glass.Mvc/Jabberwocky.Glass.Mvc.csproj @@ -0,0 +1,123 @@ + + + + + Debug + AnyCPU + {DD17DB22-247C-44A6-B0DD-091786863626} + Library + Properties + Jabberwocky.Glass.Mvc + Jabberwocky.Glass.Mvc + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll + True + + + ..\packages\Glass.Mapper.Sc.4.0.3.51\lib\net45\Glass.Mapper.dll + True + + + ..\packages\Glass.Mapper.Sc.4.0.3.51\lib\80\Glass.Mapper.Sc.dll + + + ..\packages\Glass.Mapper.Sc.4.0.3.51\lib\Mvc5\Glass.Mapper.Sc.Mvc.dll + + + ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + True + + + ..\lib\Sitecore\Sitecore.Kernel.dll + + + ..\lib\Sitecore\Sitecore.Mvc.dll + + + + + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll + True + + + ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll + True + + + ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll + True + + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll + True + + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll + True + + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + {13e08d30-b2a4-45ef-a28e-c916eb80b70d} + Jabberwocky.Glass + + + + + \ No newline at end of file diff --git a/Jabberwocky.Glass.Autofac.Mvc/Models/Factory/IViewModelFactory.cs b/Jabberwocky.Glass.Mvc/Models/Factory/IViewModelFactory.cs similarity index 63% rename from Jabberwocky.Glass.Autofac.Mvc/Models/Factory/IViewModelFactory.cs rename to Jabberwocky.Glass.Mvc/Models/Factory/IViewModelFactory.cs index 5ca9850..a45e224 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Models/Factory/IViewModelFactory.cs +++ b/Jabberwocky.Glass.Mvc/Models/Factory/IViewModelFactory.cs @@ -1,6 +1,6 @@ -using System; +using System; -namespace Jabberwocky.Glass.Autofac.Mvc.Models.Factory +namespace Jabberwocky.Glass.Mvc.Models.Factory { public interface IViewModelFactory { diff --git a/Jabberwocky.Glass.Mvc/Properties/AssemblyInfo.cs b/Jabberwocky.Glass.Mvc/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..830e162 --- /dev/null +++ b/Jabberwocky.Glass.Mvc/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Jabberwocky.Glass.Mvc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Velir")] +[assembly: AssemblyProduct("Jabberwocky.Glass.Mvc")] +[assembly: AssemblyCopyright("Copyright © Velir 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("dd17db22-247c-44a6-b0dd-091786863626")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Jabberwocky.Glass.Mvc/Services/DatasourceNestingOptions.cs b/Jabberwocky.Glass.Mvc/Services/DatasourceNestingOptions.cs new file mode 100644 index 0000000..90ddeaa --- /dev/null +++ b/Jabberwocky.Glass.Mvc/Services/DatasourceNestingOptions.cs @@ -0,0 +1,11 @@ +namespace Jabberwocky.Glass.Mvc.Services +{ + // This type is forwarded... until the obolete version is deprecated, any changes here should be evaluated against the forwarded type + + public enum DatasourceNestingOptions + { + Default, + Never, + Always + } +} diff --git a/Jabberwocky.Glass.Mvc/Services/IRenderingContextService.cs b/Jabberwocky.Glass.Mvc/Services/IRenderingContextService.cs new file mode 100644 index 0000000..7e82f94 --- /dev/null +++ b/Jabberwocky.Glass.Mvc/Services/IRenderingContextService.cs @@ -0,0 +1,17 @@ +using System; +using Jabberwocky.Glass.Models; +using Sitecore.Mvc.Presentation; + +namespace Jabberwocky.Glass.Mvc.Services +{ + public interface IRenderingContextService + { + Rendering GetCurrentRendering(); + + T GetCurrentRenderingDatasource(DatasourceNestingOptions options = DatasourceNestingOptions.Default) where T : class, IGlassBase; + + T GetCurrentRenderingParameters() where T : class; + + object GetCurrentRenderingParameters(Type renderingParamType); + } +} \ No newline at end of file diff --git a/Jabberwocky.Glass.Autofac.Mvc/Services/RenderingContextService.cs b/Jabberwocky.Glass.Mvc/Services/RenderingContextService.cs similarity index 98% rename from Jabberwocky.Glass.Autofac.Mvc/Services/RenderingContextService.cs rename to Jabberwocky.Glass.Mvc/Services/RenderingContextService.cs index 39550bc..b94b95f 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Services/RenderingContextService.cs +++ b/Jabberwocky.Glass.Mvc/Services/RenderingContextService.cs @@ -1,12 +1,12 @@ -using System; +using System; using System.Collections.Concurrent; +using System.Linq; using System.Reflection; -using Sitecore.Mvc.Presentation; using Glass.Mapper.Sc; -using System.Linq; using Jabberwocky.Glass.Models; +using Sitecore.Mvc.Presentation; -namespace Jabberwocky.Glass.Autofac.Mvc.Services +namespace Jabberwocky.Glass.Mvc.Services { public class RenderingContextService : IRenderingContextService { diff --git a/Jabberwocky.Glass.Autofac.Mvc/Util/CustomSitecoreHelper.cs b/Jabberwocky.Glass.Mvc/Util/CustomSitecoreHelper.cs similarity index 88% rename from Jabberwocky.Glass.Autofac.Mvc/Util/CustomSitecoreHelper.cs rename to Jabberwocky.Glass.Mvc/Util/CustomSitecoreHelper.cs index e8f4fa1..3ac4806 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Util/CustomSitecoreHelper.cs +++ b/Jabberwocky.Glass.Mvc/Util/CustomSitecoreHelper.cs @@ -1,11 +1,11 @@ -using System.Web; +using System.Web; using System.Web.Mvc; using System.Web.Mvc.Html; -using Jabberwocky.Glass.Autofac.Mvc.Attributes; +using Jabberwocky.Glass.Mvc.Attributes; using Sitecore.Mvc.Extensions; using Sitecore.Mvc.Helpers; -namespace Jabberwocky.Glass.Autofac.Mvc.Util +namespace Jabberwocky.Glass.Mvc.Util { public class CustomSitecoreHelper : SitecoreHelper { diff --git a/Jabberwocky.Glass.Autofac.Mvc/Views/CustomGlassView.cs b/Jabberwocky.Glass.Mvc/Views/CustomGlassView.cs similarity index 85% rename from Jabberwocky.Glass.Autofac.Mvc/Views/CustomGlassView.cs rename to Jabberwocky.Glass.Mvc/Views/CustomGlassView.cs index c9cfa1c..e968623 100644 --- a/Jabberwocky.Glass.Autofac.Mvc/Views/CustomGlassView.cs +++ b/Jabberwocky.Glass.Mvc/Views/CustomGlassView.cs @@ -1,9 +1,9 @@ -using System.Web.Mvc; +using System.Web.Mvc; using Glass.Mapper.Sc.Configuration.Attributes; using Glass.Mapper.Sc.Web.Mvc; -using Jabberwocky.Glass.Autofac.Mvc.Models.Factory; +using Jabberwocky.Glass.Mvc.Models.Factory; -namespace Jabberwocky.Glass.Autofac.Mvc.Views +namespace Jabberwocky.Glass.Mvc.Views { public abstract class CustomGlassView : GlassView where TModel : class { diff --git a/Jabberwocky.Glass.Mvc/packages.config b/Jabberwocky.Glass.Mvc/packages.config new file mode 100644 index 0000000..d1679b0 --- /dev/null +++ b/Jabberwocky.Glass.Mvc/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Jabberwocky.Glass.Tests/Factory/GlassInterfaceFactoryTests.cs b/Jabberwocky.Glass.Tests/Factory/GlassInterfaceFactoryTests.cs index 332a903..0365370 100644 --- a/Jabberwocky.Glass.Tests/Factory/GlassInterfaceFactoryTests.cs +++ b/Jabberwocky.Glass.Tests/Factory/GlassInterfaceFactoryTests.cs @@ -76,6 +76,26 @@ public void Initialize() ZIndex = 0 } } + }, + { + typeof(INestedTestInterface), new[] + { + new GlassInterfaceMetadata + { + GlassType = typeof (IIntermediateTemplate), + ImplementationType = typeof(IIntermediateTemplateModel), + IsFallback = false, + ZIndex = 0 + }, + // Base Type, matches no direct template + new GlassInterfaceMetadata + { + GlassType = typeof (IBaseType), + ImplementationType = typeof (IBaseTypeModel), + IsFallback = true, + ZIndex = 0 + }, + } } }; @@ -289,6 +309,20 @@ public void GlassFactory_ZIndexBehavior_WillHigherPriorityImplementation() Assert.AreEqual("IInheritedTemplateModel", testItem.ZIndexTest); // Should fallback to IInheritedTemplateModel -> BaseType } + [Test] + public void GlassFactory_FallbackBehavior_WorksWithNestedInterfaces() + { + + var mockItem = Substitute.For(); + mockItem._Id = Guid.NewGuid(); + mockItem._TemplateId.Returns(new Guid(FakeIntermediateTemplate)); // matching template + mockItem._BaseTemplates.Returns(new Guid[0]); + + var testItem = _glassFactory.GetItem(mockItem); + Assert.IsNotNull(testItem); + Assert.AreEqual("IBaseTypeModel", testItem.ZIndexTest); // Should fallback to IIntermediateTemplateModel -> BaseType + } + private ITestInterface GetItemWithFallback() { var mockItem = Substitute.For(); @@ -350,6 +384,12 @@ private interface ITestInterface string ZIndexTest { get; } } + [GlassFactoryInterface] + private interface INestedTestInterface : ITestInterface + { + + } + [GlassFactoryType(typeof (IInheritedTemplate), ZIndex = 1)] public abstract class IInheritedTemplateModel : ITestInterface { @@ -415,7 +455,7 @@ public object DontCallMe() } [GlassFactoryType(typeof (IBaseType))] - public abstract class IBaseTypeModel : ITestInterface + public abstract class IBaseTypeModel : ITestInterface, INestedTestInterface { private readonly IBaseType _innerItem; protected IBaseTypeModel(IBaseType innerItem) @@ -452,7 +492,7 @@ public object DontCallMe() } [GlassFactoryType(typeof(IIntermediateTemplate))] - public abstract class IIntermediateTemplateModel : ITestInterface + public abstract class IIntermediateTemplateModel : INestedTestInterface { public abstract bool IsNotFallback { get; } public abstract bool IsFallback { get; } diff --git a/Jabberwocky.Glass.Tests/Jabberwocky.Glass.Tests.csproj b/Jabberwocky.Glass.Tests/Jabberwocky.Glass.Tests.csproj index 84eb1f5..fe6eb66 100644 --- a/Jabberwocky.Glass.Tests/Jabberwocky.Glass.Tests.csproj +++ b/Jabberwocky.Glass.Tests/Jabberwocky.Glass.Tests.csproj @@ -57,6 +57,13 @@ False ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + False + ..\lib\Sitecore\Sitecore.Kernel.dll + + + ..\lib\Sitecore\Sitecore.Mvc.dll + diff --git a/Jabberwocky.Glass/Factory/Interceptors/FallbackInterceptor.cs b/Jabberwocky.Glass/Factory/Interceptors/FallbackInterceptor.cs index 25391d4..b30d8a2 100644 --- a/Jabberwocky.Glass/Factory/Interceptors/FallbackInterceptor.cs +++ b/Jabberwocky.Glass/Factory/Interceptors/FallbackInterceptor.cs @@ -1,7 +1,9 @@ using System; +using System.Linq; using System.Reflection; using Castle.DynamicProxy; using Glass.Mapper.Sc.Configuration.Attributes; +using Jabberwocky.Core.Utils.Extensions; using Jabberwocky.Glass.Factory.Attributes; using Jabberwocky.Glass.Factory.Caching; using Jabberwocky.Glass.Factory.Implementation; @@ -78,17 +80,34 @@ private void ResolveInvocation(IInvocation invocation, GlassFactoryTypeAttribute ? invocationTarget.GetGenericMethodDefinition() : invocationTarget; - var map = invocation.TargetType.GetInterfaceMap(_interfaceType); - var index = Array.IndexOf(map.TargetMethods, targetMethod); + var fallbackMethod = GetFallbackInterfaceMethod(invocation, _interfaceType, invocationTarget, targetMethod); + if (fallbackMethod != null) + { + invocation.ReturnValue = fallbackMethod.Invoke(fallbackImpl, invocation.Arguments); + } + } - if (index == -1) return; + private static MethodInfo GetFallbackInterfaceMethod(IInvocation invocation, Type targetInterfaceType, + MethodInfo invocationTarget, MethodInfo targetMethod) + { + var interfaceCandidates = new[] { targetInterfaceType }.Concat(targetInterfaceType.GetInterfaces()); - MethodInfo interfaceMethod = map.InterfaceMethods[index]; - interfaceMethod = interfaceMethod.IsGenericMethod - ? interfaceMethod.MakeGenericMethod(invocationTarget.GetGenericArguments()) - : interfaceMethod; + foreach (var interfaceType in interfaceCandidates) + { + var map = invocation.TargetType.GetInterfaceMap(interfaceType); + var index = Array.IndexOf(map.TargetMethods, targetMethod); + + if (index == -1) continue; + + MethodInfo interfaceMethod = map.InterfaceMethods[index]; + interfaceMethod = interfaceMethod.IsGenericMethod + ? interfaceMethod.MakeGenericMethod(invocationTarget.GetGenericArguments()) + : interfaceMethod; + + return interfaceMethod; + } - invocation.ReturnValue = interfaceMethod.Invoke(fallbackImpl, invocation.Arguments); + return null; } } } diff --git a/Jabberwocky.Glass/Properties/AssemblyInfo.cs b/Jabberwocky.Glass/Properties/AssemblyInfo.cs index 1e4ea9e..1ec3133 100644 --- a/Jabberwocky.Glass/Properties/AssemblyInfo.cs +++ b/Jabberwocky.Glass/Properties/AssemblyInfo.cs @@ -32,7 +32,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] +[assembly: AssemblyVersion("1.1.1.0")] +[assembly: AssemblyFileVersion("1.1.1.0")] [assembly: InternalsVisibleTo("Jabberwocky.Glass.Tests")] [assembly: InternalsVisibleTo("Jabberwocky.Glass.Autofac")] diff --git a/Jabberwocky.sln b/Jabberwocky.sln index 4491bc7..d1c859e 100644 --- a/Jabberwocky.sln +++ b/Jabberwocky.sln @@ -60,6 +60,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jabberwocky.Glass.Autofac.W EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jabberwocky.Autofac.Tests", "Jabberwocky.Autofac.Tests\Jabberwocky.Autofac.Tests.csproj", "{87913926-895A-422B-B462-EF685DCAE215}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jabberwocky.Glass.Mvc", "Jabberwocky.Glass.Mvc\Jabberwocky.Glass.Mvc.csproj", "{DD17DB22-247C-44A6-B0DD-091786863626}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jabberwocky.Glass.Mvc.Tests", "Jabberwocky.Glass.Mvc.Tests\Jabberwocky.Glass.Mvc.Tests.csproj", "{949B682F-643F-4422-B598-9F5176DB8E2A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -142,6 +146,14 @@ Global {87913926-895A-422B-B462-EF685DCAE215}.Debug|Any CPU.Build.0 = Debug|Any CPU {87913926-895A-422B-B462-EF685DCAE215}.Release|Any CPU.ActiveCfg = Release|Any CPU {87913926-895A-422B-B462-EF685DCAE215}.Release|Any CPU.Build.0 = Release|Any CPU + {DD17DB22-247C-44A6-B0DD-091786863626}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD17DB22-247C-44A6-B0DD-091786863626}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD17DB22-247C-44A6-B0DD-091786863626}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD17DB22-247C-44A6-B0DD-091786863626}.Release|Any CPU.Build.0 = Release|Any CPU + {949B682F-643F-4422-B598-9F5176DB8E2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {949B682F-643F-4422-B598-9F5176DB8E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {949B682F-643F-4422-B598-9F5176DB8E2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {949B682F-643F-4422-B598-9F5176DB8E2A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -169,5 +181,7 @@ Global {44DB88AB-C38E-4CAE-ADA0-BC64778A1D4A} = {338A9D71-3ED1-4E69-AC1B-E5033846B3A4} {86B4E810-DCA7-4510-BA2B-EC1DDA9CB7FE} = {FF1D41BA-5DE4-49CC-8CFF-08B1BF700C3D} {87913926-895A-422B-B462-EF685DCAE215} = {7EF6690B-FB53-4BC9-A915-93E893FE3225} + {DD17DB22-247C-44A6-B0DD-091786863626} = {FF1D41BA-5DE4-49CC-8CFF-08B1BF700C3D} + {949B682F-643F-4422-B598-9F5176DB8E2A} = {7EF6690B-FB53-4BC9-A915-93E893FE3225} EndGlobalSection EndGlobal