Пример #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);
        }