Esempio n. 1
0
        private CheckedRet <T> TryGet_ <T> (string name)
        {
            var             t    = typeof(T);
            NamedObjectDict dic2 = null;

            if (mDic.TryGetValue(t, out dic2))
            {
                throw new Exception("Target type is missing.");
            }
            ;
            if (dic2.IsNull())
            {
                return(CheckedRet <T> .Fail());
            }

            object value = null;

            if (dic2.TryGetValue(name, out value))
            {
                return(CheckedRet <T> .Fail());
            }
            ;
            if (value.IsNull())
            {
                return(CheckedRet <T> .Fail());
            }
            var ret = (T)value;

            return(CheckedRet <T> .Gen(true, ret));
        }
Esempio n. 2
0
 public static CheckedRet <object> Deserial(ByteList bytes)
 {
     try {
         return(CheckedRet <object> .Gen(true, bytes.DropInt32()));
     } catch (Exception e) {
         Debug.Log("Int parse error" + e);
         return(CheckedRet <object> .Fail());
     }
 }
Esempio n. 3
0
 public static CheckedRet <object> Deserial(ByteList bytes)
 {
     try {
         var size = bytes.DropInt32();
         var data = System.Text.Encoding.UTF8.GetString(bytes.DropRange(0, size));
         return(CheckedRet <object> .Gen(true, data));
     } catch (Exception e) {
         Debug.Log("parse error" + e);
         return(CheckedRet <object> .Fail());
     }
 }
Esempio n. 4
0
 public static CheckedRet <object> Deserial(ByteList bytes)
 {
     try {
         var size = bytes.DropInt32();
         var data = BitConverter.ToSingle(bytes.DropRange(0, size), 0);
         return(CheckedRet <object> .Gen(true, data));
     } catch (Exception e) {
         Debug.Log("parse error" + e);
         return(CheckedRet <object> .Fail());
     }
 }
Esempio n. 5
0
 public static CheckedRet <object> Deserial(ByteList bytes)
 {
     try {
         var       size = bytes.DropInt32();
         object [] arr  = new object [size];
         for (int i = 0; i < size; i++)
         {
             arr [i] = Serializer.Deserialize(bytes);
         }
         return(CheckedRet <object> .Gen(true, arr));
     } catch (Exception e) {
         Debug.Log("parse error" + e);
         return(CheckedRet <object> .Fail());
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Dictionary < object , object >として戻ることに注意
 /// </summary>
 public static CheckedRet <object> Deserial(ByteList bytes)
 {
     try {
         var size = bytes.DropInt32();
         Dictionary <object, object> dic = new Dictionary <object, object>();
         for (int i = 0; i < size; i++)
         {
             var key = Serializer.Deserialize(bytes);
             var val = Serializer.Deserialize(bytes);
             dic.Add(key, val);
         }
         return(CheckedRet <object> .Gen(true, dic));
     } catch (Exception e) {
         Debug.Log("parse error" + e);
         return(CheckedRet <object> .Fail());
     }
 }