Ejemplo n.º 1
0
        internal Domain(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.directSuperdomains = new List <Domain>();

            this.MetaPopulation.OnDomainCreated(this);
        }
Ejemplo n.º 2
0
        public MethodType(MetaPopulation metaPopulation, Guid id)
            : base(metaPopulation)
        {
            this.Id = id;

            metaPopulation.OnMethodTypeCreated(this);
        }
Ejemplo n.º 3
0
        internal Inheritance(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.Id = Guid.NewGuid();

            metaPopulation.OnInheritanceCreated(this);
        }
Ejemplo n.º 4
0
        static MetaPopulation()
        {
            Instance = new MetaPopulation();
            var metaBuilder = new MetaBuilder(Instance);

            metaBuilder.Build();
        }
Ejemplo n.º 5
0
        internal Inheritance(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.Id = Guid.NewGuid();

            metaPopulation.OnInheritanceCreated(this);
        }
Ejemplo n.º 6
0
        internal Interface(MetaPopulation metaPopulation, Guid id)
            : base(metaPopulation)
        {
            this.Id = id;

            metaPopulation.OnInterfaceCreated(this);
        }
Ejemplo n.º 7
0
        internal Domain(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.directSuperdomains = new List<Domain>();

            this.MetaPopulation.OnDomainCreated(this);
        }
Ejemplo n.º 8
0
        public MethodType(MetaPopulation metaPopulation, Guid id)
            : base(metaPopulation)
        {
            this.Id = id;

            metaPopulation.OnMethodTypeCreated(this);
        }
Ejemplo n.º 9
0
        internal Class(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.concreteRoleTypeByRoleType     = new Dictionary <RoleType, ConcreteRoleType>();
            this.concreteMethodTypeByMethodType = new Dictionary <MethodType, ConcreteMethodType>();

            this.classes = new[] { this };
            metaPopulation.OnClassCreated(this);
        }
Ejemplo n.º 10
0
        internal Class(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.concreteRoleTypeByRoleType = new Dictionary<RoleType, ConcreteRoleType>();
            this.concreteMethodTypeByMethodType = new Dictionary<MethodType, ConcreteMethodType>();

            this.classes = new[] { this };
            metaPopulation.OnClassCreated(this);
        }
Ejemplo n.º 11
0
        static MetaPopulation()
        {
            Instance = new MetaPopulation();
            var metaBuilder = new MetaBuilder(Instance);

            metaBuilder.BuildDomains();
            metaBuilder.BuildObjectTypes();
            metaBuilder.BuildOperandTypes();
        }
Ejemplo n.º 12
0
        protected MetaObject(MetaPopulation metaPopulation)
        {
            this.MetaPopulation = metaPopulation;

            var idAttribute = (IdAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof (IdAttribute));
            if (idAttribute != null)
            {
                this.Id = new Guid(idAttribute.Value);
            }
        }
Ejemplo n.º 13
0
        public RelationType(MetaPopulation metaPopulation, Guid id, Guid associationTypeId, Guid roleTypdId)
            : base(metaPopulation)
        {
            this.Id = id;

            this.associationType = new AssociationType(this, associationTypeId);
            this.roleType = new RoleType(this, roleTypdId);

            metaPopulation.OnRelationTypeCreated(this);
        }
Ejemplo n.º 14
0
        public RelationType(MetaPopulation metaPopulation, Guid id, Guid associationTypeId, Guid roleTypdId)
            : base(metaPopulation)
        {
            this.Id = id;

            this.AssociationType = new AssociationType(this, associationTypeId);
            this.RoleType        = new RoleType(this, roleTypdId);

            metaPopulation.OnRelationTypeCreated(this);
        }
Ejemplo n.º 15
0
        protected MetaObjectBase(MetaPopulation metaPopulation)
        {
            this.MetaPopulation = metaPopulation;

            var idAttribute = (IdAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(IdAttribute));

            if (idAttribute != null)
            {
                this.Id = new Guid(idAttribute.Value);
            }
        }
Ejemplo n.º 16
0
        public Population()
        {
            this.metaPopulation = new MetaPopulation();

            var allors = Repository.TestOnPostInit(this.metaPopulation);

            var validationlog = this.metaPopulation.Validate();

            this.Domain = new Domain(this.MetaPopulation, Guid.NewGuid()) { Name = "Domain" };
            this.Domain.AddDirectSuperdomain(allors);

            this.GetUnits();
        }
