Example #1
0
        public object GetValue(DataType dt, int dimension)
        {
            if (dimension == 1)
            {
                switch (dt)
                {
                case DataType.Bool: return(this.GetBool());

                case DataType.Byte: return(this.GetByte());

                case DataType.SByte: return(this.GetSByte());

                case DataType.Int16: return(this.GetShort());

                case DataType.UInt16: return(this.GetUShort());

                case DataType.Int32: return(this.GetInt());

                case DataType.UInt32: return(this.GetUInt());

                case DataType.Int64: return(this.GetLong());

                case DataType.UInt64: return(this.GetULong());

                case DataType.Float32: return(this.GetFloat());

                case DataType.Float64: return(this.GetDouble());

                case DataType.String: return(this.GetString());

                case DataType.ObjectRef: return(ObjectRef.FromEncodedString(this.GetString()));

                case DataType.LocationRef: return(LocationRef.FromLocationID(this.GetString()));

                case DataType.URI: return(new Uri(this.GetString()));

                case DataType.Enum: return(this.GetString());

                case DataType.JSON: return(this);

                case DataType.Guid: return(Guid.Parse(this.GetString()));

                case DataType.NamedValue: return(this.Object <NamedValue>());

                case DataType.LocalDate: return(LocalDate.FromISO8601(this.GetString()));

                case DataType.LocalTime: return(LocalTime.FromISO8601(this.GetString()));

                case DataType.LocalDateTime: return(LocalDateTime.FromISO8601(this.GetString()));

                case DataType.Timestamp: return(Timestamp.FromISO8601(this.GetString()));

                case DataType.Duration: return(Duration.Parse(this.GetString()));

                case DataType.Struct: return(json);
                }
            }
            else
            {
                switch (dt)
                {
                case DataType.Bool: return(this.GetBoolArray());

                case DataType.Byte: return(this.GetByteArray());

                case DataType.SByte: return(this.GetSByteArray());

                case DataType.Int16: return(this.GetShortArray());

                case DataType.UInt16: return(this.GetUShortArray());

                case DataType.Int32: return(this.GetIntArray());

                case DataType.UInt32: return(this.GetUIntArray());

                case DataType.Int64: return(this.GetLongArray());

                case DataType.UInt64: return(this.GetULongArray());

                case DataType.Float32: return(this.GetFloatArray());

                case DataType.Float64: return(this.GetDoubleArray());

                case DataType.String: return(this.GetStringArray());

                case DataType.ObjectRef: return(this.GetStringArray().Select(ObjectRef.FromEncodedString).ToArray());

                case DataType.LocationRef: return(this.GetStringArray().Select(LocationRef.FromLocationID).ToArray());

                case DataType.URI: return(this.GetStringArray().Select(x => new Uri(x)).ToArray());

                case DataType.Enum: return(this.GetStringArray());

                case DataType.JSON: return(this);    // TODO return DataValue[]

                case DataType.Guid: return(this.GetStringArray().Select(Guid.Parse).ToArray());

                case DataType.NamedValue: return(this.Object <NamedValue[]>());

                case DataType.LocalDate: return(this.GetStringArray().Select(LocalDate.FromISO8601).ToArray());

                case DataType.LocalTime: return(this.GetStringArray().Select(LocalTime.FromISO8601).ToArray());

                case DataType.LocalDateTime: return(this.GetStringArray().Select(LocalDateTime.FromISO8601).ToArray());

                case DataType.Timestamp: return(this.GetStringArray().Select(Timestamp.FromISO8601).ToArray());

                case DataType.Duration: return(this.GetStringArray().Select(Duration.Parse).ToArray());

                case DataType.Struct: return(json);
                }
            }
            return(null);
        }
Example #2
0
 public static LocalDateTime FromDateAndTime(LocalDate date, LocalTime time) => date + time;