Пример #1
0
        private bool IsIfcProperty(string elementName, out int index, out ExpressMetaProperty prop)
        {
            ExpressType expressType;
            var         xmlEntity = _currentNode as XmlEntity;

            if (xmlEntity != null && !_metadata.TryGetExpressType(elementName.ToUpper(), out expressType))
            {
                var t = _metadata.ExpressType(xmlEntity.Entity);

                foreach (var p in t.Properties.Where(p => p.Value.PropertyInfo.Name == elementName))
                {
                    prop  = p.Value;
                    index = p.Key;
                    return(true);
                }
            }
            prop  = null;
            index = -1;
            return(false);
        }
Пример #2
0
        private ExpressType GetExpresType(XmlReader input)
        {
            //type defined by xml attribute has always a priority over the name of the element
            var typeName = (input.GetAttribute("type", _xsi) ?? input.LocalName).ToUpper();

            if (_metadata.TryGetExpressType(typeName, out ExpressType expType))
            {
                return(expType);
            }

            //try to replace WRAPPER keyword
            typeName = input.LocalName.ToUpper();
            if (!typeName.Contains("-"))
            {
                return(null);
            }

            typeName = typeName.Replace("-WRAPPER", "");
            _metadata.TryGetExpressType(typeName, out expType);
            return(expType);
        }
Пример #3
0
        private ValidationResult CheckMeasureType(string typeName, ExpressMetaData metadata, bool reference)
        {
            // null or empty is a valid value
            if (string.IsNullOrWhiteSpace(typeName))
            {
                return(null);
            }

            typeName = typeName.ToUpperInvariant();
            var err = new ValidationResult
            {
                IssueSource = "Measure type validation",
                IssueType   = ValidationFlags.Properties,
            };

            if (!metadata.TryGetExpressType(typeName, out ExpressType eType))
            {
                err.Message = $"Type {typeName} is not an IFC type.";
                return(err);
            }

            var type = eType.Type;

            if (!reference && !typeof(IIfcValue).IsAssignableFrom(type))
            {
                err.Message = $"Type {typeName} is not applicable. This must be assignable to 'IfcValue'";
                return(err);
            }

            if (reference && !typeof(IIfcObjectReferenceSelect).IsAssignableFrom(type))
            {
                err.Message = $"Type {typeName} is not applicable. This must be assignable to 'IfcObjectReferenceSelect'";
                return(err);
            }

            return(null);
        }