Ejemplo n.º 17
0
        static MetaPopulation()
        {
            Instance = new MetaPopulation();
            var metaBuilder = new MetaBuilder(Instance);

            metaBuilder.BuildDomains();
            metaBuilder.BuildDomainInheritances();
            metaBuilder.BuildUnits();
            metaBuilder.BuildInterfaces();
            metaBuilder.BuildClasses();
            metaBuilder.BuildInheritances();
            metaBuilder.BuildRoles();
            metaBuilder.BuildInheritedRoles();
            metaBuilder.BuildImplementedRoles();
            metaBuilder.BuildAssociations();
            metaBuilder.BuildInheritedAssociations();
            metaBuilder.BuildDefinedMethods();
            metaBuilder.BuildInheritedMethods();
            metaBuilder.ExtendInterfaces();
            metaBuilder.ExtendClasses();
        }
Ejemplo n.º 18
0
 public OperandType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 19
0
 protected PropertyType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 20
0
 internal Unit(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
     metaPopulation.OnUnitCreated(this);
 }
Ejemplo n.º 21
0
 protected PropertyType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 22
0
 internal Interface(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
     metaPopulation.OnInterfaceCreated(this);
 }
Ejemplo n.º 23
0
 protected ObjectType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 24
0
        static MetaPopulation()
        {
            Instance = new MetaPopulation();

            var assembly = Assembly.GetExecutingAssembly();
            var classes  = new List <Type>(assembly.GetTypes().Where(type => type.IsClass && !type.IsAbstract));

            // Domains
            foreach (var domainType in classes.Where(type => type.GetInterfaces().Contains(typeof(IDomain))))
            {
                var constructor = domainType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new [] { Instance.GetType() }, null);
                var domain      = (Domain)constructor.Invoke(new object[] { Instance });

                domain.Name = domainType.Name.Substring(0, domainType.Name.Length - "Domain".Length);

                var instanceProperty = domainType.GetProperty("Instance");
                instanceProperty.SetMethod.Invoke(null, new[] { domain });
            }

            // Domain Inheritance
            foreach (var domain in Instance.Domains)
            {
                var type = domain.GetType();

                // Always inherit from Object
                if (!domain.Equals(CoreDomain.Instance))
                {
                    domain.AddDirectSuperdomain(CoreDomain.Instance);
                }

                // Create Inheritance objects
                foreach (var attribute in type.GetCustomAttributes(typeof(InheritAttribute)))
                {
                    var inheritanceAttribute = (InheritAttribute)attribute;
                    var idAttribute          = (IdAttribute)Attribute.GetCustomAttribute(inheritanceAttribute.Value, typeof(IdAttribute));
                    var id          = new Guid(idAttribute.Value);
                    var superdomain = (Domain)Instance.Find(id);

                    domain.AddDirectSuperdomain(superdomain);
                }
            }

            // ObjectTypes
            foreach (var objectType in classes.Where(type => type.GetInterfaces().Contains(typeof(IUnit)) || type.GetInterfaces().Contains(typeof(IInterface)) || type.GetInterfaces().Contains(typeof(IClass))))
            {
                var constructor = objectType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null);
                var instance    = (ObjectType)constructor.Invoke(null);

                if (instance is IUnit)
                {
                    instance.SingularName = objectType.Name.Substring(0, objectType.Name.Length - "Unit".Length);
                }
                else if (instance is IClass)
                {
                    instance.SingularName = objectType.Name.Substring(0, objectType.Name.Length - "Class".Length);
                }
                else if (instance is IInterface)
                {
                    instance.SingularName = objectType.Name.Substring(0, objectType.Name.Length - "Interface".Length);
                }

                var pluralAttribute = (PluralAttribute)Attribute.GetCustomAttribute(objectType, typeof(PluralAttribute));
                if (pluralAttribute != null)
                {
                    instance.PluralName = pluralAttribute.Value;
                }
                else
                {
                    instance.PluralName = instance.SingularName + "s";
                }


                var instanceProperty = objectType.GetProperty("Instance");
                instanceProperty.SetMethod.Invoke(null, new[] { instance });
            }

            // ObjectType Inheritance
            foreach (var composite in Instance.Composites)
            {
                var type = composite.GetType();

                // Always inherit from Object
                if (!composite.Equals(ObjectInterface.Instance))
                {
                    new Inheritance(Instance)
                    {
                        Subtype   = composite,
                        Supertype = ObjectInterface.Instance
                    };
                }

                // Create Inheritance objects
                foreach (var attribute in type.GetCustomAttributes(typeof(InheritAttribute)))
                {
                    var inheritanceAttribute = (InheritAttribute)attribute;
                    var idAttribute          = (IdAttribute)Attribute.GetCustomAttribute(inheritanceAttribute.Value, typeof(IdAttribute));
                    var id        = new Guid(idAttribute.Value);
                    var supertype = (Interface)Instance.Find(id);

                    new Inheritance(Instance)
                    {
                        Subtype   = composite,
                        Supertype = supertype
                    };
                }
            }

            foreach (var composite in Instance.Composites)
            {
                var type = composite.GetType();

                // Create RelationType objects
                var relationTypeFields = type
                                         .GetFields()
                                         .Where(field => field.FieldType == typeof(RelationType));

                foreach (var relationTypeField in relationTypeFields)
                {
                    var idAttribute            = (IdAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(IdAttribute));
                    var associationIdAttribute = (AssociationIdAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(AssociationIdAttribute));
                    var roleIdAttribute        = (RoleIdAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(RoleIdAttribute));
                    var id            = new Guid(idAttribute.Value);
                    var associationId = new Guid(associationIdAttribute.Value);
                    var roleId        = new Guid(roleIdAttribute.Value);
                    var relationType  = (RelationType)Activator.CreateInstance(typeof(RelationType), new object[] { Instance, id, associationId, roleId });

                    relationType.AssociationType.ObjectType = composite;

                    var multiplicityTypeAttribute = (MultiplicityAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(MultiplicityAttribute));
                    if (multiplicityTypeAttribute != null)
                    {
                        relationType.AssignedMultiplicity = multiplicityTypeAttribute.Value;
                    }

                    var derivedAttribute = (DerivedAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(DerivedAttribute));
                    if (derivedAttribute != null)
                    {
                        relationType.IsDerived = derivedAttribute.Value;
                    }

                    var indexedAttribute = (IndexedAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(IndexedAttribute));
                    if (indexedAttribute != null)
                    {
                        relationType.IsIndexed = indexedAttribute.Value;
                    }

                    relationType.AssociationType.ObjectType = composite;

                    relationType.RoleType.AssignedSingularName = relationTypeField.Name;

                    var roleTypeAttribute   = (TypeAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(TypeAttribute));
                    var roleTypeIdAttribute = (IdAttribute)Attribute.GetCustomAttribute(roleTypeAttribute.Value, typeof(IdAttribute));
                    var roleTypeId          = new Guid(roleTypeIdAttribute.Value);
                    var roleType            = (ObjectType)Instance.Find(roleTypeId);

                    relationType.RoleType.ObjectType = roleType;

                    var scaleAttribute = (ScaleAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(ScaleAttribute));
                    if (scaleAttribute != null)
                    {
                        relationType.RoleType.Scale = scaleAttribute.Value;
                    }

                    var precisionAttribute = (PrecisionAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(PrecisionAttribute));
                    if (precisionAttribute != null)
                    {
                        relationType.RoleType.Precision = precisionAttribute.Value;
                    }

                    var sizeAttribute = (SizeAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(SizeAttribute));
                    if (sizeAttribute != null)
                    {
                        relationType.RoleType.Size = sizeAttribute.Value;
                    }

                    var pluralAttribute = (PluralAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(PluralAttribute));
                    if (pluralAttribute != null)
                    {
                        relationType.RoleType.AssignedPluralName = pluralAttribute.Value;
                    }

                    foreach (var groupAttribute in Attribute.GetCustomAttributes(relationTypeField, typeof(GroupAttribute)).Cast <GroupAttribute>())
                    {
                        relationType.AddGroup(groupAttribute.Value);
                    }

                    relationTypeField.SetValue(composite, relationType);
                }
            }

            foreach (var composite in Instance.Composites)
            {
                var type = composite.GetType();

                // Create MethodType objects
                var methodTypeFields = type
                                       .GetFields()
                                       .Where(field => field.FieldType == typeof(MethodType));

                foreach (var methodTypeField in methodTypeFields)
                {
                    var idAttribute = (IdAttribute)Attribute.GetCustomAttribute(methodTypeField, typeof(IdAttribute));
                    var id          = new Guid(idAttribute.Value);
                    var methodType  = (MethodType)Activator.CreateInstance(typeof(MethodType), new object[] { Instance, id });
                    methodType.Name       = methodTypeField.Name;
                    methodType.ObjectType = composite;
                    methodTypeField.SetValue(composite, methodType);

                    foreach (var groupAttribute in Attribute.GetCustomAttributes(methodTypeField, typeof(GroupAttribute)).Cast <GroupAttribute>())
                    {
                        methodType.AddGroup(groupAttribute.Value);
                    }
                }
            }

            Instance.Extend();
        }
