예제 #1
0
        public static void Write(BinaryWriter writer, DObject.TypeCode type, object value)
        {
            writer.Write((int)type);
            if (WriteIfPrimitiveOrNull(writer, type, value, out var scope))
            {
                return;
            }
            Stack <SerializationScope> stack = new Stack <SerializationScope>();

            while (true)
            {
                int num;
                SerializationScope scope2;
                int num2;
                SerializationScope scope3;
                if (scope.Type == DObject.TypeCode.DObject)
                {
                    DObject dObject = (DObject)scope.Instance;
                    int     count   = dObject.Count;
                    num = scope.Index;
                    while (num < count)
                    {
                        DObject.Entry entry = DObject.GetEntry(dObject, num);
                        writer.Write(entry.Key);
                        writer.Write((int)entry.Type);
                        if (WriteIfPrimitiveOrNull(writer, entry.Type, entry.Value, out scope2))
                        {
                            num++;
                            continue;
                        }
                        goto IL_007c;
                    }
                }
                else
                {
                    Array            array  = (Array)scope.Instance;
                    int              length = array.Length;
                    DObject.TypeCode type2  = scope.Type & ~DObject.TypeCode.Array;
                    num2 = scope.Index;
                    while (num2 < length)
                    {
                        object value2 = array.GetValue(num2);
                        if (WriteIfPrimitiveOrNull(writer, type2, value2, out scope3))
                        {
                            num2++;
                            continue;
                        }
                        goto IL_00e3;
                    }
                }
                if (stack.Count >= 1)
                {
                    scope = stack.Pop();
                    continue;
                }
                break;
IL_00e3:
                scope.Index = num2 + 1;
                stack.Push(scope);
                scope = scope3;
                continue;
IL_007c:
                scope.Index = num + 1;
                stack.Push(scope);
                scope = scope2;
            }
        }