internal Domain(MetaPopulation metaPopulation) : base(metaPopulation) { this.directSuperdomains = new List <Domain>(); this.MetaPopulation.OnDomainCreated(this); }
public MethodType(MetaPopulation metaPopulation, Guid id) : base(metaPopulation) { this.Id = id; metaPopulation.OnMethodTypeCreated(this); }
internal Inheritance(MetaPopulation metaPopulation) : base(metaPopulation) { this.Id = Guid.NewGuid(); metaPopulation.OnInheritanceCreated(this); }
static MetaPopulation() { Instance = new MetaPopulation(); var metaBuilder = new MetaBuilder(Instance); metaBuilder.Build(); }
internal Interface(MetaPopulation metaPopulation, Guid id) : base(metaPopulation) { this.Id = id; metaPopulation.OnInterfaceCreated(this); }
internal Domain(MetaPopulation metaPopulation) : base(metaPopulation) { this.directSuperdomains = new List<Domain>(); this.MetaPopulation.OnDomainCreated(this); }
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); }
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); }
static MetaPopulation() { Instance = new MetaPopulation(); var metaBuilder = new MetaBuilder(Instance); metaBuilder.BuildDomains(); metaBuilder.BuildObjectTypes(); metaBuilder.BuildOperandTypes(); }
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); } }
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); }
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); }
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); } }
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(); }
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(); }
public OperandType(MetaPopulation metaPopulation) : base(metaPopulation) { }
protected PropertyType(MetaPopulation metaPopulation) : base(metaPopulation) { }
internal Unit(MetaPopulation metaPopulation) : base(metaPopulation) { metaPopulation.OnUnitCreated(this); }
internal Interface(MetaPopulation metaPopulation) : base(metaPopulation) { metaPopulation.OnInterfaceCreated(this); }
protected ObjectType(MetaPopulation metaPopulation) : base(metaPopulation) { }
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(); }
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); } }
protected MetaObjectBase(MetaPopulation metaPopulation) { this.MetaPopulation = metaPopulation; }
internal Unit(MetaPopulation metaPopulation, Guid id) : base(metaPopulation) { this.Id = id; metaPopulation.OnUnitCreated(this); }
private BaseDomain(MetaPopulation metaPopulation) : base(metaPopulation) { }
protected Composite(MetaPopulation metaPopulation) : base(metaPopulation) { }
public Path(MetaPopulation metaPopulation, params string[] propertyTypeIds) : this(propertyTypeIds.Select(x => (PropertyType)metaPopulation.Find(new Guid(x))).ToArray()) { }
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(); }