public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
             base.IfcParse(propIndex, value);
             break;
         case 8:
             _distributionPointFunction =
                 (IfcElectricDistributionPointFunctionEnum)
                 Enum.Parse(typeof (IfcElectricDistributionPointFunctionEnum), value.EnumVal, true);
             break;
         case 9:
             _userDefinedFunction = value.StringVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #2
0
        public IPropertyValue Construct(CssProperty[] properties)
        {
            var valueList = new List<List<CssToken>>[properties.Length];
            var dummies = new CssProperty[properties.Length];
            var max = 0;

            for (var i = 0; i < properties.Length; i++)
            {
                var value = properties[i].DeclaredValue;
                valueList[i] = value != null ? value.Original.ToList() : new List<List<CssToken>>();
                dummies[i] = Factory.Properties.CreateLonghand(properties[i].Name);
                max = Math.Max(max, valueList[i].Count);
            }

            var values = new IPropertyValue[max];

            for (var i = 0; i < max; i++)
            {
                for (var j = 0; j < dummies.Length; j++)
                {
                    var list = valueList[j];
                    var tokens = list.Count > i ? list[i] : Enumerable.Empty<CssToken>();
                    dummies[j].TrySetValue(new CssValue(tokens));
                }

                var converter = (i < max - 1) ? _listConverter : _endConverter;
                values[i] = converter.Construct(dummies);
            }

            return new ListValue(values, Enumerable.Empty<CssToken>());
        }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
         case 8:
         case 9:
         case 10:
             base.IfcParse(propIndex, value);
             break;
         case 11:
             _projectedOrTrue =
                 (IfcProjectedOrTrueLengthEnum)
                 Enum.Parse(typeof (IfcProjectedOrTrueLengthEnum), value.EnumVal, true);
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     if (propIndex == 0)
         _contents.Add((IfcDraughtingCalloutElement) value.EntityVal);
     else
         this.HandleUnexpectedAttribute(propIndex, value);
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     if (propIndex == 0)
         _position = (IfcAxis2Placement3D) value.EntityVal;
     else
         this.HandleUnexpectedAttribute(propIndex, value);
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     if (propIndex == 0)
         _sbsmBoundary.Add((IfcShell) value.EntityVal);
     else
         this.HandleUnexpectedAttribute(propIndex, value);
 }
Пример #7
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
             base.IfcParse(propIndex, value);
             break;
         case 8:
             _assemblyPlace = (IfcAssemblyPlaceEnum)
                 Enum.Parse(typeof(IfcAssemblyPlaceEnum), value.EnumVal, true);
             break;
         case 9:
             _predefinedType = (IfcElementAssemblyTypeEnum)
                 Enum.Parse(typeof(IfcElementAssemblyTypeEnum), value.EnumVal, true);
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     if (propIndex == 0)
         _outer = (IfcClosedShell) value.EntityVal;
     else
         this.HandleUnexpectedAttribute(propIndex, value);
 }
Пример #9
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     if (propIndex == 0)
         _edgeList.Add((IfcOrientedEdge) value.EntityVal);
     else
         this.HandleUnexpectedAttribute(propIndex, value);
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
             base.IfcParse(propIndex, value);
             break;
         case 7:
             _predefinedType =
                 (IfcStructuralSurfaceTypeEnum)
                 Enum.Parse(typeof (IfcStructuralSurfaceTypeEnum), value.EnumVal, true);
             break;
         case 8:
             _thickness = value.RealVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
         case 8:
             base.IfcParse(propIndex, value);
             break;
         case 9:
             _subContractor = (IfcActorSelect) value.EntityVal;
             break;
         case 10:
             _jobDescription = value.StringVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
         case 8:
             base.IfcParse(propIndex, value);
             break;
         case 9:
             if (_suppliers == null)
                 _suppliers = new XbimSet<IfcActorSelect>(this);
             _suppliers.Add((IfcActorSelect)value.EntityVal);
             break;
         case 10:
             _usageRatio = value.RealVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #13
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
         case 8:
             base.IfcParse(propIndex, value);
             break;
         case 9:
             _destabilizingLoad = value.BooleanVal;
             break;
         case 10:
             _causedBy = (IfcStructuralReaction) value.EntityVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #14
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
             base.IfcParse(propIndex, value);
             break;
         case 7:
             _benchmark = (IfcBenchmarkEnum) Enum.Parse(typeof (IfcBenchmarkEnum), value.EnumVal);
             break;
         case 8:
             _valueSource = value.StringVal;
             break;
         case 9:
             _dataValue = (IfcMetricValueSelect) value.EntityVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
         case 8:
             base.IfcParse(propIndex, value);
             break;
         case 9:
             _Width = value.RealVal;
             break;
         case 10:
             _Height = value.RealVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #16
0
        public override void IfcParse(int propIndex, IPropertyValue value)
        {
            if (propIndex == 0 && value.Type == IfcParserType.Real) //we have a 2x2 colour with no name
            {
                _name = ifc2x2Colour;
            }
            if (_name == ifc2x2Colour) propIndex++; //move all indices along 

            switch (propIndex)
            {
                case 0:    
                    base.IfcParse(propIndex, value);
                    break;
                case 1:
                    _red = value.RealVal;
                    break;
                case 2:
                    _green = value.RealVal;
                    break;
                case 3:
                    _blue = value.RealVal;
                    break;
                default:
                    this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
             base.IfcParse(propIndex, value);
             break;
         case 8:
             _topFlangeWidth = value.RealVal;
             break;
         case 9:
             _topFlangeThickness = value.RealVal;
             break;
         case 10:
             _topFlangeFilletRadius = value.RealVal;
             break;
         case 11:
             _centreOfGravityInY = value.RealVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #18
0
        public override void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                    base.IfcParse(propIndex, value);
                    break;
                case 8:
                    _predefinedType = (IfcPileTypeEnum) Enum.Parse(typeof (IfcPileTypeEnum), value.EnumVal, true);
                    break;
                case 9:
                    _constructionType =
                        (IfcPileConstructionEnum) Enum.Parse(typeof (IfcPileConstructionEnum), value.EnumVal, true);
                    break;

                default:
                    this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
Пример #19
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     if (propIndex == 0) base.IfcParse(propIndex, value);
     else if (propIndex == 1)
         _axis = (IfcDirection) value.EntityVal;
     else
         this.HandleUnexpectedAttribute(propIndex, value);
 }
Пример #20
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     if (propIndex == 0)
     {
         _points.Add((IfcCartesianPoint) value.EntityVal);
     }
     else
         this.HandleUnexpectedAttribute(propIndex, value);
 }
