예제 #1
0
파일: ComData.cs 프로젝트: Phyberosis/ArmP2
        public bool TryParse <T>(ref T container)
        {
            JSONDecoder jd = RawValue.Clone();

            try
            {
                IJSONable raw = (IJSONable)container;
                raw.fillFromJSON(jd);
                container = (T)raw;
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #2
0
        public void fillFromJSON(JSONDecoder jd)
        {
            jd.beginItem();

            dataType = jd.getField()[1];    // dataType

            jd.getField();                  // data
            jd.beginItem();                 // [
            Type t = Type.GetType(dataType);
            Queue <IJSONable> dataQ = new Queue <IJSONable>();

            while (!jd.peekLine().Contains("]"))
            {
                IJSONable obj = (IJSONable)Activator.CreateInstance(t);
                obj.fillFromJSON(jd);
                dataQ.Enqueue(obj);
            }
            value = dataQ.ToArray();
            jd.endItem();

            jd.endItem();
        }