src/GenFx/GeneticComponentExtensions.cs
/// <summary>
/// Copies the state of all configuration properties defined on the source component to the target component.
/// </summary>
/// <param name="source">The <see cref="GeneticComponent"/> from which to copy the configuration state.</param>
/// <param name="target">The <see cref="GeneticComponent"/> to which the state is to be copied.</param>
Copies the state of all configuration properties defined on the source component to the target component.
Copies the state of all configuration properties defined on the source component to the target component .
public static void CopyConfigurationStateTo(this GeneticComponent source, GeneticComponent target)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            BindingFlags binding = BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy;
            IEnumerable<PropertyInfo> properties = source.GetType().GetProperties(binding)
                .Where(p => p.GetCustomAttribute<ConfigurationPropertyAttribute>() != null);
            foreach (PropertyInfo property in properties)
            {
                if (!property.CanRead || !property.CanWrite)
                {
                    throw new InvalidOperationException(
                        StringUtil.GetFormattedString(Resources.ErrorMsg_ConfigurationPropertyNoGetterNoSetter, source.GetType(), property.Name, typeof(ConfigurationPropertyAttribute)));
                }
                property.SetValue(target, property.GetValue(source));
            }
        }
public static void CopyConfigurationStateTo ( this GeneticComponent source , GeneticComponent target ) { if ( source == null ) { throw new ArgumentNullException ( nameof ( source ) ) ; } if ( target == null ) { throw new ArgumentNullException ( nameof ( target ) ) ; } BindingFlags binding = BindingFlags . Public | BindingFlags . Instance | BindingFlags . FlattenHierarchy ; IEnumerable < PropertyInfo > properties = source . GetType ( ) . GetProperties ( binding ) . Where ( p => p . GetCustomAttribute < ConfigurationPropertyAttribute > ( ) != null ) ; foreach ( PropertyInfo property in properties ) { if ( ! property . CanRead || ! property . CanWrite ) { throw new InvalidOperationException ( StringUtil . GetFormattedString ( Resources . ErrorMsg_ConfigurationPropertyNoGetterNoSetter , source . GetType ( ) , property . Name , typeof ( ConfigurationPropertyAttribute ) ) ) ; } property . SetValue ( target , property . GetValue ( source ) ) ; } }
Copies the state of all configuration properties defined on the source component to the target component.
Copies the state of all configuration properties defined on the source component to the target component .
GeneticComponent
this
target
GeneticComponent
The  to which the state is to be copied.
The to which the state is to be copied .
source
The  from which to copy the configuration state.
The from which to copy the configuration state .