Example #1
0
        protected virtual String ParseValue(Value value) {
            String parsed = "";

            DateTimeValue dateTime = value as DateTimeValue;
            NumericValue numeric = value as NumericValue;
            StringValue @string = value as StringValue;
            RawValue raw = value as RawValue;

            if (dateTime != null) {
                parsed = String.Format(@"""{0}""", dateTime.Data.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            }
            else if (numeric != null) {
                if (numeric.Long.HasValue == true) {
                    parsed = numeric.Long.Value.ToString(CultureInfo.InvariantCulture);
                }
                else if (numeric.Double.HasValue == true) {
                    parsed = numeric.Double.Value.ToString(CultureInfo.InvariantCulture);
                }
            }
            else if (@string != null) {
                // Note that the string should have been parsed by the driver to escape it.
                parsed = String.Format(@"""{0}""", @string.Data);
            }
            else if (raw != null) {
                parsed = raw.Data;
            }

            return parsed;
        }
Example #2
0
        protected virtual Object ParseValue(Value value) {
            Object parsed = null;

            DateTimeValue dateTime = value as DateTimeValue;
            NumericValue numeric = value as NumericValue;
            StringValue @string = value as StringValue;
            RawValue raw = value as RawValue;

            if (dateTime != null) {
                parsed = dateTime.Data; // String.Format(@"""{0}""", dateTime.Data.ToString("s"));
            }
            else if (numeric != null) {
                if (numeric.Long.HasValue == true) {
                    parsed = numeric.Long.Value.ToString(CultureInfo.InvariantCulture);
                }
                else if (numeric.Double.HasValue == true) {
                    parsed = numeric.Double.Value.ToString(CultureInfo.InvariantCulture);
                }
            }
            else if (@string != null) {
                parsed = @string.Data;
            }
            else if (raw != null) {
                parsed = raw.Data;
            }

            return parsed;
        }