本文整理汇总了C#中CategoryModel.InjectFrom方法的典型用法代码示例。如果您正苦于以下问题:C# CategoryModel.InjectFrom方法的具体用法?C# CategoryModel.InjectFrom怎么用?C# CategoryModel.InjectFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel.InjectFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCategoryModel
/// <summary>
/// Creates the category model.
/// </summary>
/// <param name="category">The category.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">category</exception>
public static CategoryModel CreateCategoryModel(CategoryBase category)
{
if (category == null)
{
throw new ArgumentNullException("category");
}
var model = new CategoryModel { Category = category };
model.InjectFrom(category);
model.LinkedCategories = new List<LinkedCategory>(category.LinkedCategories).ToArray();
model.CatalogOutline = CatalogClient.BuildCategoryOutline(UserHelper.CustomerSession.CatalogId, category);
if (category is Category)
{
var realCat = category as Category;
model.CategoryPropertyValues = new List<CategoryPropertyValue>(realCat.CategoryPropertyValues).ToArray();
if (realCat.PropertySet != null && realCat.CategoryPropertyValues != null)
{
var values = realCat.CategoryPropertyValues;
var properties = realCat.PropertySet.PropertySetProperties.SelectMany(x => values.Where(v => v.Name == x.Property.Name
&& !x.Property.PropertyAttributes.Any(pa => pa.PropertyAttributeName.Equals("Hidden", StringComparison.OrdinalIgnoreCase))
&& (!x.Property.IsLocaleDependant
|| string.Equals(v.Locale, CultureInfo.CurrentUICulture.Name, StringComparison.InvariantCultureIgnoreCase))),
(r, v) => CreatePropertyModel(r.Priority, r.Property, v, category)).ToArray();
model.Properties = new PropertiesModel(properties);
}
}
return model;
}