当前位置: 首页>>代码示例>>C#>>正文


C# ISitecoreService.CreateClass方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:pworst,项目名称:Glass.Sitecore.Mapper,代码行数:17,代码来源:SitecoreItemHandler.cs

示例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);

        }
开发者ID:photomoose,项目名称:Glass.Sitecore.Mapper,代码行数:20,代码来源:SitecoreFieldClassHandler.cs

示例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);
            
        }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:21,代码来源:SitecoreFieldClassHandler.cs

示例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);
            }

        }
开发者ID:brianfeucht,项目名称:Glass.Sitecore.Mapper,代码行数:48,代码来源:SitecoreQueryHandler.cs

示例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);
            }

        }
开发者ID:simonproctor,项目名称:Glass.Sitecore.Mapper,代码行数:63,代码来源:SitecoreQueryHandler.cs

示例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);
 }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:4,代码来源:SitecoreParentHandler.cs


注:本文中的ISitecoreService.CreateClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。