コード例 #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
ファイル: CompileUnit.cs プロジェクト: ukparliament/Mapping
 internal CompileUnit(string name, OntologyGraph ontology,
                      CompileUnitOption compileUnitOption, string modelOutputLocation = null)
 {
     this.ontology = ontology;
     this.name     = name;
     this.AddReferences();
     this.AddNamespace(compileUnitOption);
 }
コード例 #4
0
ファイル: Namespace.cs プロジェクト: ukparliament/Mapping
 private void AddClasses(CompileUnitOption compileUnitOption)
 {
     foreach (var ontologyClass in this.ontology.AllClasses)
     {
         var ontologyClassTypeDeclaration = new ClassDeclaration(ontologyClass, compileUnitOption);
         this.Types.Add(ontologyClassTypeDeclaration);
     }
 }
コード例 #5
0
ファイル: Namespace.cs プロジェクト: ukparliament/Mapping
        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
ファイル: CompileUnit.cs プロジェクト: ukparliament/Mapping
        private void AddNamespace(CompileUnitOption compileUnitOption)
        {
            var ontologyNamespace = new Namespace(this.name, this.ontology, compileUnitOption);

            this.Namespaces.Add(ontologyNamespace);
        }