From 95a4bb9ba6ff0f20d4958b6bbc955d0f4deae9d8 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 19 May 2014 13:15:47 +0200 Subject: [PATCH] refactor PublishedContentModelFactory --- src/Umbraco.Core/CoreBootManager.cs | 3 +-- .../PublishedContentModelFactory.cs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index 60c7c608e1..f59b6e37ab 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -329,9 +329,8 @@ namespace Umbraco.Core UrlSegmentProviderResolver.Current = new UrlSegmentProviderResolver( typeof (DefaultUrlSegmentProvider)); - // keep it internal for now + // by default, no factory is activated PublishedContentModelFactoryResolver.Current = new PublishedContentModelFactoryResolver(); - // new PublishedContentModelFactoryImpl()); } } } diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactory.cs index 4e91a3a04c..d0874dd58f 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactory.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactory.cs @@ -14,9 +14,22 @@ namespace Umbraco.Core.Models.PublishedContent private readonly Dictionary> _constructors; - public PublishedContentModelFactory() + /// + /// Initializes a new instance of the class with types. + /// + /// The model types. + /// + /// Types must implement IPublishedContent and have a unique constructor that + /// accepts one IPublishedContent as a parameter. + /// To activate, + /// + /// var types = PluginManager.Current.ResolveTypes{PublishedContentModel}(); + /// var factory = new PublishedContentModelFactoryImpl(types); + /// PublishedContentModelFactoryResolver.Current.SetFactory(factory); + /// + /// + public PublishedContentModelFactory(IEnumerable types) { - var types = PluginManager.Current.ResolveTypes(); var ctorArgTypes = new[] { typeof(IPublishedContent) }; var constructors = new Dictionary>();