예제 #1
0
        internal Domain(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.directSuperdomains = new List <Domain>();

            this.MetaPopulation.OnDomainCreated(this);
        }
예제 #2
0
        public MethodType(MetaPopulation metaPopulation, Guid id)
            : base(metaPopulation)
        {
            this.Id = id;

            metaPopulation.OnMethodTypeCreated(this);
        }
예제 #3
0
        internal Inheritance(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.Id = Guid.NewGuid();

            metaPopulation.OnInheritanceCreated(this);
        }
예제 #4
0
        static MetaPopulation()
        {
            Instance = new MetaPopulation();
            var metaBuilder = new MetaBuilder(Instance);

            metaBuilder.Build();
        }
예제 #5
0
        internal Inheritance(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.Id = Guid.NewGuid();

            metaPopulation.OnInheritanceCreated(this);
        }
예제 #6
0
파일: Interface.cs 프로젝트: lulzzz/allors2
        internal Interface(MetaPopulation metaPopulation, Guid id)
            : base(metaPopulation)
        {
            this.Id = id;

            metaPopulation.OnInterfaceCreated(this);
        }
예제 #7
0
파일: Domain.cs 프로젝트: whesius/allors
        internal Domain(MetaPopulation metaPopulation)
            : base(metaPopulation)
        {
            this.directSuperdomains = new List<Domain>();

            this.MetaPopulation.OnDomainCreated(this);
        }
예제 #8
0
        public MethodType(MetaPopulation metaPopulation, Guid id)
            : base(metaPopulation)
        {
            this.Id = id;

            metaPopulation.OnMethodTypeCreated(this);
        }
예제 #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);
        }
예제 #10
0
파일: Class.cs 프로젝트: whesius/allors
        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);
        }
예제 #11
0
        static MetaPopulation()
        {
            Instance = new MetaPopulation();
            var metaBuilder = new MetaBuilder(Instance);

            metaBuilder.BuildDomains();
            metaBuilder.BuildObjectTypes();
            metaBuilder.BuildOperandTypes();
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
            }
        }
예제 #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();
        }
예제 #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();
        }
예제 #18
0
 public OperandType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #19
0
 protected PropertyType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #20
0
 internal Unit(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
     metaPopulation.OnUnitCreated(this);
 }
예제 #21
0
 protected PropertyType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #22
0
 internal Interface(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
     metaPopulation.OnInterfaceCreated(this);
 }
예제 #23
0
 protected ObjectType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #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();
        }
예제 #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);
            }
        }
예제 #26
0
 protected MetaObjectBase(MetaPopulation metaPopulation)
 {
     this.MetaPopulation = metaPopulation;
 }
예제 #27
0
 internal Unit(MetaPopulation metaPopulation, Guid id)
     : base(metaPopulation)
 {
     this.Id = id;
     metaPopulation.OnUnitCreated(this);
 }
예제 #28
0
파일: Base.cs 프로젝트: whesius/allors
 private BaseDomain(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #29
0
파일: Unit.cs 프로젝트: whesius/allors
 internal Unit(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
     metaPopulation.OnUnitCreated(this);
 }
예제 #30
0
 public OperandType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #31
0
 protected Composite(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #32
0
파일: Path.cs 프로젝트: lulzzz/allors2
 public Path(MetaPopulation metaPopulation, params string[] propertyTypeIds)
     : this(propertyTypeIds.Select(x => (PropertyType)metaPopulation.Find(new Guid(x))).ToArray())
 {
 }
예제 #33
0
파일: Path.cs 프로젝트: whesius/allors
 public Path(MetaPopulation metaPopulation, params string[] propertyTypeIds)
     : this(propertyTypeIds.Select(x => (PropertyType)metaPopulation.Find(new Guid(x))).ToArray())
 {
 }
예제 #34
0
 protected ObjectType(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #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();
        }
예제 #36
0
파일: Composite.cs 프로젝트: whesius/allors
 protected Composite(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
 }
예제 #37
0
파일: Interface.cs 프로젝트: whesius/allors
 internal Interface(MetaPopulation metaPopulation)
     : base(metaPopulation)
 {
     metaPopulation.OnInterfaceCreated(this);
 }