Пример #21
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     if (propIndex == 0)
     {
         _cfsFaces.Add((IfcFace) value.EntityVal);
     }
     else
         this.HandleUnexpectedAttribute(propIndex, value);
 }
 public PeriodicValue(IPropertyValue[] options, IEnumerable<CssToken> tokens, String[] labels)
 {
     _top = options[0];
     _right = options[1] ?? _top;
     _bottom = options[2] ?? _top;
     _left = options[3] ?? _right;
     _original = new CssValue(tokens);
     _labels = labels;
 }
        public ComponentPropertyWrapViewModel(string propertyName, IPropertyValue propertyValue, string type, bool required)
        {
            mName = propertyName;

            mType = (CommonUtils.PropertyType)Enum.Parse(typeof(CommonUtils.PropertyType), type, true);
            mRequired = required;
            mPropertyValue = propertyValue;
            mErrorNumbericalValidationResult = new ValidationResult(string.Format("Field {0} is numerical", mName));
            mErrorRequiredValidationResult = new ValidationResult(string.Format("Field {0} is required", mName));
        }
Пример #24
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _TextureMaps.Add((IfcVertexBasedTextureMap)value.EntityVal);
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #25
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _vertexGeometry = (IfcPoint) value.EntityVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _contents.Add((IfcDraughtingCalloutElement)(value.EntityVal));
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _repeatFactor = (IfcVector) value.EntityVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #28
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _treeRootExpression = (IfcCsgSelect) value.EntityVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #29
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _position = (IfcAxis2Placement3D) value.EntityVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Пример #30
0
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             _EdgeList.Add((IfcOrientedEdge)value.EntityVal);
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
 public StartValue(String start, IPropertyValue value, IEnumerable <CssToken> tokens)
 {
     _start    = start;
     _value    = value;
     _original = new CssValue(tokens);
 }
Пример #32
0
        public bool Equals(IPropertyValue other)
        {
            var r = other as Raw;

            return(r != null && JToken.DeepEquals(JsonValue, r.JsonValue));
        }
Пример #33
0
        public bool Equals(IPropertyValue other)
        {
            var f = other as Float;

            return(f != null && Value == f.Value);
        }
Пример #34
0
 public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
 {
     //there are no attributes defined for this entity
     throw new System.IndexOutOfRangeException("There are no attributes defined for this entity");
 }
Пример #35
0
 // TODO: Implement IfcProcedure
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
 }
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 3:
                _overallHeight = value.RealVal;
                return;

            case 4:
                _baseWidth2 = value.RealVal;
                return;

            case 5:
                _radius = value.RealVal;
                return;

            case 6:
                _headWidth = value.RealVal;
                return;

            case 7:
                _headDepth2 = value.RealVal;
                return;

            case 8:
                _headDepth3 = value.RealVal;
                return;

            case 9:
                _webThickness = value.RealVal;
                return;

            case 10:
                _baseWidth4 = value.RealVal;
                return;

            case 11:
                _baseDepth1 = value.RealVal;
                return;

            case 12:
                _baseDepth2 = value.RealVal;
                return;

            case 13:
                _baseDepth3 = value.RealVal;
                return;

            case 14:
                _centreOfGravityInY = value.RealVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Пример #37
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 3:
                _scheduleWork = value.StringVal;
                return;

            case 4:
                _scheduleUsage = value.RealVal;
                return;

            case 5:
                _scheduleStart = value.StringVal;
                return;

            case 6:
                _scheduleFinish = value.StringVal;
                return;

            case 7:
                _scheduleContour = value.StringVal;
                return;

            case 8:
                _levelingDelay = value.StringVal;
                return;

            case 9:
                _isOverAllocated = value.BooleanVal;
                return;

            case 10:
                _statusTime = value.StringVal;
                return;

            case 11:
                _actualWork = value.StringVal;
                return;

            case 12:
                _actualUsage = value.RealVal;
                return;

            case 13:
                _actualStart = value.StringVal;
                return;

            case 14:
                _actualFinish = value.StringVal;
                return;

            case 15:
                _remainingWork = value.StringVal;
                return;

            case 16:
                _remainingUsage = value.RealVal;
                return;

            case 17:
                _completion = value.RealVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Пример #38
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 3:
                _durationType = (IfcTaskDurationEnum)System.Enum.Parse(typeof(IfcTaskDurationEnum), value.EnumVal, true);
                return;

            case 4:
                _scheduleDuration = value.StringVal;
                return;

            case 5:
                _scheduleStart = value.StringVal;
                return;

            case 6:
                _scheduleFinish = value.StringVal;
                return;

            case 7:
                _earlyStart = value.StringVal;
                return;

            case 8:
                _earlyFinish = value.StringVal;
                return;

            case 9:
                _lateStart = value.StringVal;
                return;

            case 10:
                _lateFinish = value.StringVal;
                return;

            case 11:
                _freeFloat = value.StringVal;
                return;

            case 12:
                _totalFloat = value.StringVal;
                return;

            case 13:
                _isCritical = value.BooleanVal;
                return;

            case 14:
                _statusTime = value.StringVal;
                return;

            case 15:
                _actualDuration = value.StringVal;
                return;

            case 16:
                _actualStart = value.StringVal;
                return;

            case 17:
                _actualFinish = value.StringVal;
                return;

            case 18:
                _remainingTime = value.StringVal;
                return;

            case 19:
                _completion = value.RealVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Пример #39
