using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FLY.Thick.Base.Common;

namespace FLY.Thick.Base.OBJ_INTERFACE
{
    public class PASSWORD_OBJ_INTERFACE
    {

        #region Pack
        public class Pack_List 
        {
            public List<PasswordCell> list;
            #region IPack 成员

            public byte[] ToBytes()
            {
                List<byte> buf = new List<byte>();
                
                buf.AddRange(BitConverter.GetBytes(list.Count()));
                for (int i = 0; i < list.Count();i++ )
                    buf.AddRange(list[i].ToBytes());
                return buf.ToArray();
            }

            public bool TryParse(byte[] value)
            {
                int count = 4;
                if (value.Length < count)
                    return false;
                int idx = 0;
                int len = BitConverter.ToInt32(value, idx);
                idx += 4;
                if (list == null)
                    list = new List<PasswordCell>();
                else
                    list.Clear();

                for (int i = 0; i < len; i++) 
                {
                    int cnt;
                    PasswordCell p = new PasswordCell();
                    if (!p.TryParse(value, idx, out cnt))
                        return false;
                    list.Add(p);
                    count += cnt;
                    idx += cnt;
                }
                return true;
            }

            #endregion
        }
        #endregion

        #region GetValue
        public const UInt16 GET_PWLIST = 1;
        #endregion
        #region SetValue
        public const UInt16 SET_PWLIST = 1;
        #endregion
        #region PushMsg
        public const UInt16 PUSH_PWLIST = 1;
        #endregion
    }
}
