public void PutString(string str) { if (BeingBuilt == null) { BeingBuilt = JsonObject.ForString(str, Options); } else { BeingBuilt.Put(JsonObject.ForString(str, Options)); } }
internal void Put(JsonObject other) { switch (Type) { case JsonObjectType.Array: ArrayValue.Add(other); return; case JsonObjectType.ObjectMember: if (MemberPart1 == null) { MemberPart1 = other; } else { if (MemberPart2 == null) { MemberPart2 = other; this.Parent.ObjectMembers.Add(MemberPart1.StringValue, MemberPart2); } else { throw new InvalidOperationException(); } } return; } throw new InvalidOperationException(); }
public void PutFalse() { if (BeingBuilt == null) { BeingBuilt = JsonObject.False; } else { BeingBuilt.Put(JsonObject.False); } }
public void PutTrue() { if (BeingBuilt == null) { BeingBuilt = JsonObject.True; } else { BeingBuilt.Put(JsonObject.True); } }
public void PutFastNumber(bool negative, ulong beforeDot, ulong afterDot, byte afterDotLength, long afterE) { var num = JsonObject.ForFastNumber(negative, beforeDot, afterDot, afterDotLength, afterE, Options); if (BeingBuilt == null) { BeingBuilt = num; } else { BeingBuilt.Put(num); } }
public void StartArray() { var arr = JsonObject.NewArray(BeingBuilt); if (BeingBuilt == null) { BeingBuilt = arr; } else { BeingBuilt.Put(arr); BeingBuilt = arr; } }
internal static JsonObject NewObjectMember(JsonObject parent) { return new JsonObject { Type = JsonObjectType.ObjectMember, Parent = parent }; }
internal static JsonObject NewObject(JsonObject parent) { return new JsonObject { Type = JsonObjectType.Object, Parent = parent, ObjectMembers = new Dictionary<string, JsonObject>() }; }
internal static JsonObject NewArray(JsonObject parent) { return new JsonObject { Type = JsonObjectType.Array, Parent = parent, ArrayValue = new List<JsonObject>() }; }
public JsonMetaObject(JsonObject outer, Expression exp) : base(exp, BindingRestrictions.Empty, outer) { }
bool _InnerTryUnaryOperation(ExpressionType operand, Type returnType, out object result) { switch(operand) { case ExpressionType.IsFalse: if(!returnType.IsAssignableFrom(typeof(bool))) { result = null; return false; } result = Type == JsonObjectType.False; return true; case ExpressionType.IsTrue: if(!returnType.IsAssignableFrom(typeof(bool))) { result = null; return false; } result = Type == JsonObjectType.True; return true; case ExpressionType.UnaryPlus: if (Type == JsonObjectType.FastNumber || Type == JsonObjectType.Number) { return this.InnerTryConvert(returnType, out result); } break; case ExpressionType.NegateChecked: case ExpressionType.Negate: if (Type == JsonObjectType.FastNumber) { var negated = new JsonObject { Type = JsonObjectType.FastNumber, FastNumberNegative = !this.FastNumberNegative, FastNumberPart1 = this.FastNumberPart1, FastNumberPart2 = this.FastNumberPart2, FastNumberPart2Length = this.FastNumberPart2Length, FastNumberPart3 = this.FastNumberPart3 }; return negated.InnerTryConvert(returnType, out result); } if (Type == JsonObjectType.Number) { var negated = new JsonObject { Type = JsonObjectType.Number, NumberValue = -this.NumberValue }; return negated.InnerTryConvert(returnType, out result); } break; case ExpressionType.Not: if (Type == JsonObjectType.True) { return JsonObject.False.InnerTryConvert(returnType, out result); } if (Type == JsonObjectType.False) { return JsonObject.True.InnerTryConvert(returnType, out result); } break; } result = null; return false; }
public DynamicTypeConverter(JsonObject context) : base() { Context = context; }
public void PutNumber(double number) { var num = JsonObject.ForNumber(number, Options); if (BeingBuilt == null) { BeingBuilt = num; } else { BeingBuilt.Put(num); } }
public void EndObjectMember() { BeingBuilt = BeingBuilt.Pop(); }
public void EndObject() { BeingBuilt = BeingBuilt.Pop(); }
public void EndArray() { BeingBuilt = BeingBuilt.Pop(); }
public void StartObjectMember() { var member = JsonObject.NewObjectMember(BeingBuilt); BeingBuilt = member; }
public void StartObject() { var obj = JsonObject.NewObject(BeingBuilt); if (BeingBuilt == null) { BeingBuilt = obj; } else { BeingBuilt.Put(obj); BeingBuilt = obj; } }