private bool IsIfcProperty(string elementName, out int index, out IfcMetaProperty prop) { IfcType ifcType; XmlEntity xmlEntity = _currentNode as XmlEntity; if (xmlEntity != null && !IfcMetaData.TryGetIfcType(elementName.ToUpper(), out ifcType)) { IfcType t = IfcMetaData.IfcType(xmlEntity.Entity); foreach (KeyValuePair <int, IfcMetaProperty> p in t.IfcProperties) { int propIndex = p.Key; if (p.Value.PropertyInfo.Name == elementName) //this is the property to set { prop = p.Value; index = p.Key; return(true); } } } prop = null; index = -1; return(false); }
private static IEnumerable<int> ReportProp(TextHighliter sb, string IndentationHeader, IPersistIfcEntity entity, IfcMetaProperty prop, bool Verbose) { List<int> RetIds = new List<int>(); string propName = prop.PropertyInfo.Name; Type propType = prop.PropertyInfo.PropertyType; string ShortTypeName = CleanPropertyName(propType.FullName); object propVal = prop.PropertyInfo.GetValue(entity, null); if (propVal == null) propVal = "<null>"; if (prop.IfcAttribute.IsEnumerable) { IEnumerable<object> propCollection = propVal as IEnumerable<object>; propVal = propVal.ToString() + " [not an enumerable]"; if (propCollection != null) { propVal = "<empty>"; int iCntProp = 0; foreach (var item in propCollection) { iCntProp++; if (iCntProp == 1) propVal = ReportPropValue(item, ref RetIds); else { if (iCntProp == 2) { propVal = "\r\n" + IndentationHeader + " " + propVal; } propVal += "\r\n" + IndentationHeader + " " + ReportPropValue(item, ref RetIds); } } } } else propVal = ReportPropValue(propVal, ref RetIds); if (Verbose) sb.AppendFormat(IndentationHeader + "- {0} ({1}): {2}", propName, // 0 ShortTypeName, // 1 propVal // 2 ); else { if ((string)propVal != "<null>" && (string)propVal != "<empty>") { sb.AppendFormat(IndentationHeader + "- {0}: {1}", propName, // 0 propVal // 1 ); } } return RetIds; }
private bool IsCollection(IfcMetaProperty prop) { return(typeof(ExpressEnumerable).IsAssignableFrom(prop.PropertyInfo.PropertyType)); }
private void ReportProp(IPersistIfcEntity entity, IfcMetaProperty prop, bool verbose) { var propVal = prop.PropertyInfo.GetValue(entity, null); if (propVal == null) { if (!verbose) return; propVal = "<null>"; } if (prop.IfcAttribute.IsEnumerable) { var propCollection = propVal as IEnumerable<object>; if (propCollection != null) { var propVals = propCollection.ToArray(); switch (propVals.Length) { case 0: if (!verbose) return; _objectProperties.Add(new PropertyItem { Name = prop.PropertyInfo.Name, Value = "<empty>", PropertySetName = "General" }); break; case 1: var tmpSingle = GetPropItem(propVals[0]); tmpSingle.Name = prop.PropertyInfo.Name + " (∞)"; tmpSingle.PropertySetName = "General"; _objectProperties.Add(tmpSingle); break; default: foreach (var item in propVals) { var tmpLoop = GetPropItem(item); tmpLoop.Name = item.GetType().Name; tmpLoop.PropertySetName = prop.PropertyInfo.Name; _objectProperties.Add(tmpLoop); } break; } } else { if (!verbose) return; _objectProperties.Add(new PropertyItem { Name = prop.PropertyInfo.Name, Value = "<not an enumerable>" }); } } else { var tmp = GetPropItem(propVal); tmp.Name = prop.PropertyInfo.Name; tmp.PropertySetName = "General"; _objectProperties.Add(tmp); } }
private bool IsCollection(IfcMetaProperty prop) { return typeof(ExpressEnumerable).IsAssignableFrom(prop.PropertyInfo.PropertyType); }
private bool IsIfcProperty(string elementName, out int index, out IfcMetaProperty prop) { IfcType ifcType; XmlEntity xmlEntity = _currentNode as XmlEntity; if (xmlEntity != null && !IfcMetaData.TryGetIfcType(elementName.ToUpper(), out ifcType)) { IfcType t = IfcMetaData.IfcType(xmlEntity.Entity); foreach (KeyValuePair<int, IfcMetaProperty> p in t.IfcProperties) { int propIndex = p.Key; if (p.Value.PropertyInfo.Name == elementName) //this is the property to set { prop = p.Value; index = p.Key; return true; } } } prop = null; index = -1; return false; }