0
        // Token: 0x0600640F RID: 25615 RVA: 0x00153B70 File Offset: 0x00151D70
        private static T CoerceScalarValue <T>(PropertyType type, object value)
        {
            if (!CLRIPropertyValueImpl.IsCoercable(type, value) && type != PropertyType.Inspectable)
            {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", new object[]
                {
                    type,
                    typeof(T).Name
                }), -2147316576);
            }
            try
            {
                if (type == PropertyType.String && typeof(T) == typeof(Guid))
                {
                    return((T)((object)Guid.Parse((string)value)));
                }
                if (type == PropertyType.Guid && typeof(T) == typeof(string))
                {
                    return((T)((object)((Guid)value).ToString("D", CultureInfo.InvariantCulture)));
                }
                foreach (Tuple <Type, PropertyType> tuple in CLRIPropertyValueImpl.NumericScalarTypes)
                {
                    if (tuple.Item1 == typeof(T))
                    {
                        return((T)((object)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture)));
                    }
                }
            }
            catch (FormatException)
            {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", new object[]
                {
                    type,
                    typeof(T).Name
                }), -2147316576);
            }
            catch (InvalidCastException)
            {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", new object[]
                {
                    type,
                    typeof(T).Name
                }), -2147316576);
            }
            catch (OverflowException)
            {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueCoersion", new object[]
                {
                    type,
                    value,
                    typeof(T).Name
                }), -2147352566);
            }
            IPropertyValue propertyValue = value as IPropertyValue;

            if (type == PropertyType.Inspectable && propertyValue != null)
            {
                if (typeof(T) == typeof(byte))
                {
                    return((T)((object)propertyValue.GetUInt8()));
                }
                if (typeof(T) == typeof(short))
                {
                    return((T)((object)propertyValue.GetInt16()));
                }
                if (typeof(T) == typeof(ushort))
                {
                    return((T)((object)propertyValue.GetUInt16()));
                }
                if (typeof(T) == typeof(int))
                {
                    return((T)((object)propertyValue.GetUInt32()));
                }
                if (typeof(T) == typeof(uint))
                {
                    return((T)((object)propertyValue.GetUInt32()));
                }
                if (typeof(T) == typeof(long))
                {
                    return((T)((object)propertyValue.GetInt64()));
                }
                if (typeof(T) == typeof(ulong))
                {
                    return((T)((object)propertyValue.GetUInt64()));
                }
                if (typeof(T) == typeof(float))
                {
                    return((T)((object)propertyValue.GetSingle()));
                }
                if (typeof(T) == typeof(double))
                {
                    return((T)((object)propertyValue.GetDouble()));
                }
            }
            throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", new object[]
            {
                type,
                typeof(T).Name
            }), -2147316576);
        }
