private static void SetAttributeValue(IIfcPropertyBoundedValue boundedValue, CobieAttribute attribute) { var values = new List <IIfcValue>(); if (boundedValue.LowerBoundValue != null) { values.Add(boundedValue.LowerBoundValue); } if (boundedValue.SetPointValue != null) { values.Add(boundedValue.SetPointValue); } if (boundedValue.UpperBoundValue != null) { values.Add(boundedValue.UpperBoundValue); } if (values.Any()) { StringValue value = string.Join(",", values); attribute.Value = value; } if (boundedValue.Unit != null) { attribute.Unit = boundedValue.Unit.FullName; } //var ifcValue = (IExpressValueType) ifcPropertyBoundedValue.LowerBoundValue ; ////only upper and lowwer bounds are supported by COBie on integer and decimal values //if (ifcValue.UnderlyingSystemType == typeof(int) || ifcValue.UnderlyingSystemType == typeof(long) || ifcValue.UnderlyingSystemType == typeof(short) || ifcValue.UnderlyingSystemType == typeof(byte) // || ifcValue.UnderlyingSystemType == typeof(int?) || ifcValue.UnderlyingSystemType == typeof(long?) || ifcValue.UnderlyingSystemType == typeof(short?) || ifcValue.UnderlyingSystemType == typeof(byte?)) //{ // IntegerValue integerValue; // if (ifcPropertyBoundedValue.UpperBoundValue != null) // { // attribute.MaximalValue = Convert.ToInt32(ifcPropertyBoundedValue.UpperBoundValue); // } // if (ifcPropertyBoundedValue.LowerBoundValue != null) // { // attribute.MinimalValue = Convert.ToInt32(ifcPropertyBoundedValue.LowerBoundValue); // } // return integerValue; //} //if (ifcValue.UnderlyingSystemType == typeof(double) || ifcValue.UnderlyingSystemType == typeof(float) // || ifcValue.UnderlyingSystemType == typeof(double?) || ifcValue.UnderlyingSystemType == typeof(float?)) //{ // var decimalValue = new DecimalAttributeValue(); // if (ifcPropertyBoundedValue.UpperBoundValue != null) // decimalValue.MaximalValue = (double) ifcPropertyBoundedValue.UpperBoundValue.Value; // if (ifcPropertyBoundedValue.LowerBoundValue != null) // decimalValue.MinimalValue = (double) ifcPropertyBoundedValue.LowerBoundValue.Value; // return decimalValue; //} //return null; }
/// <summary> /// /// </summary> /// <param name="ifcProperty"></param> /// <param name="attribute"></param> /// <returns></returns> public static void SetAttributeValueType(IIfcPropertySingleValue ifcProperty, CobieAttribute attribute) { var ifcValue = ifcProperty.NominalValue; if (ifcValue == null) { return; } if (ifcProperty.Unit != null) { attribute.Unit = ifcProperty.Unit.FullName; } if (ifcValue is IfcMonetaryMeasure) { attribute.Value = (FloatValue)ifcValue.Value; var monUnit = ifcProperty.Unit as IIfcMonetaryUnit; if (monUnit == null) { return; } attribute.Unit = monUnit.ToString(); return; } if (ifcValue is IfcTimeStamp) { var timeStamp = (IfcTimeStamp)ifcValue; var timeValue = (DateTimeValue)timeStamp.ToDateTime(); attribute.Value = timeValue; return; } if (ifcValue.UnderlyingSystemType == typeof(int) || ifcValue.UnderlyingSystemType == typeof(long) || ifcValue.UnderlyingSystemType == typeof(short) || ifcValue.UnderlyingSystemType == typeof(byte)) { attribute.Value = (IntegerValue)Convert.ToInt32(ifcValue.Value); return; } if (ifcValue.UnderlyingSystemType == typeof(double) || ifcValue.UnderlyingSystemType == typeof(float)) { attribute.Value = (FloatValue)(double)ifcValue.Value; return; } if (ifcValue.UnderlyingSystemType == typeof(string)) { attribute.Value = (StringValue)ifcValue.ToString(); return; } if (ifcValue.UnderlyingSystemType == typeof(bool) || ifcValue.UnderlyingSystemType == typeof(bool?)) { if (ifcValue.Value == null || !(bool)ifcValue.Value) { return; } attribute.Value = (BooleanValue)(bool)ifcValue.Value; } }