本文整理汇总了C#中ISitecoreService.CreateClasses方法的典型用法代码示例。如果您正苦于以下问题:C# ISitecoreService.CreateClasses方法的具体用法?C# ISitecoreService.CreateClasses怎么用?C# ISitecoreService.CreateClasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISitecoreService
的用法示例。
在下文中一共展示了ISitecoreService.CreateClasses方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValue
public override object GetValue(global::Sitecore.Data.Items.Item item, ISitecoreService service)
{
int numChildren = item.Children.Count;
Type genericType = Utility.GetGenericArgument(Property.PropertyType);
var getItems = new Func<IEnumerable<Item>>(() =>
{
switch (Options)
{
case SitecoreLinkedOptions.All:
var itemLinks1 = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferences(item);
var itemLinks2 = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferrers(item);
return itemLinks1.Select(x => x.GetTargetItem()).Union(itemLinks2.Select(x=>x.GetSourceItem()));
break;
case SitecoreLinkedOptions.References:
var itemLinks3 = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferences(item);
return itemLinks3.Select(x => x.GetTargetItem());
break;
case SitecoreLinkedOptions.Referrers:
var itemLinks4 = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferrers(item);
return itemLinks4.Select(x => x.GetSourceItem());
break;
default:
return new List<Item>();
}
});
return service.CreateClasses(IsLazy, InferType, genericType, getItems);
}
示例2: GetValue
public override object GetValue(global::Sitecore.Data.Items.Item item, ISitecoreService service)
{
int numChildren = item.Children.Count;
Type genericType = Utility.GetGenericArgument(Property.PropertyType);
Func<IEnumerable<Item>> getItems = new Func<IEnumerable<Item>>(() =>
{
return item.Children.Cast<Item>();
});
return service.CreateClasses(IsLazy, InferType, genericType, getItems);
}
示例3: GetValue
public override object GetValue(global::Sitecore.Data.Items.Item item, ISitecoreService service)
{
string query = ParseQuery(Query, item);
if (Property.PropertyType.IsGenericType)
{
Type outerType = Utility.GetGenericOuter(Property.PropertyType);
if (typeof(IEnumerable<>) == outerType)
{
Type genericType = Utility.GetGenericArgument(Property.PropertyType);
Func<IEnumerable<Item>> getItems = null;
if (IsRelative)
{
getItems = new Func<IEnumerable<Item>>(() =>
{
return item.Axes.SelectItems(query);
});
}
else
{
getItems = new Func<IEnumerable<Item>>(() =>
{
return item.Database.SelectItems(query);
});
}
return service.CreateClasses(IsLazy, InferType, genericType, getItems);
}
else throw new NotSupportedException("Generic type not supported {0}. Must be IEnumerable<>.".Formatted(outerType.FullName));
}
else
{
Item result = null;
if (IsRelative)
{
result = item.Axes.SelectSingleItem(query);
}
else
{
result = item.Database.SelectSingleItem(query);
}
return service.CreateClass(IsLazy, InferType, Property.PropertyType, result);
}
}
示例4: GetValue
public override object GetValue(global::Sitecore.Data.Items.Item item, ISitecoreService service)
{
string query = ParseQuery(Query, item);
if (Property.PropertyType.IsGenericType)
{
Type outerType = Utility.GetGenericOuter(Property.PropertyType);
if (typeof(IEnumerable<>) == outerType)
{
Type genericType = Utility.GetGenericArgument(Property.PropertyType);
Func<IEnumerable<Item>> getItems = null;
if (IsRelative)
{
getItems = new Func<IEnumerable<Item>>(() =>
{
return item.Axes.SelectItems(query);
});
}
else
{
getItems = new Func<IEnumerable<Item>>(() =>
{
if (UseQueryContext)
{
Query conQuery = new Query(query);
QueryContext queryContext = new QueryContext(item.Database.DataManager);
object obj = conQuery.Execute(queryContext);
QueryContext[] contextArray = obj as QueryContext[];
QueryContext context = obj as QueryContext;
if (contextArray == null)
contextArray = new QueryContext[] { context };
return contextArray.Select(x => item.Database.GetItem(x.ID));
}
else
return item.Database.SelectItems(query);
});
}
return service.CreateClasses(IsLazy, InferType, genericType, getItems);
}
else throw new NotSupportedException("Generic type not supported {0}. Must be IEnumerable<>.".Formatted(outerType.FullName));
}
else
{
Item result = null;
if (IsRelative)
{
result = item.Axes.SelectSingleItem(query);
}
else
{
result = item.Database.SelectSingleItem(query);
}
return service.CreateClass(IsLazy, InferType, Property.PropertyType, result);
}
}