public InheritedAttributeGroup(AttributeGroup attributeGroup, EntitySchema schema)
            : base(attributeGroup.Alias, attributeGroup.Name, attributeGroup.Ordinal)
        {
            Id               = attributeGroup.Id;
            UtcCreated       = attributeGroup.UtcCreated;
            UtcModified      = attributeGroup.UtcModified;
            UtcStatusChanged = attributeGroup.UtcStatusChanged;

            Schema = schema;
        }
Esempio n. 2
0
        public CompositeEntitySchema(EntitySchema schema, IEnumerable <EntitySchema> ancestorSchemas, bool copyRelationProxiesFromSchema = false)
            : base(schema.Alias, schema.Name)
        {
            //TODO: Need to move this into a mapper, but not currently one available at the right level
            Id         = schema.Id;
            SchemaType = SchemaType;
            AttributeGroups.AddRange(schema.AttributeGroups);
            AttributeDefinitions.AddRange(schema.AttributeDefinitions);
            UtcCreated       = schema.UtcCreated;
            UtcModified      = schema.UtcModified;
            UtcStatusChanged = schema.UtcStatusChanged;

            var inheritedDefsDict = new Dictionary <string, InheritedAttributeDefinition>();
            var inheritedDefs     = ancestorSchemas
                                    .SelectMany(entitySchema => entitySchema.AttributeDefinitions.Select(definition => new InheritedAttributeDefinition(definition, entitySchema))).ToArray();

            foreach (var def in inheritedDefs)
            {
                if (!inheritedDefsDict.ContainsKey(def.Alias))
                {
                    inheritedDefsDict.Add(def.Alias, def);
                }
            }

            InheritedAttributeDefinitions = new EntityCollection <InheritedAttributeDefinition>(inheritedDefsDict.Values);

            // Need to only show the inherited groups that are exposed by the filtered inherited attribute definitions, but also include empty
            // groups so that they have a chance to have some definitions added
            var allLinkedGroups = ancestorSchemas.SelectMany(x => x.AttributeDefinitions.Select(y => new InheritedAttributeGroup(y.AttributeGroup, x)));
            var allKnownGroups  = ancestorSchemas.SelectMany(x => x.AttributeGroups.Select(y => new InheritedAttributeGroup(y, x)));
            var unlinkedGroups  = allKnownGroups.Except(allLinkedGroups);

            var inheritedGroups =
                InheritedAttributeDefinitions.Select(x => new InheritedAttributeGroup(x.AttributeGroup, x.Schema)).Union
                    (unlinkedGroups);

            InheritedAttributeGroups = new EntityCollection <InheritedAttributeGroup>(inheritedGroups);

            RelationProxies.LazyLoadDelegate = schema.RelationProxies.LazyLoadDelegate;
            XmlConfiguration = schema.XmlConfiguration;

            if (copyRelationProxiesFromSchema)
            {
                foreach (var proxies in schema.RelationProxies.GetManualParentProxies())
                {
                    RelationProxies.EnlistParent(proxies.Item.Source, proxies.Item.Type, proxies.Item.Ordinal, proxies.Item.MetaData.ToArray());
                }
                foreach (var proxies in schema.RelationProxies.GetManualChildProxies())
                {
                    RelationProxies.EnlistParent(proxies.Item.Source, proxies.Item.Type, proxies.Item.Ordinal, proxies.Item.MetaData.ToArray());
                }
            }
        }
Esempio n. 3
0
        public InheritedAttributeDefinition(AttributeDefinition attributeDefinition, EntitySchema schema)
            : base(attributeDefinition.Alias, attributeDefinition.Name)
        {
            Id            = attributeDefinition.Id;
            Description   = attributeDefinition.Description;
            AttributeType = attributeDefinition.AttributeType;
            Ordinal       = attributeDefinition.Ordinal;
            RenderTypeProviderConfigOverride = attributeDefinition.RenderTypeProviderConfigOverride;
            AttributeGroup   = attributeDefinition.AttributeGroup != null ? new InheritedAttributeGroup(attributeDefinition.AttributeGroup, schema) : null;
            UtcCreated       = attributeDefinition.UtcCreated;
            UtcModified      = attributeDefinition.UtcModified;
            UtcStatusChanged = attributeDefinition.UtcStatusChanged;

            Schema = schema;
        }