Пример #1
0
        /// <summary>
        /// Applies all shared properties from <see cref="Source"/> to <see cref="Destination"/>.
        /// </summary>
        /// <param name="Source"><see cref="PKM"/> that supplies property values.</param>
        /// <param name="Destination"><see cref="PKM"/> that receives property values.</param>
        protected void TransferPropertiesWithReflection(PKM Source, PKM Destination)
        {
            // Only transfer declared properties not defined in PKM.cs but in the actual type
            var SourceProperties      = ReflectUtil.getPropertiesCanWritePublicDeclared(Source.GetType());
            var DestinationProperties = ReflectUtil.getPropertiesCanWritePublicDeclared(Destination.GetType());

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