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


C# ISitecoreService.CreateClasses方法代码示例

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

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

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

        }
开发者ID:brianfeucht,项目名称:Glass.Sitecore.Mapper,代码行数:48,代码来源:SitecoreQueryHandler.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>>(() =>
                        {
                            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


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