/// <summary> /// Constructs a value path with all parameters /// </summary> /// <param name="type"></param> /// <param name="property"></param> /// <param name="identifier"></param> /// <param name="inner"></param> public CvtValuePath(DocDefinition type, DocAttribute property, string identifier, CvtValuePath inner) { this.m_type = type; this.m_property = property; this.m_identifier = identifier; this.m_inner = inner; }
private void buttonProperty_Click(object sender, EventArgs e) { using (FormSelectProperty form = new FormSelectProperty(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string valueprop = "NominalValue"; switch (form.SelectedProperty.PropertyType) { case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: valueprop = "SetPointValue"; break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: valueprop = "EnumerationValues"; break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: valueprop = "ListValues"; break; // other property types are not supported } string value = @"\" + this.m_base.Name + @".IsDefinedBy['" + form.SelectedPropertySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcPropertySet.HasProperties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName() + @"." + valueprop + @"\" + form.SelectedProperty.PrimaryDataType; CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
public static CvtValuePath FromTemplateDefinition(DocTemplateDefinition dtd, DocProject docProject) { if (dtd.Rules.Count > 0 && dtd.Rules[0] is DocModelRuleAttribute) { DocModelRuleAttribute docRuleAtt = (DocModelRuleAttribute)dtd.Rules[0]; DocEntity docEnt = docProject.GetDefinition(dtd.Type) as DocEntity; if (docEnt != null) { CvtValuePath pathInner = null; if (docRuleAtt.Rules.Count > 0 && docRuleAtt.Rules[0] is DocModelRuleEntity) { pathInner = FromModelRule((DocModelRuleEntity)docRuleAtt.Rules[0], docProject); } DocAttribute docAtt = docEnt.ResolveAttribute(docRuleAtt.Name, docProject); string identifier = null; if (docRuleAtt.Name.Equals("IsDefinedBy")) { // hack for compat docRuleAtt.ToString(); // look for identifier if (docRuleAtt.Rules.Count > 0) { try { DocModelRuleConstraint docRuleIndexCon = (DocModelRuleConstraint)docRuleAtt.Rules[0].Rules[0].Rules[0].Rules[1].Rules[0].Rules[0]; if (docRuleIndexCon != null) { if (docRuleIndexCon.Expression is DocOpStatement) { DocOpStatement docOpStatement = (DocOpStatement)docRuleIndexCon.Expression; if (docOpStatement.Value != null) { identifier = docOpStatement.Value.ToString(); if (identifier.StartsWith("'") && identifier.EndsWith("'")) { identifier = identifier.Substring(1, identifier.Length - 2); } } } } } catch { } } } CvtValuePath pathRoot = new CvtValuePath(docEnt, docAtt, identifier, pathInner); return(pathRoot); } } return(null); }
private void buttonQuantity_Click(object sender, EventArgs e) { using (FormSelectQuantity form = new FormSelectQuantity(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
public FormReference(DocProject docProject, DocDefinition docBase, Dictionary <string, DocObject> map, string value) : this() { this.m_project = docProject; this.m_base = docBase; this.m_map = map; // parse value CvtValuePath valuepath = CvtValuePath.Parse(value, map); LoadValuePath(valuepath); }
private static CvtValuePath FromModelRule(DocModelRuleEntity docRuleEntity, DocProject docProject) { DocDefinition docDef = docProject.GetDefinition(docRuleEntity.Name); DocAttribute docAtt = null; string identifier = null; CvtValuePath pathInner = null; if (docDef is DocEntity && docRuleEntity.Rules.Count > 0 && docRuleEntity.Rules[0] is DocModelRuleAttribute) { DocModelRuleAttribute docRuleAtt = (DocModelRuleAttribute)docRuleEntity.Rules[0]; DocEntity docEnt = (DocEntity)docDef; docAtt = docEnt.ResolveAttribute(docRuleAtt.Name, docProject); if (docRuleAtt.Rules.Count > 0 && docRuleAtt.Rules[0] is DocModelRuleEntity) { DocModelRuleEntity docRuleInner = (DocModelRuleEntity)docRuleAtt.Rules[0]; pathInner = FromModelRule(docRuleInner, docProject); // look for identifier if (docRuleInner.Rules.Count > 1 && docRuleInner.Rules[1] is DocModelRuleAttribute) { DocModelRuleAttribute docRuleIndexAtt = (DocModelRuleAttribute)docRuleInner.Rules[1]; if (docRuleIndexAtt.Rules.Count > 0) { DocModelRuleEntity docRuleIndexEnt = (DocModelRuleEntity)docRuleIndexAtt.Rules[0]; if (docRuleIndexEnt.Rules.Count > 0 && docRuleIndexEnt.Rules[0] is DocModelRuleConstraint) { DocModelRuleConstraint docRuleIndexCon = (DocModelRuleConstraint)docRuleIndexEnt.Rules[0]; if (docRuleIndexCon.Expression is DocOpStatement) { DocOpStatement docOpStatement = (DocOpStatement)docRuleIndexCon.Expression; if (docOpStatement.Value != null) { identifier = docOpStatement.Value.ToString(); if (identifier.StartsWith("'") && identifier.EndsWith("'")) { identifier = identifier.Substring(1, identifier.Length - 2); } } } } } } } } CvtValuePath pathOuter = new CvtValuePath(docDef, docAtt, identifier, pathInner); return(pathOuter); }
private void buttonProperty_Click(object sender, EventArgs e) { using (FormSelectProperty form = new FormSelectProperty(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string valueprop = "NominalValue"; string datatype = form.SelectedProperty.PrimaryDataType; switch (form.SelectedProperty.PropertyType) { case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: valueprop = "SetPointValue"; break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: valueprop = "EnumerationValues"; break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: valueprop = "ListValues"; break; case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE: valueprop = "PropertyReference"; datatype = "IfcIrregularTimeSeries.Values[]\\" + form.SelectedProperty.SecondaryDataType; break; // other property types are not supported } string portprefix = String.Empty; if (form.SelectedPort != null) { portprefix = @".IsNestedBy[]\IfcRelNests.RelatedObjects['" + form.SelectedPort + @"']\IfcDistributionPort"; } string value = @"\" + this.m_base.Name + portprefix + @".IsDefinedBy['" + form.SelectedPropertySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcPropertySet.HasProperties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName() + @"." + valueprop + @"\" + datatype; CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
private void buttonQuantity_Click(object sender, EventArgs e) { using (FormSelectQuantity form = new FormSelectQuantity(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string suffix = null; switch (form.SelectedQuantity.QuantityType) { case DocQuantityTemplateTypeEnum.Q_AREA: suffix = @"IfcQuantityArea.AreaValue\IfcAreaMeasure"; break; case DocQuantityTemplateTypeEnum.Q_COUNT: suffix = @"IfcQuantityCount.CountValue\IfcInteger"; break; case DocQuantityTemplateTypeEnum.Q_LENGTH: suffix = @"IfcQuantityLength.LengthValue\IfcLengthMeasure"; break; case DocQuantityTemplateTypeEnum.Q_TIME: suffix = @"IfcQuantityTime.TimeValue\IfcTimeMeasure"; break; case DocQuantityTemplateTypeEnum.Q_VOLUME: suffix = @"IfcQuantityVolume.VolumeValue\IfcVolumeMeasure"; break; case DocQuantityTemplateTypeEnum.Q_WEIGHT: suffix = @"IfcQuantityWeight.WeightValue\IfcWeightMeasure"; break; } string value = @"\" + this.m_base.Name + @".IsDefinedBy['" + form.SelectedQuantitySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcElementQuantity.Quantities['" + form.SelectedQuantity + @"']\" + suffix; CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
private void toolStripButtonQuantity_Click(object sender, EventArgs e) { DocEntity docBaseEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; if (this.m_conceptroot != null && this.m_conceptroot.ApplicableEntity != null) { docBaseEntity = this.m_conceptroot.ApplicableEntity; } using (FormSelectQuantity form = new FormSelectQuantity(docBaseEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); Dictionary <string, DocObject> mapEntity = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { mapEntity.Add(docEntity.Name, docEntity); } foreach (DocType docType in docSchema.Types) { mapEntity.Add(docType.Name, docType); } } } CvtValuePath valuepath = CvtValuePath.Parse(value, mapEntity); this.ChangeTemplate(valuepath.ToTemplateDefinition()); this.LoadTemplateGraph(); this.ContentChanged(this, EventArgs.Empty); } } }
private void LoadValuePath(CvtValuePath valuepath) { this.textBoxReference.Text = String.Empty; this.listViewReference.Items.Clear(); if (valuepath != null) { this.textBoxReference.Text = valuepath.ToString(); } else { this.textBoxReference.Text = String.Empty; } while (valuepath != null) { ListViewItem lvi = new ListViewItem(); lvi.Tag = valuepath; if (valuepath.Type != null) { lvi.Text = valuepath.Type.Name; } if (valuepath.Property != null) { lvi.SubItems.Add(valuepath.Property.Name); if (valuepath.Identifier != null) { lvi.SubItems.Add(valuepath.Identifier); } } this.listViewReference.Items.Add(lvi); valuepath = valuepath.InnerPath; } }
public string FormatData(DocProject docProject, DocPublication docPublication, DocExchangeDefinition docExchange, Dictionary <string, DocObject> map, Dictionary <long, SEntity> instances, SEntity root, bool markup) { //Guid guidMapping = Guid.Parse("");//... StringBuilder sb = new StringBuilder(); foreach (DocModelView docView in docPublication.Views) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { // look for specific concept root dealing with mappings foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition != null && docConcept.Definition.Name.Equals("External Data Constraints") && docConcept.Items.Count > 0)//... { bool included = true; if (docExchange != null) { included = false; // if exhcnage specified, check for inclusion foreach (DocExchangeItem docExchangeItem in docConcept.Exchanges) { if (docExchangeItem.Exchange == docExchange && docExchangeItem.Requirement == DocExchangeRequirementEnum.Mandatory) { included = true; break; } } } // check if there are any instances to populate table if (included) { included = false; foreach (SEntity e in instances.Values) { string eachname = e.GetType().Name; if (docRoot.ApplicableEntity.IsInstanceOfType(e)) { included = true; break; } } } if (included) { string table = docConcept.Items[0].GetParameterValue("Table"); string query = docConcept.Items[0].GetParameterValue("Reference"); sb.AppendLine("<h4>" + docConcept.Name + "</h4>"); sb.AppendLine("<table class=\"gridtable\">"); List <string> colstyles = new List <string>(); List <string> colformat = new List <string>(); List <CvtValuePath> colmaps = new List <CvtValuePath>(); // generate header row sb.AppendLine("<tr>"); foreach (DocTemplateItem docItem in docConcept.Items) { string name = docItem.GetParameterValue("Name"); string disp = "#" + docItem.GetColor().ToArgb().ToString("X8"); //docItem.GetParameterValue("Color");docItem.GetParameterValue("Color"); string expr = docItem.GetParameterValue("Reference"); string form = docItem.GetParameterValue("Format"); string style = ""; if (!String.IsNullOrEmpty(disp)) { style = " style=\"background-color:" + disp + ";\""; } colstyles.Add(style); string format = ""; if (!String.IsNullOrEmpty(form)) { format = form; } colformat.Add(format); string desc = ""; CvtValuePath valpath = CvtValuePath.Parse(expr, map); //todo: move out of loop colmaps.Add(valpath); if (valpath != null) { desc = /*valpath.GetDescription(map) + " " + */ valpath.ToString().Replace("\\", " "); } sb.Append("<th><a href=\"../../schema/views/" + DocumentationISO.MakeLinkName(docView) + "/" + DocumentationISO.MakeLinkName(docExchange) + ".htm#" + DocumentationISO.MakeLinkName(docConcept) + "\" title=\"" + desc + "\">"); sb.Append(name); sb.Append("</a></th>"); } ; sb.AppendLine("</tr>"); // generate data rows foreach (SEntity e in instances.Values) { string eachname = e.GetType().Name; if (docRoot.ApplicableEntity.IsInstanceOfType(e)) { bool includerow = true; StringBuilder sbRow = new StringBuilder(); sbRow.Append("<tr>"); int iCol = 0; foreach (DocTemplateItem docItem in docConcept.Items) { sbRow.Append("<td" + colstyles[iCol]); CvtValuePath valpath = colmaps[iCol]; string format = colformat[iCol]; iCol++; if (valpath != null) { string nn = docItem.GetParameterValue("Name"); object value = valpath.GetValue(e, null); if (value == e) { value = e.GetType().Name; } else if (value is SEntity) { // use name FieldInfo fieldValue = value.GetType().GetField("Name"); if (fieldValue != null) { value = fieldValue.GetValue(value); } } else if (value is System.Collections.IList) { System.Collections.IList list = (System.Collections.IList)value; StringBuilder sbList = new StringBuilder(); foreach (object elem in list) { FieldInfo fieldName = elem.GetType().GetField("Name"); if (fieldName != null) { object elemname = fieldName.GetValue(elem); if (elemname != null) { FieldInfo fieldValue = elemname.GetType().GetField("Value"); if (fieldValue != null) { object elemval = fieldValue.GetValue(elemname); sbList.Append(elemval.ToString()); } } } sbList.Append("; <br/>"); } value = sbList.ToString(); } else if (value is Type) { value = ((Type)value).Name; } if (!String.IsNullOrEmpty(format)) { if (format.Equals("Required") && value == null) { includerow = false; } } if (value != null) { FieldInfo fieldValue = value.GetType().GetField("Value"); if (fieldValue != null) { value = fieldValue.GetValue(value); } if (format != null && format.Equals("True") && (value == null || !value.ToString().Equals("True"))) { includerow = false; } if (value is Double) { sbRow.Append(" align=\"right\">"); sbRow.Append(((Double)value).ToString("N3")); } else if (value is List <Int64> ) { sbRow.Append(">"); // latitude or longitude List <Int64> intlist = (List <Int64>)value; if (intlist.Count >= 3) { sbRow.Append(intlist[0] + "° " + intlist[1] + "' " + intlist[2] + "\""); } } else if (value != null) { sbRow.Append(">"); sbRow.Append(value.ToString()); // todo: html-encode } } else { sbRow.Append(">"); sbRow.Append(" "); } } else { sbRow.Append(">"); } sbRow.Append("</td>"); } sbRow.AppendLine("</tr>"); if (includerow) { sb.Append(sbRow.ToString()); } } } sb.AppendLine("</table>"); sb.AppendLine("<br/>"); } } } } } return(sb.ToString()); }
private void buttonInsert_Click(object sender, EventArgs e) { DocDefinition docBase = this.m_base; DocDefinition docDefinition = null; // for now, clear it -- future: allow incremental replacement CvtValuePath valuepathouter = null; CvtValuePath valuepathinner = null; // keep building while (docBase != null) { using (FormSelectEntity formEntity = new FormSelectEntity(docBase, docDefinition, this.m_project, SelectDefinitionOptions.Entity | SelectDefinitionOptions.Type)) { if (formEntity.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && formEntity.SelectedEntity != null) { CvtValuePath valuepath = null; if (formEntity.SelectedEntity is DocEntity) { using (FormSelectAttribute formAttribute = new FormSelectAttribute((DocEntity)formEntity.SelectedEntity, this.m_project, null, false)) { if (formAttribute.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && formAttribute.SelectedAttribute != null) { string item = null; switch (formAttribute.SelectedAttribute.GetAggregation()) { case DocAggregationEnum.SET: // if set collection, then qualify by name // future: more intelligent UI for picking property sets, properties using (FormSelectItem formItem = new FormSelectItem()) { if (formItem.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { item = formItem.Item; } } break; case DocAggregationEnum.LIST: // if list collection, then qualify by index // future: more intelligent UI for picking list indices using (FormSelectItem formItem = new FormSelectItem()) { if (formItem.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { item = formItem.Item; } } break; } // now add entry to listview valuepath = new CvtValuePath(formEntity.SelectedEntity, formAttribute.SelectedAttribute, item, null); if (valuepathinner != null) { valuepathinner.InnerPath = valuepath; } valuepathinner = valuepath; if (valuepathouter == null) { valuepathouter = valuepath; } // drill in if (this.m_map.ContainsKey(formAttribute.SelectedAttribute.DefinedType)) { docBase = this.m_map[formAttribute.SelectedAttribute.DefinedType] as DocDefinition; } } else { break; } } } else if (formEntity.SelectedEntity is DocType) { valuepath = new CvtValuePath(formEntity.SelectedEntity, null, null, null); if (valuepathinner != null) { valuepathinner.InnerPath = valuepath; } valuepathinner = valuepath; if (valuepathouter == null) { valuepathouter = valuepath; } docBase = null; } } else { break; } } } this.LoadValuePath(valuepathouter); }
/// <summary> /// Parses a value path from string in ISO-10303-11 (EXPRESS) format. /// </summary> /// <param name="value"></param> /// <returns></returns> public static CvtValuePath Parse(string value, Dictionary <string, DocObject> map) { if (value == null) { return(null); } string[] tokens = value.Split(new char[] { '\\' }); //???// don't remove empty entries -- if it ends in backslash, then indicates type identifier CvtValuePath rootpath = null; CvtValuePath outerpath = null; foreach (string token in tokens) { CvtValuePath valuepath = new CvtValuePath(); string[] parts = token.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length >= 1 && map.ContainsKey(parts[0])) { valuepath.Type = map[parts[0]] as DocDefinition; if (valuepath.Type != null && parts.Length == 2) { string propname = parts[1]; int bracket = propname.IndexOf('['); if (bracket >= 0) { string content = propname.Substring(bracket + 1, propname.Length - bracket - 2); if (content.StartsWith("'") && content.EndsWith("'")) { // indexed by name valuepath.Identifier = content.Substring(1, content.Length - 2); } else if (content.StartsWith("@")) { // indexed by parameter for each line, e.g. value identifies column by name when importing/exporting spreadsheet valuepath.Identifier = content; } else if (content.Length == 0) { valuepath.Vector = true; } propname = propname.Substring(0, bracket); } if (valuepath.Type is DocEntity) { DocEntity docEntity = (DocEntity)valuepath.Type; valuepath.Property = docEntity.ResolveAttribute(propname, map); } } } // chain if (outerpath != null) { outerpath.InnerPath = valuepath; } else { rootpath = valuepath; } outerpath = valuepath; } // avoid empty head link if (rootpath.Type == null && rootpath.Property == null && rootpath.InnerPath != null) { rootpath = rootpath.InnerPath; } return(rootpath); }
/// <summary> /// Extracts description of referenced data, using properties, quantities, and attributes. /// </summary> /// <param name="mapEntity"></param> /// <param name="docView">Optional model view, for retrieving more specific descriptions such as for ports</param> /// <returns></returns> public string GetDescription(Dictionary <string, DocObject> mapEntity, DocModelView docView) { string desc = null; CvtValuePath valpath = this; if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("IsDefinedBy") && valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcRelDefinesByProperties") && valpath.Identifier != null) { DocObject docPset = null; mapEntity.TryGetValue(valpath.Identifier, out docPset); if (docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation;// localize?? if (String.IsNullOrEmpty(docProp.Documentation)) { this.ToString(); } } } else if (docPset is DocQuantitySet) { DocQuantity docProp = ((DocQuantitySet)docPset).GetQuantity(valpath.InnerPath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation;// localize?? if (String.IsNullOrEmpty(docProp.Documentation)) { this.ToString(); } } } } else if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("HasAssignments") && valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcRelAssignsToControl") && valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath.Type.Name.Equals("IfcPerformanceHistory")) { DocObject docPset = null; if (mapEntity.TryGetValue(valpath.InnerPath.InnerPath.Identifier, out docPset)) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.InnerPath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation;// localize?? if (docProp.Documentation == null) { DocLocalization docLoc = docProp.GetLocalization(null); if (docLoc != null) { desc = docLoc.Documentation; } } } } this.ToString(); } else if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("HasPropertySets") && valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcPropertySet")) { DocObject docPset = null; mapEntity.TryGetValue(valpath.Identifier, out docPset); if (docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation;// localize?? if (String.IsNullOrEmpty(docProp.Documentation)) { this.ToString(); } } } } else if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("Material") && valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcMaterial") && valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath.Type.Name.Equals("IfcMaterialProperties")) { DocObject docPset = null; mapEntity.TryGetValue(valpath.InnerPath.Identifier, out docPset); if (docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation; } } } else if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("HasProperties") && valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcMaterialProperties")) { DocObject docPset = null; mapEntity.TryGetValue(valpath.Identifier, out docPset); if (docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation; } } } else if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("IsNestedBy") && valpath.InnerPath != null && valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath != null) { CvtValuePath pathInner = valpath.InnerPath.InnerPath; if (pathInner.Type != null && pathInner.Type.Name.Equals("IfcDistributionPort")) { string portname = valpath.InnerPath.Identifier; if (pathInner.Property != null && pathInner.Property.Name.Equals("IsDefinedBy")) { // lookup description of property at port DocObject docPset = null; mapEntity.TryGetValue(pathInner.Identifier, out docPset); if (docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(pathInner.InnerPath.InnerPath.Identifier); if (docProp != null) { desc = portname + ": " + docProp.Documentation; } } } else { desc = portname; // lookup description of port Guid guidPortNesting = new Guid("bafc93b7-d0e2-42d8-84cf-5da20ee1480a"); if (docView != null) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == valpath.Type) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition != null && docConcept.Definition.Uuid == guidPortNesting) { foreach (DocTemplateItem docItem in docConcept.Items) { if (docItem.Name != null && docItem.Name.Equals(portname)) { desc = docItem.Documentation; break; } } } } } } } } } } if (desc == null) { while (valpath != null && valpath.InnerPath != null && valpath.InnerPath.Property != null) { valpath = valpath.InnerPath; } if (valpath != null && valpath.Property != null) { desc = valpath.Property.Documentation; } else if (valpath != null) { desc = "The IFC class identifier indicating the subtype of object."; } } // clear out any notes int block = desc.IndexOf("<blockquote"); if (block != -1) { desc = desc.Substring(0, block); } return(desc); }
private void toolStripButtonProperty_Click(object sender, EventArgs e) { DocEntity docBaseEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; if (this.m_conceptroot != null && this.m_conceptroot.ApplicableEntity != null) { docBaseEntity = this.m_conceptroot.ApplicableEntity; } using (FormSelectProperty form = new FormSelectProperty(docBaseEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); Dictionary <string, DocObject> mapEntity = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { mapEntity.Add(docEntity.Name, docEntity); } foreach (DocType docType in docSchema.Types) { mapEntity.Add(docType.Name, docType); } } } if (docBaseEntity.BaseDefinition == "IfcElement" || docBaseEntity.BaseDefinition == "IfcElementComponent" || docBaseEntity.BaseDefinition == "IfcBuildingElement" || docBaseEntity.BaseDefinition == "IfcReinforcingElement" || docBaseEntity.BaseDefinition == "IfcFlowSegment" || docBaseEntity.BaseDefinition == "IfcFeatureElement" || docBaseEntity.BaseDefinition == "IfcContext" || docBaseEntity.BaseDefinition == "IfcSpatialStructureElement" || docBaseEntity.BaseDefinition == "IfcFacility" || docBaseEntity.BaseDefinition == "IfcFacilityPart") { this.ChangeTemplate(this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePsetObject)); string[] psetParamNames = this.Concept.Definition.GetParameterNames(); DocTemplateItem pset = new DocTemplateItem(); pset.Name = form.SelectedPropertySet.Name; if (form.SelectedPropertySet.Name == "Pset_ElementCommon") { pset.Name = form.SelectedPropertySet.Name.Replace("Element", docBaseEntity.Name); } pset.RuleParameters = "PsetName=" + pset.Name; if (this.Concept.Items.Count == 0) { this.Concept.Items.Add(pset); } else { bool addItem = true; foreach (DocTemplateItem existingPsetDefinition in this.Concept.Items) { if (existingPsetDefinition.Name == pset.Name) { addItem = false; } } if (addItem) { this.Concept.Items.Add(pset); } } DocTemplateUsage propertyConcept = new DocTemplateUsage(); DocPropertyTemplateTypeEnum propertyType = form.SelectedProperty.PropertyType; propertyConcept.Operator = DocTemplateOperator.And; DocTemplateItem property = new DocTemplateItem(); string psetName = pset.Name; propertyConcept.Name = String.Join(" ", Regex.Split(form.SelectedProperty.Name, @"(?<!^)(?=[A-Z])")); switch (propertyType) { case DocPropertyTemplateTypeEnum.P_SINGLEVALUE: //propertyConcept.Name = "Single Value"; //propertyRule.RuleParameters = parameterNames[0] + "[Value]=" + "'" + form.SelectedProperty.Name + "'" + parameterNames[1] + "[Type]=" + "'" + form.SelectedProperty.PrimaryDataType + "'"; propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertySingle); //parameterNames = property.Definition.GetParameterNames(); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: //propertyConcept.Name = "Enumerated Value"; propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyEnumerated); //parameterNames = property.Definition.GetParameterNames(); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyList); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyBounded); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyReference); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_TABLEVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyTable); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; } //foreach(DocModelRule rule in property.Definition.Rules) //{ // if (!string.IsNullOrEmpty(rule.Identification)) // { // } //} } else { CvtValuePath valuepath = CvtValuePath.Parse(value, mapEntity); this.ChangeTemplate(valuepath.ToTemplateDefinition()); } } } }
private void buttonProperty_Click(object sender, EventArgs e) { using (FormSelectProperty form = new FormSelectProperty(this.m_base as DocEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string portprefix = String.Empty; if (form.SelectedPort != null) { portprefix = @".IsNestedBy[]\IfcRelNests.RelatedObjects['" + form.SelectedPort + @"']\IfcDistributionPort"; } if (form.SelectedPropertySet != null && form.SelectedPropertySet.PropertySetType == "PSET_PERFORMANCEDRIVEN") { portprefix += @".HasAssignments[]\IfcRelAssignsToControl.RelatingControl\IfcPerformanceHistory"; } string value = @"\" + this.m_base.Name + portprefix; if (form.SelectedProperty != null) { string valueprop = "NominalValue"; string datatype = form.SelectedProperty.PrimaryDataType; switch (form.SelectedProperty.PropertyType) { case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: if (form.SelectedQualifier != null) { valueprop = form.SelectedQualifier; } else { valueprop = "SetPointValue"; } break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: valueprop = "EnumerationValues"; break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: valueprop = "ListValues"; break; case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE: valueprop = "PropertyReference"; datatype = "IfcIrregularTimeSeries.Values[]\\IfcIrregularTimeSeriesValue.ListValues[]\\" + form.SelectedProperty.SecondaryDataType; break; // other property types are not supported } if (form.SelectedProperty.PropertyType == DocPropertyTemplateTypeEnum.COMPLEX) { value += @".IsDefinedBy['" + form.SelectedPropertySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcPropertySet.HasProperties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName(); } else { value += @".IsDefinedBy['" + form.SelectedPropertySet + @"']\IfcRelDefinesByProperties.RelatingPropertyDefinition\IfcPropertySet.HasProperties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName() + @"." + valueprop + @"\" + datatype; } // special cases if (this.m_base.Name.Equals("IfcMaterial")) { value = @"\IfcMaterial.HasProperties['" + form.SelectedPropertySet + @"']\IfcMaterialProperties.Properties['" + form.SelectedProperty + @"']\" + form.SelectedProperty.GetEntityName() + @"." + valueprop + @"\" + datatype; } } else { value += @".GlobalId\IfcGloballyUniqueId"; } CvtValuePath valuepath = CvtValuePath.Parse(value, this.m_map); LoadValuePath(valuepath); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.tabControl.TabPages.Clear(); foreach (DocConceptRoot docRoot in this.m_view.ConceptRoots) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition != null && docConcept.Definition.Uuid == DocTemplateDefinition.guidTemplateMapping) { TabPage tabPage = new TabPage(); tabPage.Text = docRoot.Name; tabPage.Tag = docConcept; this.tabControl.TabPages.Add(tabPage); ListView listView = new ListView(); tabPage.Controls.Add(listView); listView.Dock = DockStyle.Fill; listView.View = View.Details; listView.FullRowSelect = true; ColumnHeader colHeaderIndex = new ColumnHeader(); colHeaderIndex.Text = "Index"; colHeaderIndex.Width = 100; listView.Columns.Add(colHeaderIndex); List <CvtValuePath> colmaps = new List <CvtValuePath>(); foreach (DocTemplateItem docItem in docConcept.Items) { string expr = docItem.GetParameterValue("Reference"); CvtValuePath valpath = CvtValuePath.Parse(expr, this.m_mapEntity); colmaps.Add(valpath); ColumnHeader columnHeader = new ColumnHeader(); columnHeader.Text = docItem.GetParameterValue("Name"); columnHeader.Tag = docItem; columnHeader.Width = 100; listView.Columns.Add(columnHeader); } // load instance data foreach (object instance in this.m_instances.Values) { string eachname = instance.GetType().Name; if (docRoot.ApplicableEntity != null && docRoot.ApplicableEntity.IsInstanceOfType(instance)) { ListViewItem lvi = new ListViewItem(); lvi.Text = (listView.Items.Count + 1).ToString(); listView.Items.Add(lvi); int iCol = 0; foreach (DocTemplateItem docItem in docConcept.Items) { CvtValuePath valpath = colmaps[iCol]; iCol++; object value = valpath.GetValue((SEntity)instance, null); if (value == instance) { value = e.GetType().Name; } else if (value is SEntity) { // use name FieldInfo fieldValue = value.GetType().GetField("Name"); if (fieldValue != null) { value = fieldValue.GetValue(value); } } else if (value is System.Collections.IList) { System.Collections.IList list = (System.Collections.IList)value; StringBuilder sbList = new StringBuilder(); foreach (object elem in list) { FieldInfo fieldName = elem.GetType().GetField("Name"); if (fieldName != null) { object elemname = fieldName.GetValue(elem); if (elemname != null) { FieldInfo fieldValue = elemname.GetType().GetField("Value"); if (fieldValue != null) { object elemval = fieldValue.GetValue(elemname); sbList.Append(elemval.ToString()); } } } sbList.Append("; <br/>"); } value = sbList.ToString(); } else if (value is Type) { value = ((Type)value).Name; } #if false if (!String.IsNullOrEmpty(format)) { if (format.Equals("Required") && value == null) { includerow = false; } } #endif string text = String.Empty; if (value != null) { FieldInfo fieldValue = value.GetType().GetField("Value"); if (fieldValue != null) { value = fieldValue.GetValue(value); } #if false if (format != null && format.Equals("True") && (value == null || !value.ToString().Equals("True"))) { includerow = false; } #endif if (value is Double) { text = ((Double)value).ToString("N3"); } else if (value is List <Int64> ) { // latitude or longitude List <Int64> intlist = (List <Int64>)value; if (intlist.Count >= 3) { text = intlist[0] + "° " + intlist[1] + "' " + intlist[2] + "\""; } } else if (value != null) { text = value.ToString(); } } lvi.SubItems.Add(text); } } } } } } }
/// <summary> /// Extracts description of referenced data, using properties, quantities, and attributes. /// </summary> /// <param name="mapEntity"></param> /// <param name="docView">Optional model view, for retrieving more specific descriptions such as for ports</param> /// <returns></returns> public string GetDescription(Dictionary<string, DocObject> mapEntity, DocModelView docView) { string desc = null; CvtValuePath valpath = this; if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("IsDefinedBy") && valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcRelDefinesByProperties")) { DocObject docPset = null; mapEntity.TryGetValue(valpath.Identifier, out docPset); if (docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation;// localize?? } } else if (docPset is DocQuantitySet) { DocQuantity docProp = ((DocQuantitySet)docPset).GetQuantity(valpath.InnerPath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation;// localize?? } } } else if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("HasPropertySets") && valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcPropertySet")) { DocObject docPset = null; mapEntity.TryGetValue(valpath.Identifier, out docPset); if (docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.Identifier); if (docProp != null) { desc = docProp.Documentation;// localize?? } } } else if(valpath != null && valpath.Property != null && valpath.Property.Name.Equals("Material") && valpath.InnerPath != null && valpath.InnerPath.Type.Name.Equals("IfcMaterial") && valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath.Type.Name.Equals("IfcMaterialProperties")) { DocObject docPset = null; mapEntity.TryGetValue(valpath.InnerPath.Identifier, out docPset); if(docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(valpath.InnerPath.InnerPath.Identifier); if(docProp != null) { desc = docProp.Documentation; } } } else if (valpath != null && valpath.Property != null && valpath.Property.Name.Equals("IsNestedBy") && valpath.InnerPath != null && valpath.InnerPath.InnerPath != null && valpath.InnerPath.InnerPath != null) { CvtValuePath pathInner = valpath.InnerPath.InnerPath; if (pathInner.Type != null && pathInner.Type.Name.Equals("IfcDistributionPort")) { string portname = valpath.InnerPath.Identifier; if (pathInner.Property != null && pathInner.Property.Name.Equals("IsDefinedBy")) { // lookup description of property at port DocObject docPset = null; mapEntity.TryGetValue(pathInner.Identifier, out docPset); if (docPset is DocPropertySet) { DocProperty docProp = ((DocPropertySet)docPset).GetProperty(pathInner.InnerPath.InnerPath.Identifier); if (docProp != null) { desc = portname + ": " + docProp.Documentation; } } } else { desc = portname; // lookup description of port Guid guidPortNesting = new Guid("bafc93b7-d0e2-42d8-84cf-5da20ee1480a"); foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == valpath.Type) { foreach(DocTemplateUsage docConcept in docRoot.Concepts) { if(docConcept.Definition != null && docConcept.Definition.Uuid == guidPortNesting) { foreach (DocTemplateItem docItem in docConcept.Items) { if(docItem.Name.Equals(portname)) { desc = docItem.Documentation; break; } } } } } } } } } if (desc == null) { while (valpath != null && valpath.InnerPath != null && valpath.InnerPath.Property != null) { valpath = valpath.InnerPath; } if (valpath != null && valpath.Property != null) { desc = valpath.Property.Documentation; } else if (valpath != null) { desc = "The IFC class identifier indicating the subtype of object."; } } return desc; }
/// <summary> /// Parses a value path from string in ISO-10303-11 (EXPRESS) format. /// </summary> /// <param name="value"></param> /// <returns></returns> public static CvtValuePath Parse(string value, Dictionary<string, DocObject> map) { if (value == null) return null; string[] tokens = value.Split(new char[] { '\\' }); //???// don't remove empty entries -- if it ends in backslash, then indicates type identifier CvtValuePath rootpath = null; CvtValuePath outerpath = null; foreach (string token in tokens) { CvtValuePath valuepath = new CvtValuePath(); string[] parts = token.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length >= 1 && map.ContainsKey(parts[0])) { valuepath.Type = map[parts[0]] as DocDefinition; if (valuepath.Type != null && parts.Length == 2) { string propname = parts[1]; int bracket = propname.IndexOf('['); if (bracket >= 0) { string content = propname.Substring(bracket + 1, propname.Length - bracket - 2); if (content.StartsWith("'") && content.EndsWith("'")) { // indexed by name valuepath.Identifier = content.Substring(1, content.Length - 2); } else if (content.StartsWith("@")) { // indexed by parameter for each line, e.g. value identifies column by name when importing/exporting spreadsheet valuepath.Identifier = content; } else if (content.Length == 0) { valuepath.Vector = true; } propname = propname.Substring(0, bracket); } if (valuepath.Type is DocEntity) { DocEntity docEntity = (DocEntity)valuepath.Type; valuepath.Property = docEntity.ResolveAttribute(propname, map); } } } // chain if (outerpath != null) { outerpath.InnerPath = valuepath; } else { rootpath = valuepath; } outerpath = valuepath; } // avoid empty head link if (rootpath.Type == null && rootpath.Property == null && rootpath.InnerPath != null) { rootpath = rootpath.InnerPath; } return rootpath; }
public string FormatDataConcept(DocProject docProject, DocPublication docPublication, DocExchangeDefinition docExchange, Dictionary <string, DocObject> map, Dictionary <string, Type> typemap, Dictionary <long, SEntity> instances, SEntity root, bool markup, DocModelView docView, DocConceptRoot docRoot, DocTemplateUsage docConcept) { StringBuilder sb = new StringBuilder(); string table = docConcept.Items[0].GetParameterValue("Table"); string query = docConcept.Items[0].GetParameterValue("Reference"); sb.AppendLine("<h4>" + docConcept.Name + "</h4>"); sb.AppendLine("<table class=\"gridtable\">"); List <string> colstyles = new List <string>(); List <string> colformat = new List <string>(); List <CvtValuePath> colmaps = new List <CvtValuePath>(); // generate header row sb.AppendLine("<tr>"); foreach (DocTemplateItem docItem in docConcept.Items) { string name = docItem.GetParameterValue("Name"); string disp = "#" + docItem.GetColor().ToArgb().ToString("X8"); //docItem.GetParameterValue("Color");docItem.GetParameterValue("Color"); string expr = docItem.GetParameterValue("Reference"); string form = docItem.GetParameterValue("Format"); string style = ""; if (!String.IsNullOrEmpty(disp)) { style = " style=\"background-color:" + disp + ";\""; } colstyles.Add(style); string format = ""; if (!String.IsNullOrEmpty(form)) { format = form; } colformat.Add(format); string desc = ""; CvtValuePath valpath = CvtValuePath.Parse(expr, map); colmaps.Add(valpath); if (valpath != null) { desc = /*valpath.GetDescription(map) + " " + */ valpath.ToString().Replace("\\", " "); } sb.Append("<th><a href=\"../../schema/views/" + DocumentationISO.MakeLinkName(docView) + "/" + DocumentationISO.MakeLinkName(docExchange) + ".htm#" + DocumentationISO.MakeLinkName(docConcept) + "\" title=\"" + desc + "\">"); sb.Append(name); sb.Append("</a></th>"); } ; sb.AppendLine("</tr>"); // generate data rows List <DocModelRule> trace = new List <DocModelRule>(); foreach (SEntity e in instances.Values) { string eachname = e.GetType().Name; if (docRoot.ApplicableEntity.IsInstanceOfType(e)) { bool includerow = true; // if root has more complex rules, check them if (docRoot.ApplicableTemplate != null && docRoot.ApplicableItems.Count > 0) { includerow = false; // must check1 foreach (DocTemplateItem docItem in docRoot.ApplicableItems) { foreach (DocModelRule rule in docRoot.ApplicableTemplate.Rules) { try { trace.Clear(); bool?result = rule.Validate(e, docItem, typemap, trace, e, null, null); if (result == true && docRoot.ApplicableOperator == DocTemplateOperator.Or) { includerow = true; break; } } catch { docRoot.ToString(); } } // don't yet support AND or other operators if (includerow) { break; } } } if (includerow) { StringBuilder sbRow = new StringBuilder(); sbRow.Append("<tr>"); int iCol = 0; foreach (DocTemplateItem docItem in docConcept.Items) { sbRow.Append("<td" + colstyles[iCol]); CvtValuePath valpath = colmaps[iCol]; string format = colformat[iCol]; iCol++; if (valpath != null) { string nn = docItem.GetParameterValue("Name"); object value = valpath.GetValue(e, null); if (value == e) { value = e.GetType().Name; } else if (value is SEntity) { // use name FieldInfo fieldValue = value.GetType().GetField("Name"); if (fieldValue != null) { value = fieldValue.GetValue(value); } } else if (value is System.Collections.IList) { System.Collections.IList list = (System.Collections.IList)value; StringBuilder sbList = new StringBuilder(); foreach (object elem in list) { FieldInfo fieldName = elem.GetType().GetField("Name"); if (fieldName != null) { object elemname = fieldName.GetValue(elem); if (elemname != null) { FieldInfo fieldValue = elemname.GetType().GetField("Value"); if (fieldValue != null) { object elemval = fieldValue.GetValue(elemname); sbList.Append(elemval.ToString()); } } } sbList.Append("; <br/>"); } value = sbList.ToString(); } else if (value is Type) { value = ((Type)value).Name; } if (!String.IsNullOrEmpty(format)) { if (format.Equals("Required") && value == null) { includerow = false; } } if (value != null) { FieldInfo fieldValue = value.GetType().GetField("Value"); if (fieldValue != null) { value = fieldValue.GetValue(value); } if (format != null && format.Equals("True") && (value == null || !value.ToString().Equals("True"))) { includerow = false; } if (value is Double) { sbRow.Append(" align=\"right\">"); sbRow.Append(((Double)value).ToString("N3")); } else if (value is List <Int64> ) { sbRow.Append(">"); // latitude or longitude List <Int64> intlist = (List <Int64>)value; if (intlist.Count >= 3) { sbRow.Append(intlist[0] + "° " + intlist[1] + "' " + intlist[2] + "\""); } } else if (value != null) { sbRow.Append(">"); sbRow.Append(value.ToString()); // todo: html-encode } } else { sbRow.Append(">"); sbRow.Append(" "); } } else { sbRow.Append(">"); } sbRow.Append("</td>"); } sbRow.AppendLine("</tr>"); if (includerow) { sb.Append(sbRow.ToString()); } } } } sb.AppendLine("</table>"); sb.AppendLine("<br/>"); return(sb.ToString()); }