示例#1
0
文件: TS2_Biser.cs 项目: ikvm/Biser
        public static TS2 BiserDecode(byte[] enc = null, Biser.Decoder extDecoder = null) //!!! change return type
        {
            Biser.Decoder decoder = null;
            if (extDecoder == null)
            {
                if (enc == null || enc.Length == 0)
                {
                    return(null);
                }
                decoder = new Biser.Decoder(enc);
                if (decoder.CheckNull())
                {
                    return(null);
                }
            }
            else
            {
                if (extDecoder.CheckNull())
                {
                    return(null);
                }
                else
                {
                    decoder = extDecoder;
                }

                //decoder = new Biser.Decoder(extDecoder);
                //if (decoder.IsNull)
                //    return null;
            }

            TS2 m = new TS2();      //!!!!!!!!!!!!!! change return type

            m.P1 = decoder.GetLong();
            m.P2 = decoder.GetDouble();

            m.P3 = decoder.CheckNull() ? null : new List <TS3>();
            if (m.P3 != null)
            {
                decoder.GetCollection(() => { return(TS3.BiserDecode(null, decoder)); }, m.P3, true);
            }

            m.P4 = TS3.BiserDecode(null, decoder);

            m.P5 = decoder.GetUInt_NULL();

            return(m);
        }
示例#2
0
文件: TS1_Biser.cs 项目: ikvm/Biser
        public static TS1 BiserDecode(byte[] enc = null, Biser.Decoder extDecoder = null) //!!!!!!!!!!!!!! change return type
        {
            Biser.Decoder decoder = null;
            if (extDecoder == null)
            {
                if (enc == null || enc.Length == 0)
                {
                    return(null);
                }
                decoder = new Biser.Decoder(enc);
                if (decoder.CheckNull())
                {
                    return(null);
                }
            }
            else
            {
                if (extDecoder.CheckNull())
                {
                    return(null);
                }
                else
                {
                    decoder = extDecoder;
                }

                //decoder = new Biser.Decoder(extDecoder);
                //if (decoder.IsNull)
                //    return null;
            }

            TS1 m = new TS1();  //!!!!!!!!!!!!!! change return type

            m.P1 = decoder.GetInt();
            m.P2 = decoder.GetInt();
            m.P3 = decoder.GetDecimal();

            m.P4 = decoder.CheckNull() ? null : new List <TS2>();
            if (m.P4 != null)
            {
                decoder.GetCollection(() => { return(TS2.BiserDecode(null, decoder)); }, m.P4, true);
            }

            m.P5 = decoder.CheckNull() ? null : new Dictionary <long, TS3>();
            if (m.P5 != null)
            {
                decoder.GetCollection(() => {
                    return(decoder.GetLong());
                },
                                      () => { return(TS3.BiserDecode(null, decoder)); }, m.P5, true);
            }

            m.P6 = decoder.CheckNull() ? null : new Dictionary <uint, List <TS3> >();
            if (m.P6 != null)
            {
                decoder.GetCollection(
                    () => { return(decoder.GetUInt()); },
                    () =>
                {
                    var iList = decoder.CheckNull() ? null : new List <TS3>();
                    if (iList != null)
                    {
                        decoder.GetCollection(() => { return(TS3.BiserDecode(extDecoder: decoder)); }, iList, true);
                    }
                    return(iList);
                },
                    m.P6, true);
            }

            m.P7 = TS2.BiserDecode(extDecoder: decoder);

            m.P8 = decoder.CheckNull() ? null : new List <Tuple <string, byte[], TS3> >();
            if (m.P8 != null)
            {
                decoder.GetCollection
                    (() => {
                    return(new Tuple <string, byte[], TS3>
                               (decoder.GetString(),
                               decoder.GetByteArray(),
                               TS3.BiserDecode(null, decoder)));
                }, m.P8, true);
            }

            m.P9 = new Tuple <float, TS2, TS3, decimal?>
                       (decoder.GetFloat(), TS2.BiserDecode(null, decoder), TS3.BiserDecode(null, decoder), decoder.GetDecimal_NULL());

            return(m);
        }