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

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

            BeingBuilt = member;
        }
示例#18
0
        public void StartObject()
        {
            var obj = JsonObject.NewObject(BeingBuilt);

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