protected string GetFullNamespace(BaseType type, string mainNamespace, DomainStructure structure)
        {
            while (true)
            {
                if (structure == null)
                {
                    return(mainNamespace);
                }

                if (type is SimpleType)
                {
                    return("System");
                }

                if (type is NamedType namedType)
                {
                    var domain = structure.GetDomainForType(namedType.Name);
                    return(domain != null ?
                           $"{mainNamespace}.{domain.Name}"
                        :
                           mainNamespace);
                }
                if (type is AggregationType aggr)
                {
                    type = aggr.ElementType;
                    continue;
                }
                throw new Exception("Unexpected type");
            }
        }
Exemplo n.º 2
0
        private static void EnhanceNullStyleInIfc(SchemaModel model, DomainStructure structure)
        {
            var nullStyle = model.Get <EnumerationType>(n => n.Name == "IfcNullStyle").FirstOrDefault();

            if (nullStyle == null)
            {
                return;
            }
            nullStyle.Name            = "IfcNullStyleEnum";
            nullStyle.PersistanceName = "IfcNullStyleEnum";

            var defType = model.New <DefinedType>(nullStyle.ParentSchema, d =>
            {
                d.Name            = "IfcNullStyle";
                d.PersistanceName = "IfcNullStyle";
                d.Domain          = nullStyle;
            });

            var selects = model.Get <SelectType>(s => s.Selections.Contains(nullStyle));

            foreach (var @select in selects)
            {
                select.Selections.Remove(nullStyle);
                select.Selections.Add(defType);
            }

            //adjust namespace
            var domain = structure.GetDomainForType("IfcNullStyle");

            domain.Types.Add("IfcNullStyleEnum");
        }
Exemplo n.º 3
0
        private static void MoveEnumsToInterfaces(DomainStructure domains, SchemaModel model, string dir, string prj)
        {
            const string iName   = "Interfaces";
            var          enums   = model.Get <EnumerationType>();
            var          iDomain = domains.Domains.FirstOrDefault(d => d.Name == iName);

            if (iDomain == null)
            {
                iDomain = new Domain {
                    Name = iName, Types = new List <string>()
                };
                domains.Domains.Add(iDomain);
            }
            foreach (var enumeration in enums)
            {
                var enumName = enumeration.PersistanceName;
                var domain   = domains.GetDomainForType(enumName);
                if (domain != null)
                {
                    //remove from where it is in the documentation
                    domain.Types.Remove(enumName);

                    //remove old files if generated before
                    var path = Path.Combine(dir, prj, domain.Name, enumName + ".cs");
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                }
                //add to interfaces namespace
                iDomain.Types.Add(enumName);
            }
        }
Exemplo n.º 4
0
        public IEnumerable <EntityDomainComparisonResult> Compare(EntityDefinition oldObject, EntityDefinition newObject)
        {
            var results = new List <EntityDomainComparisonResult>();

            if (_oldDomains == null)
            {
                _oldDomains = GetDomain(oldObject.SchemaModel.FirstSchema);
            }
            if (_newDomains == null)
            {
                _newDomains = GetDomain(newObject.SchemaModel.FirstSchema);
            }
            if (_oldDomains == null || _newDomains == null)
            {
                return(results);
            }

            var oldDomain = _oldDomains.GetDomainForType(oldObject.Name);
            var newDomain = _newDomains.GetDomainForType(newObject.Name);

            if (oldDomain.Name.ToLower() == newDomain.Name.ToLower())
            {
                return(results);
            }

            var result = new EntityDomainComparisonResult(oldObject, newObject)
            {
                OldDomain = oldDomain.Name,
                NewDomain = newDomain.Name
            };

            results.Add(result);
            _results.Add(result);

            return(results);
        }