Пример #40
0
        /// <summary>
        /// Fills document with data
        /// </summary>
        /// <exception cref="InvalidDataException">ReportTableRow must have a TableRowGroup as parent</exception>
        protected virtual void FillData()
        {
            ArrayList blockDocumentValues  = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineDocumentValue));  // walker.Walk<IInlineDocumentValue>(_flowDocument);
            ArrayList blockTableRows       = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(ITableRowForDataTable)); // walker.Walk<TableRowForDataTable>(_flowDocument);
            ArrayList blockAggregateValues = _dynamicCache.GetFlowDocumentVisualListByType(typeof(InlineAggregateValue));       // walker.Walk<InlineAggregateValue>(_flowDocument);
            ArrayList charts = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IChart));                              // walker.Walk<IChart>(_flowDocument);
            ArrayList dynamicHeaderTableRows = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(ITableRowForDynamicHeader));
            ArrayList dynamicDataTableRows   = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(ITableRowForDynamicDataTable));


            List <Block> blocks = new List <Block>();

            if (_blockPageHeader != null)
            {
                blocks.Add(_blockPageHeader);
            }
            if (_blockPageFooter != null)
            {
                blocks.Add(_blockPageFooter);
            }

            DocumentWalker walker = new DocumentWalker();

            blockDocumentValues.AddRange(walker.TraverseBlockCollection <IInlineDocumentValue>(blocks));

            Dictionary <string, List <object> > aggregateValues = new Dictionary <string, List <object> >();

            FillCharts(charts);

            // fill report values
            foreach (IInlineDocumentValue dv in blockDocumentValues)
            {
                if (dv == null)
                {
                    continue;
                }
                object obj = null;
                if ((dv.PropertyName != null) && (_data.ReportDocumentValues.TryGetValue(dv.PropertyName, out obj)))
                {
                    dv.Value = obj;
                    RememberAggregateValue(aggregateValues, dv.AggregateGroup, obj);
                }
                else
                {
                    if ((_data.ShowUnknownValues) && (dv.Value == null))
                    {
                        dv.Value = "[" + ((dv.PropertyName != null) ? dv.PropertyName : "NULL") + "]";
                    }
                    RememberAggregateValue(aggregateValues, dv.AggregateGroup, null);
                }
            }


            // fill dynamic tables
            foreach (ITableRowForDynamicDataTable iTableRow in dynamicDataTableRows)
            {
                TableRow tableRow = iTableRow as TableRow;
                if (tableRow == null)
                {
                    continue;
                }

                TableRowGroup tableGroup = tableRow.Parent as TableRowGroup;
                if (tableGroup == null)
                {
                    continue;
                }

                TableRow currentRow = null;

                DataTable table = _data.GetDataTableByName(iTableRow.TableName);

                for (int i = 0; i < table.Rows.Count; i++)
                {
                    currentRow = new TableRow();

                    DataRow dataRow = table.Rows[i];
                    for (int j = 0; j < table.Columns.Count; j++)
                    {
                        string value = dataRow[j].ToString();
                        currentRow.Cells.Add(new TableCell(new Paragraph(new Run(value))));
                    }
                    tableGroup.Rows.Add(currentRow);
                }
            }

            foreach (ITableRowForDynamicHeader iTableRow in dynamicHeaderTableRows)
            {
                TableRow tableRow = iTableRow as TableRow;
                if (tableRow == null)
                {
                    continue;
                }

                DataTable table = _data.GetDataTableByName(iTableRow.TableName);

                foreach (DataRow row in table.Rows)
                {
                    string    value     = row[0].ToString();
                    TableCell tableCell = new TableCell(new Paragraph(new Run(value)));
                    tableRow.Cells.Add(tableCell);
                }
            }

            // fill tables
            foreach (ITableRowForDataTable iTableRow in blockTableRows)
            {
                TableRow tableRow = iTableRow as TableRow;
                if (tableRow == null)
                {
                    continue;
                }

                DataTable table = _data.GetDataTableByName(iTableRow.TableName);
                if (table == null)
                {
                    if (_data.ShowUnknownValues)
                    {
                        // show unknown values
                        foreach (TableCell cell in tableRow.Cells)
                        {
                            DocumentWalker         localWalker = new DocumentWalker();
                            List <ITableCellValue> tableCells  = localWalker.TraverseBlockCollection <ITableCellValue>(cell.Blocks);
                            foreach (ITableCellValue cv in tableCells)
                            {
                                IPropertyValue dv = cv as IPropertyValue;
                                if (dv == null)
                                {
                                    continue;
                                }
                                dv.Value = "[" + dv.PropertyName + "]";
                                IAggregateValue av = cv as IAggregateValue;
                                if (av != null)
                                {
                                    RememberAggregateValue(aggregateValues, av.AggregateGroup, null);
                                }
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    List <ITableCellValue> tableCells = new List <ITableCellValue>();
                    foreach (TableCell cell in tableRow.Cells)
                    {
                        DocumentWalker localWalker = new DocumentWalker();
                        tableCells.AddRange(localWalker.TraverseBlockCollection <ITableCellValue>(cell.Blocks));
                    }

                    TableRowGroup rowGroup = tableRow.Parent as TableRowGroup;
                    if (rowGroup == null)
                    {
                        throw new InvalidDataException("ReportTableRow must have a TableRowGroup as parent");
                    }

                    List <TableRow> listNewRows = new List <TableRow>();
                    foreach (TableRow row in rowGroup.Rows)
                    {
                        TableRowForDataTable reportTableRow = row as TableRowForDataTable;
                        if (reportTableRow == null)
                        {
                            // clone regular row
                            listNewRows.Add(XamlHelper.CloneTableRow(row));
                        }
                        else
                        {
                            string reportTableRowXaml = XamlWriter.Save(reportTableRow);

                            // clone ReportTableRows
                            List <TableRow> clonedTableRows = new List <TableRow>();
                            for (int i = 0; i < table.Rows.Count; i++)
                            {
                                clonedTableRows.Add((TableRow)XamlHelper.LoadXamlFromString(reportTableRowXaml));
                            }

                            foreach (DataRow dataRow in table.Rows)
                            {
                                // get cloned ReportTableRow
                                TableRow newTableRow = clonedTableRows[0];
                                clonedTableRows.RemoveAt(0);

                                foreach (TableCell cell in newTableRow.Cells)
                                {
                                    DocumentWalker         localWalker = new DocumentWalker();
                                    List <ITableCellValue> newCells    = localWalker.TraverseBlockCollection <ITableCellValue>(cell.Blocks);
                                    foreach (ITableCellValue cv in newCells)
                                    {
                                        IPropertyValue dv = cv as IPropertyValue;
                                        if (dv == null)
                                        {
                                            continue;
                                        }
                                        IAggregateValue av = cv as IAggregateValue;
                                        try
                                        {
                                            object obj = dataRow[dv.PropertyName];
                                            if (obj == DBNull.Value)
                                            {
                                                obj = null;
                                            }
                                            dv.Value = obj;

                                            if (av != null)
                                            {
                                                RememberAggregateValue(aggregateValues, av.AggregateGroup, obj);
                                            }
                                        }
                                        catch
                                        {
                                            if (_data.ShowUnknownValues)
                                            {
                                                dv.Value = "[" + dv.PropertyName + "]";
                                            }
                                            else
                                            {
                                                dv.Value = "";
                                            }
                                            if (av != null)
                                            {
                                                RememberAggregateValue(aggregateValues, av.AggregateGroup, null);
                                            }
                                        }
                                    }
                                }
                                listNewRows.Add(newTableRow);

                                // fire event
                                _report.FireEventDataRowBoundEventArgs(new DataRowBoundEventArgs(_report, dataRow)
                                {
                                    TableName = dataRow.Table.TableName, TableRow = newTableRow
                                });
                            }
                        }
                    }
                    rowGroup.Rows.Clear();
                    foreach (TableRow row in listNewRows)
                    {
                        rowGroup.Rows.Add(row);
                    }
                }
            }

            // fill aggregate values
            foreach (InlineAggregateValue av in blockAggregateValues)
            {
                if (String.IsNullOrEmpty(av.AggregateGroup))
                {
                    continue;
                }
                if (!aggregateValues.ContainsKey(av.AggregateGroup))
                {
                    av.Text = av.EmptyValue;
                }
                else
                {
                    av.Text = av.ComputeAndFormat(aggregateValues);
                }
            }
        }
Пример #41
0
 public FunctionValue(string name, IPropertyValue arguments, IEnumerable <Token> tokens)
 {
     _name      = name;
     _arguments = arguments;
     Original   = new TokenValue(tokens);
 }
Пример #42
0
 public TransformationValueConverter(IPropertyValue value, string[] labels)
 {
     _value  = value;
     _labels = labels;
 }
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 4:
                _propertySource = (IfcPropertySourceEnum)System.Enum.Parse(typeof(IfcPropertySourceEnum), value.EnumVal, true);
                return;

            case 5:
                _flowConditionTimeSeries = (IfcTimeSeries)(value.EntityVal);
                return;

            case 6:
                _velocityTimeSeries = (IfcTimeSeries)(value.EntityVal);
                return;

            case 7:
                _flowrateTimeSeries = (IfcTimeSeries)(value.EntityVal);
                return;

            case 8:
                _fluid = (IfcMaterial)(value.EntityVal);
                return;

            case 9:
                _pressureTimeSeries = (IfcTimeSeries)(value.EntityVal);
                return;

            case 10:
                _userDefinedPropertySource = value.StringVal;
                return;

            case 11:
                _temperatureSingleValue = value.RealVal;
                return;

            case 12:
                _wetBulbTemperatureSingleValue = value.RealVal;
                return;

            case 13:
                _wetBulbTemperatureTimeSeries = (IfcTimeSeries)(value.EntityVal);
                return;

            case 14:
                _temperatureTimeSeries = (IfcTimeSeries)(value.EntityVal);
                return;

            case 15:
                _flowrateSingleValue = (IfcDerivedMeasureValue)(value.EntityVal);
                return;

            case 16:
                _flowConditionSingleValue = value.RealVal;
                return;

            case 17:
                _velocitySingleValue = value.RealVal;
                return;

            case 18:
                _pressureSingleValue = value.RealVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Пример #44
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 5:
                _email = value.StringVal;
                return;

            case 6:
                _category = (CobieRole)(value.EntityVal);
                return;

            case 7:
                _company = value.StringVal;
                return;

            case 8:
                _phone = value.StringVal;
                return;

            case 9:
                _department = value.StringVal;
                return;

            case 10:
                _organizationCode = value.StringVal;
                return;

            case 11:
                _givenName = value.StringVal;
                return;

            case 12:
                _familyName = value.StringVal;
                return;

            case 13:
                _street = value.StringVal;
                return;

            case 14:
                _postalBox = value.StringVal;
                return;

            case 15:
                _town = value.StringVal;
                return;

            case 16:
                _stateRegion = value.StringVal;
                return;

            case 17:
                _postalCode = value.StringVal;
                return;

            case 18:
                _country = value.StringVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Пример #45
0
        private static T CoerceScalarValue <T>(PropertyType type, object value)
        {
            // If the property type is neither one of the coercable numeric types nor IInspectable, we
            // should not attempt coersion, even if the underlying value is technically convertable
            if (!IsCoercable(type, value) && type != PropertyType.Inspectable)
            {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", type, typeof(T).Name), __HResults.TYPE_E_TYPEMISMATCH);
            }

            try {
                // Try to coerce:
                //  * String <--> Guid
                //  * Numeric scalars
                if (type == PropertyType.String && typeof(T) == typeof(Guid))
                {
                    return((T)(object)Guid.Parse((string)value));
                }
                else if (type == PropertyType.Guid && typeof(T) == typeof(String))
                {
                    return((T)(object)((Guid)value).ToString("D", System.Globalization.CultureInfo.InvariantCulture));
                }
                else
                {
                    // Iterate over the numeric scalars, to see if we have a match for one of the known conversions
                    foreach (Tuple <Type, PropertyType> numericScalar in NumericScalarTypes)
                    {
                        if (numericScalar.Item1 == typeof(T))
                        {
                            return((T)Convert.ChangeType(value, typeof(T), System.Globalization.CultureInfo.InvariantCulture));
                        }
                    }
                }
            }
            catch (FormatException) {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", type, typeof(T).Name), __HResults.TYPE_E_TYPEMISMATCH);
            }
            catch (InvalidCastException) {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", type, typeof(T).Name), __HResults.TYPE_E_TYPEMISMATCH);
            }
            catch (OverflowException) {
                throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueCoersion", type, value, typeof(T).Name), __HResults.DISP_E_OVERFLOW);
            }

            // If the property type is IInspectable, and we have a nested IPropertyValue, then we need
            // to pass along the request to coerce the value.
            IPropertyValue ipv = value as IPropertyValue;

            if (type == PropertyType.Inspectable && ipv != null)
            {
                if (typeof(T) == typeof(Byte))
                {
                    return((T)(object)ipv.GetUInt8());
                }
                else if (typeof(T) == typeof(Int16))
                {
                    return((T)(object)ipv.GetInt16());
                }
                else if (typeof(T) == typeof(UInt16))
                {
                    return((T)(object)ipv.GetUInt16());
                }
                else if (typeof(T) == typeof(Int32))
                {
                    return((T)(object)ipv.GetUInt32());
                }
                else if (typeof(T) == typeof(UInt32))
                {
                    return((T)(object)ipv.GetUInt32());
                }
                else if (typeof(T) == typeof(Int64))
                {
                    return((T)(object)ipv.GetInt64());
                }
                else if (typeof(T) == typeof(UInt64))
                {
                    return((T)(object)ipv.GetUInt64());
                }
                else if (typeof(T) == typeof(Single))
                {
                    return((T)(object)ipv.GetSingle());
                }
                else if (typeof(T) == typeof(Double))
                {
                    return((T)(object)ipv.GetDouble());
                }
                else
                {
                    BCLDebug.Assert(false, "T in coersion function wasn't understood as a type that can be coerced - make sure that CoerceScalarValue and NumericScalarTypes are in sync");
                }
            }

            // Otherwise, this is an invalid coersion
            throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", type, typeof(T).Name), __HResults.TYPE_E_TYPEMISMATCH);
        }
Пример #46
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
                _documentId = value.StringVal;
                return;

            case 1:
                _name = value.StringVal;
                return;

            case 2:
                _description = value.StringVal;
                return;

            case 3:
                _documentReferences.InternalAdd((IfcDocumentReference)value.EntityVal);
                return;

            case 4:
                _purpose = value.StringVal;
                return;

            case 5:
                _intendedUse = value.StringVal;
                return;

            case 6:
                _scope = value.StringVal;
                return;

            case 7:
                _revision = value.StringVal;
                return;

            case 8:
                _documentOwner = (IfcActorSelect)(value.EntityVal);
                return;

            case 9:
                _editors.InternalAdd((IfcActorSelect)value.EntityVal);
                return;

            case 10:
                _creationTime = (IfcDateAndTime)(value.EntityVal);
                return;

            case 11:
                _lastRevisionTime = (IfcDateAndTime)(value.EntityVal);
                return;

            case 12:
                _electronicFormat = (IfcDocumentElectronicFormat)(value.EntityVal);
                return;

            case 13:
                _validFrom = (IfcCalendarDate)(value.EntityVal);
                return;

            case 14:
                _validUntil = (IfcCalendarDate)(value.EntityVal);
                return;

            case 15:
                _confidentiality = (IfcDocumentConfidentialityEnum)System.Enum.Parse(typeof(IfcDocumentConfidentialityEnum), value.EnumVal, true);
                return;

            case 16:
                _status = (IfcDocumentStatusEnum)System.Enum.Parse(typeof(IfcDocumentStatusEnum), value.EnumVal, true);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Пример #47
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 7:
                _torsionalConstantX = value.RealVal;
                return;

            case 8:
                _momentOfInertiaYZ = value.RealVal;
                return;

            case 9:
                _momentOfInertiaY = value.RealVal;
                return;

            case 10:
                _momentOfInertiaZ = value.RealVal;
                return;

            case 11:
                _warpingConstant = value.RealVal;
                return;

            case 12:
                _shearCentreZ = value.RealVal;
                return;

            case 13:
                _shearCentreY = value.RealVal;
                return;

            case 14:
                _shearDeformationAreaZ = value.RealVal;
                return;

            case 15:
                _shearDeformationAreaY = value.RealVal;
                return;

            case 16:
                _maximumSectionModulusY = value.RealVal;
                return;

            case 17:
                _minimumSectionModulusY = value.RealVal;
                return;

            case 18:
                _maximumSectionModulusZ = value.RealVal;
                return;

            case 19:
                _minimumSectionModulusZ = value.RealVal;
                return;

            case 20:
                _torsionalSectionModulus = value.RealVal;
                return;

            case 21:
                _centreOfGravityInX = value.RealVal;
                return;

            case 22:
                _centreOfGravityInY = value.RealVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Пример #48
0
 public abstract void Parse(int propIndex, IPropertyValue value, int[] nested);
Пример #49
0
 // allows us to swich between published / edited easier.
 protected virtual object GetPropertyValue(IPropertyValue value)
 => value.EditedValue;
Пример #50
0
 /// <inheritdoc />
 public void SetValue(IPropertyValue propertyValue) =>
 DoOnLock(() => _propertyContainer.SetValue(propertyValue));
Пример #51
0
 /// <inheritdoc />
 public void Add(IPropertyValue propertyValue) =>
 DoOnLock(() => _propertyContainer.Add(propertyValue));
Пример #52
0
        private WActorNode LoadActorFromChunk(string fourCC, MapActorDescriptor template)
        {
            var newActor = new WActorNode(fourCC, m_world);
            List <IPropertyValue> actorProperties = new List <IPropertyValue>();

            foreach (var field in template.Fields)
            {
                IPropertyValue propValue = null;

                switch (field.FieldType)
                {
                case PropertyValueType.Byte:
                    propValue = new TBytePropertyValue(m_reader.ReadByte(), field.FieldName);
                    break;

                case PropertyValueType.Bool:
                    propValue = new TBoolPropertyValue(m_reader.ReadBoolean(), field.FieldName);
                    break;

                case PropertyValueType.Short:
                    propValue = new TShortPropertyValue(m_reader.ReadInt16(), field.FieldName);
                    break;

                case PropertyValueType.Int:
                    propValue = new TIntPropertyValue(m_reader.ReadInt32(), field.FieldName);
                    break;

                case PropertyValueType.Float:
                    propValue = new TFloatPropertyValue(m_reader.ReadSingle(), field.FieldName);
                    break;

                case PropertyValueType.FixedLengthString:
                case PropertyValueType.String:
                    string stringVal = (field.Length == 0) ? m_reader.ReadStringUntil('\0') : m_reader.ReadString(field.Length);
                    stringVal = stringVal.Trim(new[] { '\0' });
                    propValue = new TStringPropertyValue(stringVal, field.FieldName);
                    break;

                case PropertyValueType.Vector2:
                    propValue = new TVector2PropertyValue(new OpenTK.Vector2(m_reader.ReadSingle(), m_reader.ReadSingle()), field.FieldName);
                    break;

                case PropertyValueType.Vector3:
                    propValue = new TVector3PropertyValue(new OpenTK.Vector3(m_reader.ReadSingle(), m_reader.ReadSingle(), m_reader.ReadSingle()), field.FieldName);
                    break;

                case PropertyValueType.XRotation:
                case PropertyValueType.YRotation:
                case PropertyValueType.ZRotation:
                    propValue = new TShortPropertyValue(m_reader.ReadInt16(), field.FieldName);
                    break;

                case PropertyValueType.Color24:
                    propValue = new TLinearColorPropertyValue(new WLinearColor(m_reader.ReadByte() / 255f, m_reader.ReadByte() / 255f, m_reader.ReadByte() / 255f), field.FieldName);
                    break;

                case PropertyValueType.Color32:
                    propValue = new TLinearColorPropertyValue(new WLinearColor(m_reader.ReadByte() / 255f, m_reader.ReadByte() / 255f, m_reader.ReadByte() / 255f, m_reader.ReadByte() / 255f), field.FieldName);
                    break;

                default:
                    Console.WriteLine("Unsupported PropertyValueType: {0}", field.FieldType);
                    break;
                }

                propValue.SetUndoStack(m_world.UndoStack);
                actorProperties.Add(propValue);
            }

            // Now that we have loaded all properties out of it, we need to post-process them.
            IPropertyValue positionProperty = actorProperties.Find(x => x.Name == "Position");
            IPropertyValue xRotProperty     = actorProperties.Find(x => x.Name == "X Rotation");
            IPropertyValue yRotProperty     = actorProperties.Find(x => x.Name == "Y Rotation");
            IPropertyValue zRotProperty     = actorProperties.Find(x => x.Name == "Z Rotation");
            IPropertyValue xScaleProperty   = actorProperties.Find(x => x.Name == "X Scale");
            IPropertyValue yScaleProperty   = actorProperties.Find(x => x.Name == "Y Scale");
            IPropertyValue zScaleProperty   = actorProperties.Find(x => x.Name == "Z Scale");

            // Remove these properties from the actor so they don't get added to the UI.
            actorProperties.Remove(positionProperty);
            actorProperties.Remove(xRotProperty);
            actorProperties.Remove(yRotProperty);
            actorProperties.Remove(zRotProperty);
            actorProperties.Remove(xScaleProperty);
            actorProperties.Remove(yScaleProperty);
            actorProperties.Remove(zScaleProperty);

            if (positionProperty != null)
            {
                newActor.Transform.Position = (Vector3)positionProperty.GetValue();
            }

            float xRot = 0, yRot = 0, zRot = 0;

            if (xRotProperty != null)
            {
                xRot = WMath.RotationShortToFloat((short)xRotProperty.GetValue());
            }
            if (yRotProperty != null)
            {
                yRot = WMath.RotationShortToFloat((short)yRotProperty.GetValue());
            }
            if (zRotProperty != null)
            {
                zRot = WMath.RotationShortToFloat((short)zRotProperty.GetValue());
            }

            // Build rotation with ZYX order.
            Quaternion xRotQ = Quaternion.FromAxisAngle(new Vector3(1, 0, 0), WMath.DegreesToRadians(xRot));
            Quaternion yRotQ = Quaternion.FromAxisAngle(new Vector3(0, 1, 0), WMath.DegreesToRadians(yRot));
            Quaternion zRotQ = Quaternion.FromAxisAngle(new Vector3(0, 0, 1), WMath.DegreesToRadians(zRot));

            newActor.Transform.Rotation = zRotQ * yRotQ * xRotQ;

            float xScale = 1, yScale = 1, zScale = 1;

            if (xScaleProperty != null)
            {
                xScale = ((byte)xScaleProperty.GetValue()) / 10f;
            }
            if (yScaleProperty != null)
            {
                yScale = ((byte)yScaleProperty.GetValue()) / 10f;
            }
            if (zScaleProperty != null)
            {
                zScale = ((byte)zScaleProperty.GetValue()) / 10f;
            }

            newActor.Transform.LocalScale = new Vector3(xScale, yScale, zScale);

            newActor.Properties.AddRange(actorProperties);
            newActor.PostFinishedLoad();
            return(newActor);
        }
Пример #53
0
 public Variable(string name, IPropertyValue value)
 {
     Name  = name;
     Value = value;
 }
Пример #54
0
        public bool Equals(IPropertyValue other)
        {
            var b = other as Bool;

            return(b != null && Value == b.Value);
        }
        static private object CoerceScalarValue(PropertyType type, object value, PropertyType unboxType)
        {
            // If the property type is neither one of the coercable numeric types nor IInspectable, we
            // should not attempt coersion, even if the underlying value is technically convertable
            if ((type == PropertyType.Guid) && (unboxType == PropertyType.String))
            {
                // String <--> Guid is allowed
                return(((System.Guid)value).ToString());
            }
            else if ((type == PropertyType.String) && (unboxType == PropertyType.Guid))
            {
                System.Guid result;

                if (System.Guid.TryParse((string)value, out result))
                {
                    return(result);
                }
            }
            else if (type == PropertyType.Inspectable)
            {
                // If the property type is IInspectable, and we have a nested IPropertyValue, then we need
                // to pass along the request to coerce the value.
                IPropertyValue ipv = value as IPropertyValue;

                if (ipv != null)
                {
                    object result = ReferenceUtility.GetWellKnownScalar(ipv, unboxType);

                    if (result != null)
                    {
                        return(result);
                    }

                    Debug.Assert(
                        false,
                        "T in coersion function wasn't understood as a type that can be coerced - make sure that CoerceScalarValue and NumericScalarTypes are in sync"
                        );
                }
            }
            else if (type == PropertyType.Boolean || type == PropertyType.Char16)
            {
                throw CreateExceptionForInvalidCoersion(type, value, unboxType, Interop.COM.TYPE_E_TYPEMISMATCH);
            }

            //
            // Let Convert handle all possible conversions - this include
            // 1. string - which desktop code accidentally allowed
            // 2. object (IInspectable)
            //
            try
            {
                switch (unboxType)
                {
                case PropertyType.UInt8:
                    return(System.Convert.ToByte(value));

                case PropertyType.Int16:
                    return(System.Convert.ToInt16(value));

                case PropertyType.UInt16:
                    return(System.Convert.ToUInt16(value));

                case PropertyType.Int32:
                    return(System.Convert.ToInt32(value));

                case PropertyType.UInt32:
                    return(System.Convert.ToUInt32(value));

                case PropertyType.Int64:
                    return(System.Convert.ToInt64(value));

                case PropertyType.UInt64:
                    return(System.Convert.ToUInt64(value));

                case PropertyType.Single:
                    return(System.Convert.ToSingle(value));

                case PropertyType.Double:
                    return(System.Convert.ToDouble(value));

                default:
                    break;
                }
            }
            catch (System.FormatException)
            {
                throw CreateExceptionForInvalidCoersion(type, value, unboxType, Interop.COM.TYPE_E_TYPEMISMATCH);
            }
            catch (System.InvalidCastException)
            {
                throw CreateExceptionForInvalidCoersion(type, value, unboxType, Interop.COM.TYPE_E_TYPEMISMATCH);
            }
            catch (System.OverflowException)
            {
                throw CreateExceptionForInvalidCoersion(type, value, unboxType, Interop.COM.DISP_E_OVERFLOW);
            }

            throw CreateExceptionForInvalidCast(type, unboxType);
        }
        private static IPropertyContainer?ParseXmlElement(
            XElement objectElement,
            IObjectSchema objectSchema,
            IXmlParserSettings settings,
            IXmlParserContext context,
            IMutablePropertyContainer?container = null)
        {
            if (objectElement.HasElements)
            {
                container ??= new MutablePropertyContainer();

                foreach (XElement propertyElement in objectElement.Elements())
                {
                    string    elementName  = settings.GetElementName(propertyElement);
                    string    propertyName = settings.StringProvider.GetString(elementName);
                    IProperty?property     = objectSchema.GetProperty(propertyName);

                    if (propertyElement.HasElements)
                    {
                        IObjectSchema propertyInternalSchema = context.GetOrCreateNewSchemaCached(property).ToObjectSchema();

                        IPropertyContainer?internalObject = ParseXmlElement(propertyElement, propertyInternalSchema, settings, context);
                        if (internalObject != null && internalObject.Count > 0)
                        {
                            if (settings.SetSchemaForObjects)
                            {
                                internalObject.SetSchema(propertyInternalSchema);
                            }

                            if (property == null)
                            {
                                property = new Property <IPropertyContainer>(propertyName)
                                           .SetIsNotFromSchema()
                                           .SetSchema(propertyInternalSchema);

                                if (objectSchema is IMutableObjectSchema mutableObjectSchema)
                                {
                                    property = mutableObjectSchema.AddProperty(property);
                                }
                            }

                            IPropertyValue propertyValue = settings.PropertyValueFactory.CreateUntyped(property, internalObject);
                            container.Add(propertyValue);

                            // Validate property.
                            if (settings.ValidateOnParse)
                            {
                                ValidateProperty(context, container, property, propertyElement);
                            }
                        }
                    }
                    else
                    {
                        if (property != null && property.Type == typeof(IPropertyContainer))
                        {
                            // Composite object, no value.
                            bool isNullAllowed = property.GetOrEvaluateNullability().IsNullAllowed;
                            if (!isNullAllowed)
                            {
                                context.Messages.AddError(
                                    $"Property '{property.Name}' can not be null but xml element has no value.{GetXmlLineInfo(propertyElement)}");
                            }

                            continue;
                        }

                        if (property == null)
                        {
                            property = new Property <string>(propertyName)
                                       .SetIsNotFromSchema();

                            if (objectSchema is IMutableObjectSchema mutableObjectSchema)
                            {
                                property = mutableObjectSchema.AddProperty(property);
                            }
                        }

                        IValueParser valueParser = context.GetParserCached(property);
                        if (valueParser != EmptyParser.Instance)
                        {
                            string elementValue = propertyElement.Value;

                            // Parse value.
                            IParseResult parseResult = valueParser.ParseUntyped(elementValue);

                            if (parseResult.IsSuccess)
                            {
                                // Add property to container.
                                object?        parsedValue   = parseResult.ValueUntyped;
                                IPropertyValue propertyValue = settings.PropertyValueFactory.CreateUntyped(property, parsedValue);
                                container.Add(propertyValue);

                                // Validate property.
                                if (settings.ValidateOnParse)
                                {
                                    ValidateProperty(context, container, property, propertyElement);
                                }
                            }
                            else
                            {
                                string?parseResultErrorMessage = parseResult.Error?.FormattedMessage;
                                string parseResultError        = parseResultErrorMessage != null ? $" Error: '{parseResultErrorMessage}'." : string.Empty;
                                string errorMessage            = $"Property '{property.Name}' failed to parse from string '{elementValue}'.{parseResultError}{GetXmlLineInfo(propertyElement)}";
                                context.Messages.AddError(errorMessage);
                            }
                        }
                        else
                        {
                            string errorMessage = $"Property '{property.Name}' can not be parsed because no parser found for type {property.Type}.{GetXmlLineInfo(propertyElement)}";
                            context.Messages.AddError(errorMessage);
                        }
                    }
                }

                return(container);
            }

            return(null);
        }
Пример #57
0
        //public ParameterSetter ParameterSetter
        //{
        //    get
        //    {
        //        //if (RequiredParameters == null || RequiredParameters.Contains(CurrentParamIndex))
        //            return Entity.Parse;
        //        //else
        //        //    return ParameterEater;
        //    }
        //}

        private void ParameterEater(int i, IPropertyValue v, int[] nestedIndex)
        {
        }
 IPropertyValue CreateFrom(IPropertyValue value, IEnumerable <CssToken> tokens)
 {
     return(value != null ? new StartValue(_data, value, tokens) : null);
 }
Пример #59
0
 private void ParameterEater(int i, IPropertyValue v)
 {
 }
Пример #60
0
 public BorderRadiusValue(IPropertyValue horizontal, IPropertyValue vertical, TokenValue original)
 {
     _horizontal = horizontal;
     _vertical   = vertical;
     Original    = original;
 }