AB3267 - Use interface instead of concrete class

This commit is contained in:
Bjarke Berg
2019-10-22 09:44:51 +02:00
parent 35cae68214
commit dd909ebde4
2 changed files with 12 additions and 3 deletions

View File

@@ -199,10 +199,10 @@ namespace Umbraco.ModelsBuilder.Building
sb.AppendFormat("\t\tpublic new const PublishedItemType ModelItemType = PublishedItemType.{0};\n",
itemType);
WriteGeneratedCodeAttribute(sb, "\t\t");
sb.Append("\t\tpublic new static PublishedContentType GetModelContentType()\n");
sb.Append("\t\tpublic new static IPublishedContentType GetModelContentType()\n");
sb.Append("\t\t\t=> PublishedModelUtility.GetModelContentType(ModelItemType, ModelTypeAlias);\n");
WriteGeneratedCodeAttribute(sb, "\t\t");
sb.AppendFormat("\t\tpublic static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<{0}, TValue>> selector)\n",
sb.AppendFormat("\t\tpublic static IPublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<{0}, TValue>> selector)\n",
type.ClrName);
sb.Append("\t\t\t=> PublishedModelUtility.GetModelPropertyType(GetModelContentType(), selector);\n");
sb.Append("#pragma warning restore 0109\n\n");

View File

@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using Umbraco.Web.Composing;
@@ -40,7 +41,15 @@ namespace Umbraco.ModelsBuilder.Umbraco
}
}
public static IPublishedPropertyType GetModelPropertyType<TModel, TValue>(PublishedContentType contentType, Expression<Func<TModel, TValue>> selector)
[Obsolete("Use the overload taking IPublishedContentType instead")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static IPublishedPropertyType GetModelPropertyType<TModel, TValue>(PublishedContentType contentType,
Expression<Func<TModel, TValue>> selector)
{
return GetModelPropertyType((IPublishedContentType)contentType, selector);
}
public static IPublishedPropertyType GetModelPropertyType<TModel, TValue>(IPublishedContentType contentType, Expression<Func<TModel, TValue>> selector)
//where TModel : PublishedContentModel // fixme PublishedContentModel _or_ PublishedElementModel
{
// fixme therefore, missing a check on TModel here