diff --git a/src/Umbraco.Compat7/Core/Models/PublishedContent/PublishedContentModelFactoryResolver.cs b/src/Umbraco.Compat7/Core/Models/PublishedContent/PublishedContentModelFactoryResolver.cs
index a8774743c6..1f4ab8acf9 100644
--- a/src/Umbraco.Compat7/Core/Models/PublishedContent/PublishedContentModelFactoryResolver.cs
+++ b/src/Umbraco.Compat7/Core/Models/PublishedContent/PublishedContentModelFactoryResolver.cs
@@ -13,11 +13,11 @@ namespace Umbraco.Core.Models.PublishedContent
public static bool HasCurrent => true;
- public void SetFactory(IPublishedContentModelFactory factory)
+ public void SetFactory(IPublishedModelFactory factory)
{
CoreCurrent.Container.RegisterSingleton(_ => factory);
}
- public IPublishedContentModelFactory Factory => CoreCurrent.PublishedContentModelFactory;
+ public IPublishedModelFactory Factory => CoreCurrent.PublishedModelFactory;
}
}
diff --git a/src/Umbraco.Core/Components/CompositionExtensions.cs b/src/Umbraco.Core/Components/CompositionExtensions.cs
index 9500ccaa2d..f3764e13f9 100644
--- a/src/Umbraco.Core/Components/CompositionExtensions.cs
+++ b/src/Umbraco.Core/Components/CompositionExtensions.cs
@@ -125,9 +125,9 @@ namespace Umbraco.Core.Components
/// The type of the factory.
/// The composition.
public static void SetPublishedContentModelFactory(this Composition composition)
- where T : IPublishedContentModelFactory
+ where T : IPublishedModelFactory
{
- composition.Container.RegisterSingleton();
+ composition.Container.RegisterSingleton();
}
///
@@ -135,7 +135,7 @@ namespace Umbraco.Core.Components
///
/// The composition.
/// A function creating a published content model factory.
- public static void SetPublishedContentModelFactory(this Composition composition, Func factory)
+ public static void SetPublishedContentModelFactory(this Composition composition, Func factory)
{
composition.Container.RegisterSingleton(factory);
}
@@ -145,7 +145,7 @@ namespace Umbraco.Core.Components
///
/// The composition.
/// A published content model factory.
- public static void SetPublishedContentModelFactory(this Composition composition, IPublishedContentModelFactory factory)
+ public static void SetPublishedContentModelFactory(this Composition composition, IPublishedModelFactory factory)
{
composition.Container.RegisterSingleton(_ => factory);
}
diff --git a/src/Umbraco.Core/Composing/Current.cs b/src/Umbraco.Core/Composing/Current.cs
index 31b3ed6831..8326be987f 100644
--- a/src/Umbraco.Core/Composing/Current.cs
+++ b/src/Umbraco.Core/Composing/Current.cs
@@ -123,8 +123,8 @@ namespace Umbraco.Core.Composing
internal static PropertyValueConverterCollection PropertyValueConverters
=> Container.GetInstance();
- internal static IPublishedContentModelFactory PublishedContentModelFactory
- => Container.GetInstance();
+ internal static IPublishedModelFactory PublishedModelFactory
+ => Container.GetInstance();
public static IServerMessenger ServerMessenger
=> Container.GetInstance();
diff --git a/src/Umbraco.Core/CoreRuntimeComponent.cs b/src/Umbraco.Core/CoreRuntimeComponent.cs
index ba87b49c50..06567d2691 100644
--- a/src/Umbraco.Core/CoreRuntimeComponent.cs
+++ b/src/Umbraco.Core/CoreRuntimeComponent.cs
@@ -120,7 +120,7 @@ namespace Umbraco.Core
.Append();
// by default, register a noop factory
- composition.Container.RegisterSingleton();
+ composition.Container.RegisterSingleton();
}
internal void Initialize(IEnumerable mapperProfiles)
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs
index db6dc4d88d..6b65b7b421 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
namespace Umbraco.Core.Models.PublishedContent
{
+ ///
///
/// Represents a cached content.
///
@@ -17,13 +18,16 @@ namespace Umbraco.Core.Models.PublishedContent
{
#region Content
+ // fixme - all these are colliding with models => ?
+ // or could we force them to be 'new' in models?
+
int Id { get; }
int TemplateId { get; }
int SortOrder { get; }
string Name { get; }
- string UrlName { get; }
- string DocumentTypeAlias { get; }
- int DocumentTypeId { get; }
+ string UrlName { get; } // fixme rename
+ string DocumentTypeAlias { get; } // fixme obsolete
+ int DocumentTypeId { get; } // fixme obsolete
string WriterName { get; }
string CreatorName { get; }
int WriterId { get; }
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentExtended.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentExtended.cs
deleted file mode 100644
index 524ef969b3..0000000000
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentExtended.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace Umbraco.Core.Models.PublishedContent
-{
- ///
- /// Provides methods to handle extended content.
- ///
- internal interface IPublishedContentExtended : IPublishedContent
- {
- ///
- /// Adds a property to the extended content.
- ///
- /// The property to add.
- void AddProperty(IPublishedProperty property);
-
- ///
- /// Gets a value indicating whether properties were added to the extended content.
- ///
- bool HasAddedProperties { get; }
- }
-}
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContentModelFactory.cs
deleted file mode 100644
index 350e5970eb..0000000000
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContentModelFactory.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Umbraco.Core.Models.PublishedContent
-{
- ///
- /// Provides the model creation service.
- ///
- public interface IPublishedContentModelFactory // fixme rename IFacadeModelFactory
- {
- ///
- /// Creates a strongly-typed model representing a property set.
- ///
- /// The original property set.
- /// The strongly-typed model representing the property set, or the property set
- /// itself it the factory has no model for that content type.
- IPublishedElement CreateModel(IPublishedElement set);
-
- ///
- /// Gets the model type map.
- ///
- Dictionary ModelTypeMap { get; }
-
- // fixme
- //
- // ModelFactory.Meta.Model("thing").ClrType (find the our post?)
- //
- // then
- // make a plan to get NestedContent in
- // and an equivalent of Vorto with different syntax
- //
- // then
- // VARIANTS ARCHITECTURE FFS!
- }
-}
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedModelFactory.cs
new file mode 100644
index 0000000000..9e488dd797
--- /dev/null
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedModelFactory.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+
+namespace Umbraco.Core.Models.PublishedContent
+{
+ ///
+ /// Provides the published model creation service.
+ ///
+ public interface IPublishedModelFactory
+ {
+ ///
+ /// Creates a strongly-typed model representing a published element.
+ ///
+ /// The original published element.
+ /// The strongly-typed model representing the published element, or the published element
+ /// itself it the factory has no model for the corresponding element type.
+ IPublishedElement CreateModel(IPublishedElement element);
+
+ ///
+ /// Gets the model type map.
+ ///
+ /// The model type map maps element type aliases to actual Clr types.
+ Dictionary ModelTypeMap { get; }
+ }
+}
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
index 83cd9d0dfe..d78ced95a7 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
@@ -1,7 +1,7 @@
namespace Umbraco.Core.Models.PublishedContent
{
///
- /// Represents a property of an IPublishedContent.
+ /// Represents a property of an IPublishedElement.
///
public interface IPublishedProperty
{
diff --git a/src/Umbraco.Core/Models/PublishedContent/IndexedArrayItem.cs b/src/Umbraco.Core/Models/PublishedContent/IndexedArrayItem.cs
index 0349807e27..5dc42cc542 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IndexedArrayItem.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IndexedArrayItem.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
+using System.Web;
namespace Umbraco.Core.Models.PublishedContent
{
diff --git a/src/Umbraco.Core/Models/PublishedContent/ModelType.cs b/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
index 93ba2e1788..3589643926 100644
--- a/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
@@ -6,13 +6,15 @@ using System.Reflection;
namespace Umbraco.Core.Models.PublishedContent
{
- // create a simple model type:
- // ModelType.For("alias")
- // use in a generic type:
- // typeof (IEnumerable<>).MakeGenericType(ModelType.For("alias"))
- // use in an array:
- // ModelType.For("alias").MakeArrayType()
-
+ ///
+ ///
+ /// Represents the Clr type of a model.
+ ///
+ ///
+ /// ModelType.For("alias")
+ /// typeof (IEnumerable{}).MakeGenericType(ModelType.For("alias"))
+ /// Model.For("alias").MakeArrayType()
+ ///
public class ModelType : Type
{
private ModelType(string contentTypeAlias)
@@ -21,14 +23,29 @@ namespace Umbraco.Core.Models.PublishedContent
Name = "{" + ContentTypeAlias + "}";
}
+ ///
+ /// Gets the content type alias.
+ ///
public string ContentTypeAlias { get; }
+ ///
public override string ToString()
=> Name;
+ ///
+ /// Gets the model type for a published element type.
+ ///
+ /// The published element type alias.
+ /// The model type for the published element type.
public static ModelType For(string alias)
=> new ModelType(alias);
+ ///
+ /// Gets the actual Clr type by replacing model types, if any.
+ ///
+ /// The type.
+ /// The model types map.
+ /// The actual Clr type.
public static Type Map(Type type, Dictionary modelTypes)
{
if (type is ModelType modelType)
@@ -47,12 +64,21 @@ namespace Umbraco.Core.Models.PublishedContent
if (type.IsGenericType == false)
return type;
+ var def = type.GetGenericTypeDefinition();
+ if (def == null)
+ throw new InvalidOperationException("panic");
var args = type.GetGenericArguments().Select(x => Map(x, modelTypes)).ToArray();
-
- return type.GetGenericTypeDefinition().MakeGenericType(args);
+ return def.MakeGenericType(args);
}
+ ///
+ /// Gets a value indicating whether two instances are equal.
+ ///
+ /// The first instance.
+ /// The second instance.
+ /// A value indicating whether the two instances are equal.
+ /// Knows how to compare instances.
public static bool Equals(Type t1, Type t2)
{
if (t1 == t2)
@@ -80,104 +106,144 @@ namespace Umbraco.Core.Models.PublishedContent
return true;
}
+ ///
protected override TypeAttributes GetAttributeFlagsImpl()
=> TypeAttributes.Class;
+ ///
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
=> Array.Empty();
+ ///
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
=> null;
+ ///
public override Type[] GetInterfaces()
=> Array.Empty();
+ ///
public override Type GetInterface(string name, bool ignoreCase)
=> null;
+ ///
public override EventInfo[] GetEvents(BindingFlags bindingAttr)
=> Array.Empty();
+ ///
public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
=> null;
+ ///
public override Type[] GetNestedTypes(BindingFlags bindingAttr)
=> Array.Empty();
+ ///
public override Type GetNestedType(string name, BindingFlags bindingAttr)
=> null;
+ ///
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
=> Array.Empty();
+ ///
protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
=> null;
+ ///
public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
=> Array.Empty();
+ ///
protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
=> null;
+ ///
public override FieldInfo[] GetFields(BindingFlags bindingAttr)
=> Array.Empty();
+ ///
public override FieldInfo GetField(string name, BindingFlags bindingAttr)
=> null;
+ ///
public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
=> Array.Empty();
+ ///
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
=> Array.Empty