Esempio n. 1
0
        // 把值写入到ab当中
        public void WriteTo(object value, Nested.AnyBase ab)
        {
            if (value == null)
            {
                ab.valueType = 0;
                return;
            }

            ab.valueType = 1;
            var dic = (IDictionary)value;
            int cnt = 0;

            ab.listCount = dic.Count;
            foreach (DictionaryEntry ator in dic)
            {
                string key = cnt.ToString();
                keyTypeSerialize.WriteTo(ator.Key, ab.Create($"key:{key}", keyTypeSerialize.typeFlag));
                valueTypeSerialize.WriteTo(ator.Value, ab.Create($"value:{key}", valueTypeSerialize.typeFlag));
                ++cnt;
            }
        }
Esempio n. 2
0
        // 把值写入到ab当中
        void ITypeSerialize.WriteTo(object value, Nested.AnyBase ab)
        {
            IList array = (IList)value;

            if (array == null)
            {
                ab.valueType = 0;
                return;
            }

            ab.valueType        = 1;
            ab.elementTypeFlags = elementTypeSerialize.typeFlag;
            object elementObj;
            int    cnt = array.Count;

            ab.listCount = cnt;
            for (int i = 0; i < cnt; ++i)
            {
                elementObj = array[i];
                var cts = ab.Create($"[{i}]", elementTypeSerialize.typeFlag);
                elementTypeSerialize.WriteTo(elementObj, cts);
            }
        }