refactor PublishedContentModelFactory

This commit is contained in:
Stephan
2014-05-19 13:15:47 +02:00
parent 32b7871eaf
commit 95a4bb9ba6
2 changed files with 16 additions and 4 deletions

View File

@@ -14,9 +14,22 @@ namespace Umbraco.Core.Models.PublishedContent
private readonly Dictionary<string, Func<IPublishedContent, IPublishedContent>> _constructors;
public PublishedContentModelFactory()
/// <summary>
/// Initializes a new instance of the <see cref="PublishedContentModelFactory"/> class with types.
/// </summary>
/// <param name="types">The model types.</param>
/// <remarks>
/// <para>Types must implement <c>IPublishedContent</c> and have a unique constructor that
/// accepts one IPublishedContent as a parameter.</para>
/// <para>To activate,</para>
/// <code>
/// var types = PluginManager.Current.ResolveTypes{PublishedContentModel}();
/// var factory = new PublishedContentModelFactoryImpl(types);
/// PublishedContentModelFactoryResolver.Current.SetFactory(factory);
/// </code>
/// </remarks>
public PublishedContentModelFactory(IEnumerable<Type> types)
{
var types = PluginManager.Current.ResolveTypes<PublishedContentModel>();
var ctorArgTypes = new[] { typeof(IPublishedContent) };
var constructors = new Dictionary<string, Func<IPublishedContent, IPublishedContent>>();