Exemple #1
0
 public static object Unpack(Stream stream, Type type)
 {
     if (stream != null && stream.CanRead)
     {
         if (stream.CanSeek)
         {
             \uE017 uE = default(\uE017);
             if (CpInazumaMsgPack.\uE022(type, ref uE))
             {
                 return(CpInazumaMsgPack.\uE020(stream, ref uE));
             }
             sbyte  b   = 0;
             \uE015 uE2 = CpInazumaMsgPack.\uE00A(stream, out b);
             if (uE2 == global::\uE015.\uE00B)
             {
                 stream.Seek(-1L, SeekOrigin.Current);
                 return(null);
             }
             if (uE2 == global::\uE015.\uE00A)
             {
                 return(null);
             }
             if (CpInazumaMsgPack.\uE00E(uE2))
             {
                 return(CpInazumaMsgPack.\uE01B(stream, uE2, b));
             }
             if (CpInazumaMsgPack.\uE00F(uE2))
             {
                 return(CpInazumaMsgPack.\uE01C(stream, uE2, b, type));
             }
             if (CpInazumaMsgPack.\uE010(uE2))
             {
                 return(CpInazumaMsgPack.\uE01D(stream, uE2, b, type));
             }
             if (CpInazumaMsgPack.\uE011(uE2))
             {
                 return(CpInazumaMsgPack.\uE01E(stream, uE2, b));
             }
             if (CpInazumaMsgPack.\uE012(uE2))
             {
                 return(CpInazumaMsgPack.\uE01F(stream, uE2, b));
             }
             stream.Seek(-1L, SeekOrigin.Current);
             return(null);
         }
     }
     throw new IOException(global::\uE019.\uE000(11502));
 }
Exemple #2
0
 public static void Pack(object data, Stream stream)
 {
     if (stream != null)
     {
         if (stream.CanWrite)
         {
             if (data == null)
             {
                 CpInazumaMsgPack.\uE00B(null, global::\uE015.\uE00A, stream);
                 return;
             }
             if (data.GetType().IsPrimitive)
             {
                 CpInazumaMsgPack.\uE015(data, stream);
                 return;
             }
             if (data is string)
             {
                 CpInazumaMsgPack.\uE018((string)data, stream);
                 return;
             }
             if (data is byte[])
             {
                 CpInazumaMsgPack.\uE019((byte[])data, stream);
                 return;
             }
             if (data is IList)
             {
                 CpInazumaMsgPack.\uE016((IList)data, stream);
                 return;
             }
             if (data is IDictionary)
             {
                 CpInazumaMsgPack.\uE017((IDictionary)data, stream);
                 return;
             }
             \uE017 uE = default(\uE017);
             if (CpInazumaMsgPack.\uE022(data.GetType(), ref uE))
             {
                 CpInazumaMsgPack.\uE01A(data, ref uE, stream);
             }
             return;
         }
     }
     throw new IOException(global::\uE019.\uE000(11502));
 }
Exemple #3
0
        private static bool \uE022(Type \uE060, ref \uE017 \uE061)
        {
            if (CpInazumaMsgPack.\uE007.TryGetValue(\uE060, out \uE061))
            {
                return(true);
            }
            if (\uE060.IsPrimitive || typeof(IList).IsAssignableFrom(\uE060) || typeof(IDictionary).IsAssignableFrom(\uE060) || \uE060 == typeof(object) || typeof(string) == \uE060)
            {
                return(false);
            }
            BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            FieldInfo[]   fields = \uE060.GetFields(bindingAttr);
            List <\uE016> list   = new List <\uE016>(fields.Length);
            bool          flag   = false;

            foreach (FieldInfo fieldInfo in fields)
            {
                if (!fieldInfo.IsDefined(typeof(NonSerializedAttribute), false))
                {
                    \uE016 uE = new \uE016();
                    uE.\uE001 = fieldInfo.Name;
                    uE.\uE000 = int.MaxValue;
                    uE.\uE002 = fieldInfo;
                    object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(CpSerializeFieldAttribute), false);
                    if (customAttributes.Length > 0 && customAttributes[0] is CpSerializeFieldAttribute)
                    {
                        flag = true;
                        CpSerializeFieldAttribute cpSerializeFieldAttribute = customAttributes[0] as CpSerializeFieldAttribute;
                        uE.\uE001 = (cpSerializeFieldAttribute.Name ?? fieldInfo.Name);
                        uE.\uE000 = cpSerializeFieldAttribute.Order;
                    }
                    list.Add(uE);
                }
            }
            if (flag)
            {
                List <\uE016> list2 = list;
                if (CpInazumaMsgPack.\uE00B == null)
                {
                    CpInazumaMsgPack.\uE00B = new Comparison <\uE016>(CpInazumaMsgPack.\uE024);
                }
                list2.Sort(CpInazumaMsgPack.\uE00B);
            }
            else
            {
                List <\uE016> list3 = list;
                if (CpInazumaMsgPack.\uE00C == null)
                {
                    CpInazumaMsgPack.\uE00C = new Comparison <\uE016>(CpInazumaMsgPack.\uE025);
                }
                list3.Sort(CpInazumaMsgPack.\uE00C);
            }
            \uE017 uE2 = default(\uE017);

            uE2.\uE000 = \uE060;
            uE2.\uE001 = list;
            CpInazumaMsgPack.\uE007[\uE060] = uE2;
            \uE017 uE3 = default(\uE017);

            for (int j = 0; j < list.Count; j++)
            {
                CpInazumaMsgPack.\uE022(list[j].\uE002.FieldType, ref uE3);
            }
            \uE061 = uE2;
            return(true);
        }
Exemple #4
0
 private static bool \uE021 <\uE000>(ref \uE017 \uE05F)
 {
     return(CpInazumaMsgPack.\uE022(typeof(\uE000), ref \uE05F));
 }