Exemple #1
0
        public static List <T> Merge <T>(List <T> to,
                                         List <T> patch) where T : class, IPatchClass <T>, new()
        {
            var count     = patch.Count;
            var lastCount = to.Count;

            to = FieldSerializeUtil.Resize(to, count);
            for (int i = 0; i < count; i++)
            {
                if (patch[i].HasValue)
                {
                    PatchPropertySerializer.MergeFromPatch(to[i], patch[i]);
                }
            }

            return(to);
        }
Exemple #2
0
        /// <summary>
        /// size是不会变的,否则重新生成
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dest"></param>
        /// <param name="origin"></param>
        /// <returns></returns>
        public static T[] Merge <T>(T[] dest,
                                    T[] origin) where T : class, IPatchClass <T>, new()
        {
            var oc = origin.Length;
            var dc = dest.Length;

            dest = FieldSerializeUtil.Resize(dest, oc);
            for (int i = 0; i < oc; i++)
            {
                if (origin[i].HasValue)
                {
                    dest[i].MergeFromPatch(origin[i]);
                }
            }

            return(dest);
        }