private void AddPropertiesFrom(OntologyClass ontologyClass, CompileUnitOption compileUnitOption) { foreach (var ontologyProperty in ontologyClass.IsDomainOf) { this.Members.AddRange(new PropertyWithBackingField(ontologyProperty)); } }
private void AddProperties(CompileUnitOption compileUnitOption) { IEnumerable <OntologyClass> fullClassContext = null; if (this.ontologyClass.SuperClasses.Any()) { fullClassContext = this.ontologyClass.SuperClasses .Union(this.ontologyClass.SuperClasses .SelectMany(sc => sc.SubClasses)); } else { fullClassContext = new OntologyClass[] { this.ontologyClass } .Union(this.ontologyClass.SubClasses); } HashSet <string> classes = new HashSet <string>(); foreach (var contextClass in fullClassContext) { if (classes.Contains(contextClass.ToPascalCase()) == false) { this.AddPropertiesFrom(contextClass, compileUnitOption); classes.Add(contextClass.ToPascalCase()); } } }
internal CompileUnit(string name, OntologyGraph ontology, CompileUnitOption compileUnitOption, string modelOutputLocation = null) { this.ontology = ontology; this.name = name; this.AddReferences(); this.AddNamespace(compileUnitOption); }
private void AddClasses(CompileUnitOption compileUnitOption) { foreach (var ontologyClass in this.ontology.AllClasses) { var ontologyClassTypeDeclaration = new ClassDeclaration(ontologyClass, compileUnitOption); this.Types.Add(ontologyClassTypeDeclaration); } }
internal Namespace(string name, OntologyGraph ontology, CompileUnitOption compileUnitOption) : base(name) { this.ontology = ontology; if (compileUnitOption == CompileUnitOption.InterfaceOnly) { this.AddInterfaces(); } else if (compileUnitOption == CompileUnitOption.ModelImplementation) { this.AddClasses(compileUnitOption); } }
internal ClassDeclaration(OntologyClass ontologyClass, CompileUnitOption compileUnitOption) { this.ontologyClass = ontologyClass; this.BaseTypes.Add(typeof(BaseResource)); this.Name = this.ontologyClass.ToPascalCase(); this.TypeAttributes = TypeAttributes.Public | TypeAttributes.Class; this.CustomAttributes.Add(new ResourceAttributeDeclaration <ClassAttribute>(this.ontologyClass)); if ((ontologyClass.Label != null) && (ontologyClass.Label.Any())) { foreach (VDS.RDF.ILiteralNode labelNode in ontologyClass.Label) { this.Comments.Add(new CodeCommentStatement(labelNode.Value)); } } this.AddProperties(compileUnitOption); }
private void AddNamespace(CompileUnitOption compileUnitOption) { var ontologyNamespace = new Namespace(this.name, this.ontology, compileUnitOption); this.Namespaces.Add(ontologyNamespace); }