Esempio n. 1
0
        public override object CreateValue(ISymbol symbol, byte[] rawData, int offset, IValue parent)
        {
            object          obj2     = null;
            IDataType       dataType = symbol.DataType;
            IResolvableType type2    = symbol.DataType as IResolvableType;

            if (type2 != null)
            {
                dataType = type2.ResolveType(DataTypeResolveStrategy.AliasReference);
            }
            if (base.mode.HasFlag(ValueCreationMode.FullDynamics) || !dataType.IsPrimitive)
            {
                if (!symbol.IsReference)
                {
                    obj2 = !symbol.IsPointer ? new DynamicValue((IDynamicSymbol)symbol, rawData, offset, (DynamicValue)parent) : new DynamicPointerValue((IDynamicSymbol)symbol, rawData, offset, (DynamicValue)parent);
                }
                else
                {
                    byte[]   buffer;
                    DateTime time;
                    IAccessorDynamicValue accessor = base.accessor as IAccessorDynamicValue;
                    if ((accessor != null) && (accessor.TryReadValue(symbol, out buffer, out time) == 0))
                    {
                        obj2 = new DynamicReferenceValue((IDynamicSymbol)symbol, buffer, 0, (DynamicValue)parent);
                    }
                }
            }
            else if ((dataType.Category == DataTypeCategory.Enum) && base.mode.HasFlag(ValueCreationMode.Enums))
            {
                obj2 = EnumValueFactory.Create((IEnumType)dataType, rawData, offset);
            }
            else if (base.mode.HasFlag(ValueCreationMode.Default))
            {
                base.valueConverter.Unmarshal(symbol, rawData, offset, out obj2);
            }
            else
            {
                obj2 = new DynamicValue((IDynamicSymbol)symbol, rawData, offset, (DynamicValue)parent);
            }
            return(obj2);
        }