Skip to content

Commit

Permalink
Simplify method LDAPCPConfig.ApplyConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvand committed Jul 9, 2019
1 parent 596c376 commit 024cd32
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions LDAPCP/LDAPCPConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,6 @@ public void ResetCurrentConfiguration()
/// <param name="configToApply"></param>
public void ApplyConfiguration(LDAPCPConfig configToApply)
{
// Copy non-inherited public fields
// This copies persisted field SPTrustName (it doesn't have a corresponding property).
// Private fields should not be retrieved here, since their corresponding properties are retrieved just after.
FieldInfo[] fieldsToCopy = this.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
foreach (FieldInfo field in fieldsToCopy)
{
field.SetValue(this, field.GetValue(configToApply));
}
// Copy non-inherited public properties
PropertyInfo[] propertiesToCopy = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
foreach (PropertyInfo property in propertiesToCopy)
Expand All @@ -434,6 +426,9 @@ public void ApplyConfiguration(LDAPCPConfig configToApply)
property.SetValue(this, value);
}
}

// Member SPTrustName is not exposed through a property, so it must be set explicitly
this.SPTrustName = configToApply.SPTrustName;
}

/// <summary>
Expand Down

0 comments on commit 024cd32

Please sign in to comment.