Exemple #1
0
        private static string[][] getPropArray()
        {
            var p = new string[types.Length][];

            for (int i = 0; i < p.Length; i++)
            {
                p[i] = ReflectUtil.getPropertiesCanWritePublic(types[i]).ToArray();
            }

            IEnumerable <string> all = p.SelectMany(prop => prop).Distinct();
            IEnumerable <string> any = p[0];

            for (int i = 1; i < p.Length; i++)
            {
                any = any.Union(p[i]);
            }

            var p1 = new string[types.Length + 2][];

            Array.Copy(p, 0, p1, 1, p.Length);
            p1[0]             = all.ToArray();
            p1[p1.Length - 1] = any.ToArray();

            return(p1);
        }
Exemple #2
0
        protected void TransferPropertiesWithReflection(PKM Source, PKM Destination)
        {
            var SourceProperties      = ReflectUtil.getPropertiesCanWritePublic(Source.GetType());
            var DestinationProperties = ReflectUtil.getPropertiesCanWritePublic(Destination.GetType());

            foreach (string property in SourceProperties.Intersect(DestinationProperties).Where(prop => prop != nameof(Data)))
            {
                var prop = ReflectUtil.GetValue(this, property);
                if (prop == null)
                {
                    continue;
                }
                ReflectUtil.SetValue(Destination, property, prop);
            }
        }