Inheritance: ICustomTypeDescriptor
Exemplo n.º 1
1
 public void PutString(string str)
 {
     if (BeingBuilt == null)
     {
         BeingBuilt = JsonObject.ForString(str, Options);
     }
     else
     {
         BeingBuilt.Put(JsonObject.ForString(str, Options));
     }
 }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
 public void PutFalse()
 {
     if (BeingBuilt == null)
     {
         BeingBuilt = JsonObject.False;
     }
     else
     {
         BeingBuilt.Put(JsonObject.False);
     }
 }
Exemplo n.º 4
0
 public void PutTrue()
 {
     if (BeingBuilt == null)
     {
         BeingBuilt = JsonObject.True;
     }
     else
     {
         BeingBuilt.Put(JsonObject.True);
     }
 }
Exemplo n.º 5
0
 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);
     }
 }
Exemplo n.º 6
0
        public void StartArray()
        {
            var arr = JsonObject.NewArray(BeingBuilt);

            if (BeingBuilt == null)
            {
                BeingBuilt = arr;
            }
            else
            {
                BeingBuilt.Put(arr);
                BeingBuilt = arr;
            }
        }
Exemplo n.º 7
0
 internal static JsonObject NewObjectMember(JsonObject parent)
 {
     return new JsonObject { Type = JsonObjectType.ObjectMember, Parent = parent };
 }
Exemplo n.º 8
0
 internal static JsonObject NewObject(JsonObject parent)
 {
     return new JsonObject { Type = JsonObjectType.Object, Parent = parent, ObjectMembers = new Dictionary<string, JsonObject>() };
 }
Exemplo n.º 9
0
 internal static JsonObject NewArray(JsonObject parent)
 {
     return new JsonObject { Type = JsonObjectType.Array, Parent = parent, ArrayValue = new List<JsonObject>() };
 }
Exemplo n.º 10
0
 public JsonMetaObject(JsonObject outer, Expression exp)
     : base(exp, BindingRestrictions.Empty, outer)
 {
 }
Exemplo n.º 11
0
        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;
        }
Exemplo n.º 12
0
 public DynamicTypeConverter(JsonObject context)
     : base()
 {
     Context = context;
 }
Exemplo n.º 13
0
 public void PutNumber(double number)
 {
     var num = JsonObject.ForNumber(number, Options);
     if (BeingBuilt == null)
     {
         BeingBuilt = num;
     }
     else
     {
         BeingBuilt.Put(num);
     }
 }
Exemplo n.º 14
0
 public void EndObjectMember()
 {
     BeingBuilt = BeingBuilt.Pop();
 }
Exemplo n.º 15
0
 public void EndObject()
 {
     BeingBuilt = BeingBuilt.Pop();
 }
Exemplo n.º 16
0
 public void EndArray()
 {
     BeingBuilt = BeingBuilt.Pop();
 }
Exemplo n.º 17
0
        public void StartObjectMember()
        {
            var member = JsonObject.NewObjectMember(BeingBuilt);

            BeingBuilt = member;
        }
Exemplo n.º 18
0
        public void StartObject()
        {
            var obj = JsonObject.NewObject(BeingBuilt);

            if (BeingBuilt == null)
            {
                BeingBuilt = obj;
            }
            else
            {
                BeingBuilt.Put(obj);
                BeingBuilt = obj;
            }
        }