// Return a String representation of JSValue. // Null is "null". // Object and Array are empty strings "". // Boolean is "true" or "false". // Int64 is converted to string using integer representation. // Double uses AsJSString() conversion which uses "NaN", "Infinity", and "-Infinity" for special values. public string AsString() { switch (Type) { case JSValueType.Null: return(JSConverter.NullString); case JSValueType.String: return(StringValue); case JSValueType.Boolean: return(JSConverter.ToJSString(BooleanValue)); case JSValueType.Int64: return(Int64Value.ToString()); case JSValueType.Double: return(JSConverter.ToJSString(DoubleValue)); default: return(""); } }
public override string ToString() { switch (Type) { case SQLiteColumnType.BLOB: return("0x" + Conversions.ToHexa(BlobValue)); case SQLiteColumnType.REAL: return(DoubleValue.ToString(CultureInfo.CurrentCulture)); case SQLiteColumnType.INTEGER: return(Int64Value.ToString(CultureInfo.CurrentCulture)); case SQLiteColumnType.NULL: return("<NULL>"); default: return(StringValue); } }
static Constants() { BoolValue = true; DateTimeValue = DateTime.Parse(DateTime.MaxValue.ToString(), CultureInfo.InvariantCulture); DecimalValue = Decimal.MaxValue; GuidValue = Guid.NewGuid(); Int16Value = Int16.MaxValue; Int32Value = Int32.MaxValue; Int64Value = Int64.MaxValue; StringValue = Guid.NewGuid().ToString(); NullableInt64Value = Int64.MaxValue; BoolStringValue = BoolValue.ToString(); DateTimeStringValue = DateTimeValue.ToString(); DecimalStringValue = DecimalValue.ToString(); GuidStringValue = GuidValue.ToString(); Int16StringValue = Int16Value.ToString(); Int32StringValue = Int32Value.ToString(); Int64StringValue = Int64Value.ToString(); NullableInt64StringValue = NullableInt64Value.ToString(); }
/// <summary> /// Returns a System.String that represents the current PropVariant. /// </summary> /// <returns>A System.String that represents the current PropVariant.</returns> public override string ToString() { return("[" + Value + "] " + Int64Value.ToString(CultureInfo.CurrentCulture)); }
// Convert JSValue to a readable string that can be used for logging and debugging. public override string ToString() { switch (Type) { case JSValueType.Null: return(JSConverter.NullString); case JSValueType.Object: { var sb = new StringBuilder(); sb.Append("{"); bool start = true; foreach (var prop in ObjectValue) { if (start) { start = false; } else { sb.Append(", "); } sb.Append(prop.Key); sb.Append(": "); sb.Append(prop.Value.ToString()); } sb.Append("}"); return(sb.ToString()); } case JSValueType.Array: { var sb = new StringBuilder(); sb.Append("["); bool start = true; foreach (var item in ArrayValue) { if (start) { start = false; } else { sb.Append(", "); } sb.Append(item.ToString()); } sb.Append("]"); return(sb.ToString()); } case JSValueType.String: return("\"" + StringValue + "\""); case JSValueType.Boolean: return(JSConverter.ToJSString(BooleanValue)); case JSValueType.Int64: return(Int64Value.ToString()); case JSValueType.Double: return(JSConverter.ToJSString(DoubleValue)); default: return("<Unexpected>"); } }
// Return a String representation of JSValue. It is equivalent to JavaScript String(value) result. public string AsJSString() { StringBuilder WriteValue(StringBuilder sb, JSValue node) { switch (node.Type) { case JSValueType.Null: return(sb.Append(JSConverter.NullString)); case JSValueType.Object: return(sb.Append(JSConverter.ObjectString)); case JSValueType.Array: { bool start = true; foreach (var item in node.ArrayValue) { if (start) { start = false; } else { sb.Append(','); } WriteValue(sb, item); } return(sb); } case JSValueType.String: return(sb.Append(node.StringValue)); case JSValueType.Boolean: return(sb.Append(JSConverter.ToJSString(node.BooleanValue))); case JSValueType.Int64: return(sb.Append(node.Int64Value)); case JSValueType.Double: return(sb.Append(JSConverter.ToJSString(node.DoubleValue))); default: return(sb); } } switch (Type) { case JSValueType.Null: return(JSConverter.NullString); case JSValueType.Object: return(JSConverter.ObjectString); case JSValueType.Array: { StringBuilder sb = new StringBuilder(); WriteValue(sb, this); return(sb.ToString()); } case JSValueType.String: return(StringValue); case JSValueType.Boolean: return(JSConverter.ToJSString(BooleanValue)); case JSValueType.Int64: return(Int64Value.ToString()); case JSValueType.Double: return(JSConverter.ToJSString(DoubleValue)); default: return(""); } }