public override void ValueFromConst(Parser.ValueType val) { if (val.TypeHint == Parser.ConstType.String) { Data = new[] { DateTime.ParseExact( ProtocolFormatter.UnescapeStringValue(val.StringValue), new[] { "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss.f", "yyyy-MM-dd HH:mm:ss.ff", "yyyy-MM-dd HH:mm:ss.fff", "yyyy-MM-dd HH:mm:ss.ffff", "yyyy-MM-dd HH:mm:ss.fffff", "yyyy-MM-dd HH:mm:ss.ffffff", "yyyy-MM-dd HH:mm:ss.fffffff" }, null, DateTimeStyles.AssumeUniversal ) } } ; else { throw new InvalidCastException("Cannot convert numeric value to DateTime."); } }
public override void ValueFromConst(Parser.ValueType val) { if (val.TypeHint == Parser.ConstType.String) { Data = new[] { Guid.Parse(val.StringValue.Replace("'", "")) } } ; else { throw new InvalidCastException("Cannot convert non-string value to Guid."); } }
public override void ValueFromConst(Parser.ValueType val) { if (val.TypeHint == Parser.ConstType.String) { var uvalue = ProtocolFormatter.UnescapeStringValue(val.StringValue); Data = new[] { Values.First(x => x.Item1 == uvalue).Item2 }; } else { Data = new[] { int.Parse(val.StringValue) } }; }
public override void ValueFromConst(Parser.ValueType val) { if (val.TypeHint == Parser.ConstType.String) { var uvalue = ProtocolFormatter.UnescapeStringValue(val.StringValue); Data = new[] { uvalue }; } else { Data = new[] { val.StringValue } }; }
public override void ValueFromConst(Parser.ValueType val) { if (val.TypeHint == Parser.ConstType.Array) { InnerType.ValuesFromConst(val.ArrayValue.Select(x => Convert.ChangeType(x.StringValue, InnerType.CLRType))); Offsets.ValueFromConst(new Parser.ValueType { TypeHint = Parser.ConstType.Number, StringValue = InnerType.Rows.ToString() }); } else { throw new NotSupportedException(); } }
public override void ValueFromConst(Parser.ValueType val) { switch (val.TypeHint) { case Parser.ConstType.String: Data = new[] { new Guid(val.StringValue) }; break; default: throw new InvalidCastException("Cannot convert numeric value to Guid."); } }
public override void ValueFromConst(Parser.ValueType val) { switch (val.TypeHint) { case Parser.ConstType.String: { var uvalue = ProtocolFormatter.UnescapeStringValue(val.StringValue); Data = new[] {uvalue}; break; } default: Data = new[] {val.StringValue}; break; } }
public override void ValueFromConst(Parser.ValueType val) { switch (val.TypeHint) { case Parser.ConstType.String: { var uvalue = ProtocolFormatter.UnescapeStringValue(val.StringValue); Data = new[] { Values.First(x => x.Item1 == uvalue).Item2 }; break; } default: Data = new[] { int.Parse(val.StringValue) }; break; } }
public override void ValueFromConst(Parser.ValueType val) { switch (val.TypeHint) { case Parser.ConstType.String: Data = new[] { DateTime.ParseExact(ProtocolFormatter.UnescapeStringValue(val.StringValue), "yyyy-MM-dd", null, DateTimeStyles.AssumeUniversal) }; break; default: throw new InvalidCastException("Cannot convert numeric value to Date."); } }
public override void ValueFromConst(Parser.ValueType val) { if (val.TypeHint == Parser.ConstType.String) { Data = new[] { (T)Convert.ChangeType(ProtocolFormatter.UnescapeStringValue(val.StringValue), typeof(T)) } } ; else if (val.TypeHint == Parser.ConstType.Number) { Data = new[] { (T)Convert.ChangeType(val.StringValue, typeof(T)) } } ; else { throw new NotSupportedException(); } }
public override void ValueFromConst(Parser.ValueType val) { switch (val.TypeHint) { case Parser.ConstType.String: Data = new[] { IPAddress.Parse(val.StringValue) }; break; case Parser.ConstType.Number: byte[] rawIPAddress = BitConverter.GetBytes(Convert.ToUInt32(val.StringValue)).Reverse().ToArray(); Data = new[] { new IPAddress(rawIPAddress) }; break; default: throw new NotSupportedException(); } }
public override void ValueFromConst(Parser.ValueType val) { switch (val.TypeHint) { case Parser.ConstType.String: var match = Regex.Match(val.StringValue, @"'(?<value>[0-9A-F]{8}([-][0-9A-F]{4}){3}[-][0-9A-F]{12})'", RegexOptions.IgnoreCase); if (match.Success) { Data = new[] { new Guid(match.Groups["value"].Value) } } ; break; default: throw new InvalidCastException("Cannot convert numeric value to Guid."); } }
public override void ValueFromConst(Parser.ValueType val) { switch (val.TypeHint) { case Parser.ConstType.String: Data = new[] { (decimal)Convert.ChangeType(ProtocolFormatter.UnescapeStringValue(val.StringValue), typeof(decimal)) }; break; case Parser.ConstType.Number: Data = new[] { (decimal)Convert.ChangeType(val.StringValue, typeof(decimal)) }; break; default: throw new NotSupportedException(); } }
public override void ValueFromConst(Parser.ValueType val) { if (_doubleFallback) { if (val.TypeHint == Parser.ConstType.String) { DataDouble = new[] { (double)Convert.ChangeType(ProtocolFormatter.UnescapeStringValue(val.StringValue), typeof(double)) } } ; else if (val.TypeHint == Parser.ConstType.Number) { DataDouble = new[] { (double)Convert.ChangeType(val.StringValue, typeof(double)) } } ; else { throw new NotSupportedException(); } } else { if (val.TypeHint == Parser.ConstType.String) { DataDecimal = new[] { (decimal)Convert.ChangeType(ProtocolFormatter.UnescapeStringValue(val.StringValue), typeof(decimal)) } } ; else if (val.TypeHint == Parser.ConstType.Number) { DataDecimal = new[] { (decimal)Convert.ChangeType(val.StringValue, typeof(decimal)) } } ; else { throw new NotSupportedException(); } } }
public override void ValueFromConst(Parser.ValueType val) { }
public override void ValueFromConst(Parser.ValueType val) { throw new NotSupportedException(); }
//public abstract void ValueFromConst(string value, Parser.ConstType typeHint); public abstract void ValueFromConst(Parser.ValueType val);
public override void ValueFromConst(Parser.ValueType val) { Nulls = new[] { val.StringValue == null && val.ArrayValue == null }; InnerType.ValueFromConst(val); }