Ejemplo n.º 25
0
        internal void Generate(MetaPopulation metaPopulation, DirectoryInfo outputDirectory, string group, Log log)
        {
            var validation = metaPopulation.Validate();
            if (validation.ContainsErrors)
            {
                log.Error(this, "Meta population " + metaPopulation + " has validation errors.");
                return;
            }

            try
            {
                TemplateGroup templateGroup = new TemplateGroupFile(this.fileInfo.FullName, '$', '$');

                templateGroup.ErrorManager = new ErrorManager(new LogAdapter(log));

                var configurationTemplate = templateGroup.GetInstanceOf(TemplateConfiguration);
                configurationTemplate.Add(MetaKey, metaPopulation);
                configurationTemplate.Add(GroupKey, group);

                var configurationXml = new XmlDocument();
                configurationXml.LoadXml(configurationTemplate.Render());

                var location = new Location(outputDirectory);
                foreach (XmlElement generation in configurationXml.DocumentElement.SelectNodes(GenerationKey))
                {
                    var templateName = generation.GetAttribute(TemplateKey);
                    var template = templateGroup.GetInstanceOf(templateName);
                    var output = generation.GetAttribute(OutputKey);

                    template.Add(MetaKey, metaPopulation);
                    template.Add(GroupKey, group);

                    if (generation.HasAttribute(InputKey))
                    {
                        var input = new Guid(generation.GetAttribute(InputKey));
                        var objectType = metaPopulation.Find(input) as IObjectType;
                        if (objectType != null)
                        {
                            template.Add(ObjectTypeKey, objectType);
                        }
                        else
                        {
                            var relationType = metaPopulation.Find(input) as RelationType;
                            if (relationType != null)
                            {
                                template.Add(RelationTypeKey, relationType);
                            }
                            else
                            {
                                var inheritance = metaPopulation.Find(input) as Inheritance;
                                if (inheritance != null)
                                {
                                    template.Add(InheritanceKey, inheritance);
                                }
                                else
                                {
                                    var methodType = metaPopulation.Find(input) as MethodType;
                                    if (methodType != null)
                                    {
                                        template.Add(MethodTypeKey, methodType);
                                    }
                                    else
                                    {
                                        throw new ArgumentException(input + " was not found");
                                    }
                                }
                            }
                        }
                        //TODO: Super Domains
                    }

                    var result = template.Render();
                    location.Save(output, result);
                }
            }
            catch (Exception e)
            {
                log.Error(this, "Generation error : " + e.Message + "\n" + e.StackTrace);
            }
        }
