public string AsString() { StringBuilder value = new StringBuilder(); if (!string.IsNullOrEmpty(Description)) { value.Append(Description); value.Append(", "); } if (AppliedValue != null)//not nullable should be? incorrect name? { value.Append("AppliedValue: "); if (AppliedValue is IfcRatioMeasure) { var ifcRatioMeasure = (IfcRatioMeasure)AppliedValue; value.Append(string.Format("{0,0:N2}", ifcRatioMeasure.Value)); } if (AppliedValue is IfcMonetaryMeasure) { IfcMonetaryMeasure ifcMonetaryMeasure = (IfcMonetaryMeasure)AppliedValue; value.Append(string.Format("{0,0:N2}", ifcMonetaryMeasure.Value)); } var unit = AppliedValue as IfcMeasureWithUnit; if (unit != null) { value.Append(unit.AsString()); } value.Append(", "); } if (UnitBasis != null) //not nullable should be? { value.Append("UnitBase: "); value.Append(UnitBasis.AsString()); value.Append(", "); } if (ApplicableDate != null) //not nullable should be? { value.Append("ApplicableDate: "); value.Append(ApplicableDate.ToString()); value.Append(", "); } if (FixedUntilDate != null) //not nullable should be? { value.Append("FixedUntilDate: "); value.Append(FixedUntilDate.ToString()); value.Append(", "); } return(value.ToString()); }
public static string GetAsString(this IfcAppliedValue ifcAppliedValue) { StringBuilder value = new StringBuilder(); if ((ifcAppliedValue.Description.HasValue) && (!string.IsNullOrEmpty(ifcAppliedValue.Description)) ) { value.Append(ifcAppliedValue.Description); value.Append(", "); } if (ifcAppliedValue.Value != null)//not nullable should be? incorrect name? { value.Append("AppliedValue: "); if (ifcAppliedValue.Value is IfcRatioMeasure) { IfcRatioMeasure ifcRatioMeasure = (IfcRatioMeasure)ifcAppliedValue.Value; value.Append(string.Format("{0,0:N2}", ifcRatioMeasure.Value)); } if (ifcAppliedValue.Value is IfcMonetaryMeasure) { IfcMonetaryMeasure ifcMonetaryMeasure = (IfcMonetaryMeasure)ifcAppliedValue.Value; value.Append(string.Format("{0,0:N2}", ifcMonetaryMeasure.Value)); } if (ifcAppliedValue.Value is IfcMeasureWithUnit) { value.Append(GetMeasureWithUnitAsString((IfcMeasureWithUnit)ifcAppliedValue.Value)); } value.Append(", "); } if (ifcAppliedValue.UnitBasis != null) //not nullable should be? { value.Append("UnitBase: "); value.Append(GetMeasureWithUnitAsString((IfcMeasureWithUnit)ifcAppliedValue.UnitBasis)); value.Append(", "); } if (ifcAppliedValue.ApplicableDate != null) //not nullable should be? { value.Append("ApplicableDate: "); value.Append(ifcAppliedValue.ApplicableDate.GetAsString()); value.Append(", "); } if (ifcAppliedValue.FixedUntilDate != null) //not nullable should be? { value.Append("FixedUntilDate: "); value.Append(ifcAppliedValue.FixedUntilDate.GetAsString()); value.Append(", "); } if (ifcAppliedValue is IfcCostValue) { IfcCostValue ifcCostValue = (IfcCostValue)ifcAppliedValue; if (ifcCostValue.CostType != null) { value.Append("CostType: "); value.Append(ifcCostValue.CostType); value.Append(", "); } if (ifcCostValue.Condition != null)//not nullable should be? { value.Append("Condition: "); value.Append(ifcCostValue.Condition); value.Append(", "); } } if (ifcAppliedValue is IfcEnvironmentalImpactValue) { IfcEnvironmentalImpactValue ifcEnvironmentalImpactValue = (IfcEnvironmentalImpactValue)ifcAppliedValue; if (ifcEnvironmentalImpactValue.ImpactType != null) { value.Append("ImpactType: "); value.Append(ifcEnvironmentalImpactValue.ImpactType); value.Append(", "); } //enum so should have a value as not nullable value.Append("Category: "); value.Append(ifcEnvironmentalImpactValue.Category.ToString()); value.Append(", "); if (ifcEnvironmentalImpactValue.UserDefinedCategory != null)//not nullable should be? { value.Append("UserDefinedCategory: "); value.Append(ifcEnvironmentalImpactValue.UserDefinedCategory); value.Append(", "); } } return(value.ToString()); }