本文整理汇总了C#中ISitecoreService.CreateClass方法的典型用法代码示例。如果您正苦于以下问题:C# ISitecoreService.CreateClass方法的具体用法?C# ISitecoreService.CreateClass怎么用?C# ISitecoreService.CreateClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISitecoreService
的用法示例。
在下文中一共展示了ISitecoreService.CreateClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValue
public override object GetValue(global::Sitecore.Data.Items.Item item, ISitecoreService service)
{
if (Id != Guid.Empty)
{
var scItem = service.Database.GetItem(new ID(Id));
return service.CreateClass(IsLazy, false, Property.Property.PropertyType, scItem);
}
else if (!Path.IsNullOrEmpty())
{
var scItem = service.Database.GetItem(Path);
return service.CreateClass(IsLazy, false, Property.Property.PropertyType, scItem);
}
else
{
return null;
}
}
示例2: GetFieldValue
public override object GetFieldValue(string fieldValue, Item item, ISitecoreService service)
{
Item target = null;
if (fieldValue.IsNullOrEmpty()) return null;
Guid id = Guid.Empty;
if (Guid.TryParse(fieldValue, out id))
{
target = item.Database.GetItem(new ID(id), item.Language);
}
else
{
target = item.Database.GetItem(fieldValue, item.Language);
}
if (target == null) return null;
return service.CreateClass(IsLazy, InferType, Property.PropertyType, target);
}
示例3: GetFieldValue
public override object GetFieldValue(string fieldValue, Item item, ISitecoreService service)
{
Item target = null;
if (fieldValue.IsNullOrEmpty()) return null;
try
{
Guid id = Guid.Empty;
id = new Guid(fieldValue);
target = item.Database.GetItem(new ID(id));
}
catch (Exception ex)
{
target = item.Database.GetItem(fieldValue);
}
if (target == null) return null;
return service.CreateClass(IsLazy, InferType, Property.PropertyType, target);
}
示例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>>(() =>
{
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);
}
}
示例5: 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);
}
}
示例6: GetValue
public override object GetValue(global::Sitecore.Data.Items.Item item, ISitecoreService service)
{
return service.CreateClass(this.IsLazy, this.InferType, Property.PropertyType, item.Parent);
}