Ejemplo n.º 26
0
 protected MetaObjectBase(MetaPopulation metaPopulation)
 {
     this.MetaPopulation = metaPopulation;
 }
Ejemplo n.º 27
0
 internal Unit(MetaPopulation metaPopulation, Guid id)
     : base(metaPopulation)
 {
     this.Id = id;
     metaPopulation.OnUnitCreated(this);
 }
Ejemplo n.º 28
0
 private BaseDomain(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 29
0
 internal Unit(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
     metaPopulation.OnUnitCreated(this);
 }
Ejemplo n.º 30
0
 public OperandType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 31
0
 protected Composite(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 32
0
 public Path(MetaPopulation metaPopulation, params string[] propertyTypeIds)
     : this(propertyTypeIds.Select(x => (PropertyType)metaPopulation.Find(new Guid(x))).ToArray())
 {
 }
Ejemplo n.º 33
0
 public Path(MetaPopulation metaPopulation, params string[] propertyTypeIds)
     : this(propertyTypeIds.Select(x => (PropertyType)metaPopulation.Find(new Guid(x))).ToArray())
 {
 }
Ejemplo n.º 34
0
 protected ObjectType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 35
0
        static MetaPopulation()
        {
            Instance = new MetaPopulation();

            var assembly = Assembly.GetExecutingAssembly();
            var classes = new List<Type>(assembly.GetTypes().Where(type => type.IsClass && !type.IsAbstract));

            // Domains
            foreach (var domainType in classes.Where(type => type.GetInterfaces().Contains(typeof(IDomain))))
            {
                var constructor = domainType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new []{Instance.GetType()}, null);
                var domain = (Domain)constructor.Invoke(new object[] { Instance });

                domain.Name = domainType.Name.Substring(0, domainType.Name.Length-"Domain".Length);

                var instanceProperty = domainType.GetProperty("Instance");
                instanceProperty.SetMethod.Invoke(null, new[] { domain });
            }

            // Domain Inheritance
            foreach (var domain in Instance.Domains)
            {
                var type = domain.GetType();

                // Always inherit from Object
                if (!domain.Equals(CoreDomain.Instance))
                {
                    domain.AddDirectSuperdomain(CoreDomain.Instance);
                }

                // Create Inheritance objects
                foreach (var attribute in type.GetCustomAttributes(typeof(InheritAttribute)))
                {
                    var inheritanceAttribute = (InheritAttribute)attribute;
                    var idAttribute = (IdAttribute)Attribute.GetCustomAttribute(inheritanceAttribute.Value, typeof(IdAttribute));
                    var id = new Guid(idAttribute.Value);
                    var superdomain = (Domain)Instance.Find(id);

                    domain.AddDirectSuperdomain(superdomain);
                }
            }

            // ObjectTypes
            foreach (var objectType in classes.Where(type => type.GetInterfaces().Contains(typeof(IUnit)) || type.GetInterfaces().Contains(typeof(IInterface)) || type.GetInterfaces().Contains(typeof(IClass))))
            {
                var constructor = objectType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null);
                var instance = (ObjectType)constructor.Invoke(null);

                if (instance is IUnit)
                {
                    instance.SingularName = objectType.Name.Substring(0, objectType.Name.Length - "Unit".Length);
                }
                else if (instance is IClass)
                {
                    instance.SingularName = objectType.Name.Substring(0, objectType.Name.Length - "Class".Length);
                }
                else if (instance is IInterface)
                {
                    instance.SingularName = objectType.Name.Substring(0, objectType.Name.Length - "Interface".Length);
                }

                var pluralAttribute = (PluralAttribute)Attribute.GetCustomAttribute(objectType, typeof(PluralAttribute));
                if (pluralAttribute != null)
                {
                    instance.PluralName = pluralAttribute.Value;
                }
                else
                {
                    instance.PluralName = instance.SingularName + "s";
                }

                var instanceProperty = objectType.GetProperty("Instance");
                instanceProperty.SetMethod.Invoke(null, new[] { instance });
            }

            // ObjectType Inheritance
            foreach (var composite in Instance.Composites)
            {
                var type = composite.GetType();

                // Always inherit from Object
                if (!composite.Equals(ObjectInterface.Instance))
                {
                    new Inheritance(Instance)
                    {
                        Subtype = composite,
                        Supertype = ObjectInterface.Instance
                    };
                }

                // Create Inheritance objects
                foreach (var attribute in type.GetCustomAttributes(typeof(InheritAttribute)))
                {
                    var inheritanceAttribute = (InheritAttribute)attribute;
                    var idAttribute = (IdAttribute)Attribute.GetCustomAttribute(inheritanceAttribute.Value, typeof(IdAttribute));
                    var id = new Guid(idAttribute.Value);
                    var supertype = (Interface)Instance.Find(id);

                    new Inheritance(Instance)
                    {
                        Subtype = composite,
                        Supertype = supertype
                    };
                }
            }

            foreach (var composite in Instance.Composites)
            {
                var type = composite.GetType();

                // Create RelationType objects
                var relationTypeFields = type
                    .GetFields()
                    .Where(field => field.FieldType == typeof(RelationType));

                foreach (var relationTypeField in relationTypeFields)
                {
                    var idAttribute = (IdAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(IdAttribute));
                    var associationIdAttribute = (AssociationIdAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(AssociationIdAttribute));
                    var roleIdAttribute = (RoleIdAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(RoleIdAttribute));
                    var id = new Guid(idAttribute.Value);
                    var associationId = new Guid(associationIdAttribute.Value);
                    var roleId = new Guid(roleIdAttribute.Value);
                    var relationType = (RelationType)Activator.CreateInstance(typeof(RelationType), new object[] { Instance, id , associationId, roleId });

                    relationType.AssociationType.ObjectType = composite;

                    var multiplicityTypeAttribute = (MultiplicityAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(MultiplicityAttribute));
                    if (multiplicityTypeAttribute != null)
                    {
                        relationType.AssignedMultiplicity = multiplicityTypeAttribute.Value;
                    }

                    var derivedAttribute = (DerivedAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(DerivedAttribute));
                    if (derivedAttribute != null)
                    {
                        relationType.IsDerived = derivedAttribute.Value;
                    }

                    var indexedAttribute = (IndexedAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(IndexedAttribute));
                    if (indexedAttribute != null)
                    {
                        relationType.IsIndexed = indexedAttribute.Value;
                    }

                    relationType.AssociationType.ObjectType = composite;

                    relationType.RoleType.AssignedSingularName = relationTypeField.Name;

                    var roleTypeAttribute = (TypeAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(TypeAttribute));
                    var roleTypeIdAttribute = (IdAttribute)Attribute.GetCustomAttribute(roleTypeAttribute.Value, typeof(IdAttribute));
                    var roleTypeId = new Guid(roleTypeIdAttribute.Value);
                    var roleType = (ObjectType)Instance.Find(roleTypeId);

                    relationType.RoleType.ObjectType = roleType;

                    var scaleAttribute = (ScaleAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(ScaleAttribute));
                    if (scaleAttribute != null)
                    {
                        relationType.RoleType.Scale = scaleAttribute.Value;
                    }

                    var precisionAttribute = (PrecisionAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(PrecisionAttribute));
                    if (precisionAttribute != null)
                    {
                        relationType.RoleType.Precision = precisionAttribute.Value;
                    }

                    var sizeAttribute = (SizeAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(SizeAttribute));
                    if (sizeAttribute != null)
                    {
                        relationType.RoleType.Size = sizeAttribute.Value;
                    }

                    var pluralAttribute = (PluralAttribute)Attribute.GetCustomAttribute(relationTypeField, typeof(PluralAttribute));
                    if (pluralAttribute != null)
                    {
                        relationType.RoleType.AssignedPluralName = pluralAttribute.Value;
                    }

                    foreach (var groupAttribute in Attribute.GetCustomAttributes(relationTypeField, typeof(GroupAttribute)).Cast<GroupAttribute>())
                    {
                        relationType.AddGroup(groupAttribute.Value);
                    }

                    relationTypeField.SetValue(composite, relationType);
                }
            }

            foreach (var composite in Instance.Composites)
            {
                var type = composite.GetType();

                // Create MethodType objects
                var methodTypeFields = type
                    .GetFields()
                    .Where(field => field.FieldType == typeof(MethodType));

                foreach (var methodTypeField in methodTypeFields)
                {
                    var idAttribute = (IdAttribute)Attribute.GetCustomAttribute(methodTypeField, typeof(IdAttribute));
                    var id = new Guid(idAttribute.Value);
                    var methodType = (MethodType)Activator.CreateInstance(typeof(MethodType), new object[] { Instance, id });
                    methodType.Name = methodTypeField.Name;
                    methodType.ObjectType = composite;
                    methodTypeField.SetValue(composite, methodType);
                }
            }

            Instance.Extend();
        }
Ejemplo n.º 36
0
 protected Composite(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
Ejemplo n.º 37
0
 internal Interface(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
     metaPopulation.OnInterfaceCreated(this);
 }