예제 #1
0
 private void AddPropertiesFrom(OntologyClass ontologyClass, CompileUnitOption compileUnitOption)
 {
     foreach (var ontologyProperty in ontologyClass.IsDomainOf)
     {
         this.Members.AddRange(new PropertyWithBackingField(ontologyProperty));
     }
 }
예제 #2
0
        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());
                }
            }
        }
예제 #3
0
 internal CompileUnit(string name, OntologyGraph ontology,
                      CompileUnitOption compileUnitOption, string modelOutputLocation = null)
 {
     this.ontology = ontology;
     this.name     = name;
     this.AddReferences();
     this.AddNamespace(compileUnitOption);
 }
예제 #4
0
 private void AddClasses(CompileUnitOption compileUnitOption)
 {
     foreach (var ontologyClass in this.ontology.AllClasses)
     {
         var ontologyClassTypeDeclaration = new ClassDeclaration(ontologyClass, compileUnitOption);
         this.Types.Add(ontologyClassTypeDeclaration);
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
        private void AddNamespace(CompileUnitOption compileUnitOption)
        {
            var ontologyNamespace = new Namespace(this.name, this.ontology, compileUnitOption);

            this.Namespaces.Add(ontologyNamespace);
        }