コード例 #1
0
        private IEnumerable <GlassField> GetFields(KeyValuePair <Type, Configuration.SitecoreClassConfig> cls)
        {
            var scProps = cls.Value.Properties.Where(x => x.Attribute is SitecoreFieldAttribute);

            List <GlassField> fields = new List <GlassField>();


            foreach (var scProp in scProps)
            {
                var fieldAttr = scProp.Attribute as SitecoreFieldAttribute;
                var handler   = cls.Value.DataHandlers.Where(x => x.Property == scProp.Property).FirstOrDefault() as AbstractSitecoreField;

                GlassField field = new GlassField();

                field.Name        = scProp.Property.Name;
                field.Type        = DashboardUtilities.GetTypeName(scProp.Property.PropertyType);
                field.FieldName   = handler.FieldName;
                field.FieldId     = fieldAttr.FieldId;
                field.ReadOnly    = fieldAttr.ReadOnly;
                field.CodeFirst   = fieldAttr.CodeFirst;
                field.SectionName = fieldAttr.SectionName;
                field.FieldType   = fieldAttr.FieldType.ToString();
                field.FieldTitle  = fieldAttr.FieldTitle;
                field.FieldSource = fieldAttr.FieldSource;

                fields.Add(field);
            }

            return(fields);
        }
コード例 #2
0
        private IEnumerable <GlassQuery> GetQuery(KeyValuePair <Type, Configuration.SitecoreClassConfig> cls)
        {
            var scProps = cls.Value.Properties.Where(x => x.Attribute is SitecoreQueryAttribute);

            List <GlassQuery> queries = new List <GlassQuery>();


            foreach (var scProp in scProps)
            {
                var propAttr = scProp.Attribute as SitecoreQueryAttribute;
                var query    = new GlassQuery();

                query.Name            = scProp.Property.Name;
                query.Type            = DashboardUtilities.GetTypeName(scProp.Property.PropertyType);
                query.InferType       = propAttr.InferType;
                query.IsLazy          = propAttr.IsLazy;
                query.IsRelative      = propAttr.IsRelative;
                query.Query           = propAttr.Query;
                query.UseQueryContext = propAttr.UseQueryContext;

                queries.Add(query);
            }

            return(queries);
        }
コード例 #3
0
        private IEnumerable <GlassClassSummary> GetDerivedTypes(Type type)
        {
            List <GlassClassSummary> classes = new List <GlassClassSummary>();

            foreach (var clsType in GlassContext.Classes)
            {
                if (type.IsAssignableFrom(clsType.Key) && clsType.Key != type)
                {
                    classes.Add(DashboardUtilities.GetTypeName(clsType.Key));
                }
            }

            return(classes);
        }
コード例 #4
0
        private IEnumerable <GlassChildren> GetChildren(KeyValuePair <Type, Configuration.SitecoreClassConfig> cls)
        {
            var scProps = cls.Value.Properties.Where(x => x.Attribute is SitecoreChildrenAttribute);

            List <GlassChildren> childrens = new List <GlassChildren>();

            foreach (var scProp in scProps)
            {
                var           propAttr = scProp.Attribute as SitecoreChildrenAttribute;
                GlassChildren child    = new GlassChildren();

                child.Name      = scProp.Property.Name;
                child.Type      = DashboardUtilities.GetTypeName(scProp.Property.PropertyType);
                child.InferType = propAttr.InferType;
                child.IsLazy    = propAttr.IsLazy;

                childrens.Add(child);
            }
            return(childrens);
        }
コード例 #5
0
        private IEnumerable <GlassClassSummary> GetInheritedMembers(Type type)
        {
            List <GlassClassSummary> classes = new List <GlassClassSummary>();

            if (GlassContext.Classes.Any(x => x.Key == type.BaseType))
            {
                classes.Add(DashboardUtilities.GetTypeName(type.BaseType));
            }

            var interfaces = type.GetInterfaces();

            if (interfaces.Any())
            {
                foreach (var superType in interfaces.OrderBy(x => x.Name))
                {
                    classes.Add(DashboardUtilities.GetTypeName(superType));
                }
            }

            return(classes);
        }
コード例 #6
0
        private IEnumerable <GlassInfo> GetInformation(KeyValuePair <Type, Configuration.SitecoreClassConfig> cls)
        {
            var scProps = cls.Value.Properties.Where(x => x.Attribute is SitecoreInfoAttribute);

            List <GlassInfo> infos = new List <GlassInfo>();


            foreach (var scProp in scProps)
            {
                var propAttr = scProp.Attribute as SitecoreInfoAttribute;

                var info = new GlassInfo();

                info.Name     = scProp.Property.Name;
                info.Type     = DashboardUtilities.GetTypeName(scProp.Property.PropertyType);
                info.InfoType = propAttr.Type.ToString();

                infos.Add(info);
            }

            return(infos);
        }
コード例 #7
0
        private IEnumerable <GlassParent> GetParents(KeyValuePair <Type, Configuration.SitecoreClassConfig> cls)
        {
            var scProps = cls.Value.Properties.Where(x => x.Attribute is SitecoreParentAttribute);

            List <GlassParent> parents = new List <GlassParent>();


            foreach (var scProp in scProps)
            {
                var propAttr = scProp.Attribute as SitecoreParentAttribute;
                var parent   = new GlassParent();

                parent.Name      = scProp.Property.Name;
                parent.Type      = DashboardUtilities.GetTypeName(scProp.Property.PropertyType);
                parent.InferType = propAttr.InferType;
                parent.IsLazy    = propAttr.IsLazy;

                parents.Add(parent);
            }

            return(parents);
        }
コード例 #8
0
        private IEnumerable <GlassItem> GetItems(KeyValuePair <Type, Configuration.SitecoreClassConfig> cls)
        {
            var scProps = cls.Value.Properties.Where(x => x.Attribute is SitecoreItemAttribute);

            List <GlassItem> items = new List <GlassItem>();


            foreach (var scProp in scProps)
            {
                var propAttr = scProp.Attribute as SitecoreItemAttribute;
                var item     = new GlassItem();
                item.Name   = scProp.Property.Name;
                item.Type   = DashboardUtilities.GetTypeName(scProp.Property.PropertyType);
                item.Id     = propAttr.Id;
                item.Path   = propAttr.Path;
                item.IsLazy = propAttr.IsLazy;

                items.Add(item);
            }

            return(items);
        }
コード例 #9
0
        private IEnumerable <GlassLinked> GetLinked(KeyValuePair <Type, Configuration.SitecoreClassConfig> cls)
        {
            var scProps = cls.Value.Properties.Where(x => x.Attribute is SitecoreLinkedAttribute);

            List <GlassLinked> links = new List <GlassLinked>();


            foreach (var scProp in scProps)
            {
                var propAttr = scProp.Attribute as SitecoreLinkedAttribute;
                var link     = new GlassLinked();

                link.Name      = scProp.Property.Name;
                link.Type      = DashboardUtilities.GetTypeName(scProp.Property.PropertyType);
                link.Option    = propAttr.Option.ToString();
                link.InferType = propAttr.InferType;
                link.IsLazy    = propAttr.IsLazy;

                links.Add(link);
            }

            return(links);
        }