示例#1
0
 public static void ToJsonObjectFromDictionary <TKey>(IVOSJsonObject jobj, IDictionary <TKey, object> dct)
 {
     foreach (var item in dct)
     {
         jobj.AddField(item.Key.ToString(), item.Value.ToString());
     }
 }
示例#2
0
        //
        // </ Array >
        //

        public static TValue FromJsonObjectToJobj <TValue>(IVOSJsonObject jobj)
            where TValue : IVOSJsonSirializable, new()
        {
            var val = new TValue();

            val.DeserializeFromJson(jobj);
            return(val);
        }
示例#3
0
        public static void FromJsonObjectToDictionary(IVOSJsonObject jobj, IDictionary <string, int> dct)
        {
            string key = string.Empty;

            for (int i = 0; i < jobj.count; ++i)
            {
                key = jobj.GetKey(i);

                dct.Add(key, jobj.GetIntField(key));
            }
        }
示例#4
0
        //
        // </ Dictionary >
        //

        //
        // < Collection >
        //

        public static void ToJsonArrayFromJobjCollection <TValue>(IVOSJsonArray jarr, ICollection <TValue> coll)
            where TValue : IVOSJsonSirializable
        {
            IVOSJsonObject jobj = null;

            foreach (var item in coll)
            {
                jobj = jarr.AddObjectItem();
                item.SerializeToJson(jobj);
            }
        }
示例#5
0
        public static void ToJsonArrayFromJobjArray <TValue>(IVOSJsonArray jarr, TValue[] arr)
            where TValue : IVOSJsonSirializable
        {
            IVOSJsonObject jobj = null;

            for (int i = 0; i < arr.Length; ++i)
            {
                jobj = jarr.AddObjectItem();
                arr[i].SerializeToJson(jobj);
            }
        }
示例#6
0
        //
        // < Dictionary >
        //

        public static void ToJsonObjectFromJobjDictionary <TKey, TValue>(IVOSJsonObject jobj, IDictionary <TKey, TValue> dct)
            where TValue : IVOSJsonSirializable
        {
            IVOSJsonObject jobjitem = null;

            foreach (var item in dct)
            {
                jobjitem = jobj.AddObjectField(item.Key.ToString());
                item.Value.SerializeToJson(jobjitem);
            }
        }
示例#7
0
        public static void FromJsonArrayToJobjArray <TValue>(IVOSJsonArray jarr, TValue[] arr)
            where TValue : IVOSJsonSirializable, new()
        {
            TValue         val  = new TValue();
            IVOSJsonObject jobj = null;

            for (int i = 0; i < jarr.count; ++i)
            {
                jobj = jarr.GetObjectItem(i);

                val = new TValue();
                val.DeserializeFromJson(jobj);

                arr[i] = val;
            }
        }
示例#8
0
        //
        // </ Collection >
        //

        //
        // < Array >
        //

        public static void ToJsonArrayFromJobjArray <TValue>(IVOSJsonArray jarr, TValue[,] arr)
            where TValue : IVOSJsonSirializable
        {
            IVOSJsonArray  rw   = null;
            IVOSJsonObject jobj = null;

            for (int i = 0; i < arr.GetLength(0); ++i)
            {
                rw = jarr.AddArrayItem();
                for (int j = 0; j < arr.GetLength(1); ++j)
                {
                    jobj = rw.AddObjectItem();
                    arr[i, j].SerializeToJson(jobj);
                }
            }
        }
示例#9
0
        public static void FromJsonObjectToJobjDictionary <TValue>(IVOSJsonObject jobj, IDictionary <string, TValue> dct)
            where TValue : IVOSJsonSirializable, new()
        {
            TValue val = new TValue();
            string key = string.Empty;

            for (int i = 0; i < jobj.count; ++i)
            {
                key = jobj.GetKey(i);

                val = new TValue();
                val.DeserializeFromJson(
                    jobj.GetObjectField(key));

                dct.Add(key, val);
            }
        }
示例#10
0
        public static void FromJsonObjectToEnumDictionary <TEnum, TValue>(IVOSJsonObject jobj, IDictionary <TEnum, TValue> dct)
            where TValue : IVOSJsonSirializable, new()
        {
            TValue val = new TValue();
            string key = string.Empty;

            for (int i = 0; i < jobj.count; ++i)
            {
                key = jobj.GetKey(i);

                val = new TValue();
                val.DeserializeFromJson(
                    jobj.GetObjectField(key));

                dct.Add(
                    (TEnum)System.Enum.Parse(typeof(TEnum), key),
                    val);
            }
        }
示例#11
0
 public void DeserializeFromJson(IVOSJsonObject jobj)
 {
     denominator = jobj.GetIntField("Denominator");
     numerator   = jobj.GetIntField("Numerator");
 }
示例#12
0
 public void SerializeToJson(IVOSJsonObject jobj)
 {
     jobj.AddField("Numerator", numerator);
     jobj.AddField("Denominator", denominator);
 }