Пример #1
0
        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;
        }
Пример #2
0
        private static AttributeValue GetAttributeValue(IIfcPropertyBoundedValue ifcPropertyBoundedValue)
        {
            var ifcValue = (IExpressValueType)ifcPropertyBoundedValue.LowerBoundValue;

            //only upper and lower 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?)
                )
            {
                var integerValue = new IntegerAttributeValue();
                if (ifcPropertyBoundedValue.UpperBoundValue != null)
                {
                    integerValue.MaximalValue = Convert.ToInt32(ifcPropertyBoundedValue.UpperBoundValue);
                }
                if (ifcPropertyBoundedValue.LowerBoundValue != null)
                {
                    integerValue.MinimalValue = Convert.ToInt32(ifcPropertyBoundedValue.LowerBoundValue);
                }
                return(integerValue);
            }
            // ReSharper disable once InvertIf
            else 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);
        }
Пример #3
0
        private static AttributeValueType GetAttributeValue(IIfcPropertyBoundedValue ifcPropertyBoundedValue)
        {
            var       attributeValueType = new AttributeValueType();
            IIfcValue ifcValue           = ifcPropertyBoundedValue.LowerBoundValue;
            var       expressValue       = (IExpressValueType)ifcValue;
            var       underlyingType     = expressValue.UnderlyingSystemType;

            //only upper and lowwer bounds are supported by COBie on integer and decimal values
            if (underlyingType == typeof(int) || underlyingType == typeof(long) || underlyingType == typeof(short) || underlyingType == typeof(byte) ||
                underlyingType == typeof(int?) || underlyingType == typeof(long?) || underlyingType == typeof(short?) || underlyingType == typeof(byte?))
            {
                var integerValue = new AttributeIntegerValueType();
                if (ifcPropertyBoundedValue.UpperBoundValue != null)
                {
                    integerValue.MaxValueInteger = Convert.ToInt32(((IExpressValueType)ifcPropertyBoundedValue.UpperBoundValue).Value);
                }
                if (ifcPropertyBoundedValue.LowerBoundValue != null)
                {
                    integerValue.MinValueInteger = Convert.ToInt32(((IExpressValueType)ifcPropertyBoundedValue.LowerBoundValue).Value);
                }
                attributeValueType.Item            = integerValue;
                attributeValueType.ItemElementName = ItemChoiceType.AttributeIntegerValue;
            }
            else if (underlyingType == typeof(double) || underlyingType == typeof(float) ||
                     underlyingType == typeof(double?) || underlyingType == typeof(float?))
            {
                var decimalValue = new AttributeDecimalValueType();
                if (ifcPropertyBoundedValue.UpperBoundValue != null)
                {
                    decimalValue.MaxValueDecimal          = (double)((IExpressValueType)ifcPropertyBoundedValue.UpperBoundValue).Value;
                    decimalValue.MaxValueDecimalSpecified = true;
                }
                if (ifcPropertyBoundedValue.LowerBoundValue != null)
                {
                    decimalValue.MinValueDecimal          = (double)((IExpressValueType)ifcPropertyBoundedValue.LowerBoundValue).Value;
                    decimalValue.MinValueDecimalSpecified = true;
                }
                attributeValueType.Item            = decimalValue;
                attributeValueType.ItemElementName = ItemChoiceType.AttributeDecimalValue;
            }
            else
            {
                attributeValueType = null;
            }

            return(attributeValueType);
        }