Skip to content

Commit 51298ad

Browse files
committed
Xmldoc updates.
1 parent 1bab0d1 commit 51298ad

4 files changed

Lines changed: 87 additions & 8 deletions

File tree

src/Azure/AzureKeyVaultConfigBuilder.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class AzureKeyVaultConfigBuilder : KeyValueConfigBuilder
4545
/// <param name="config">A collection of the name/value pairs representing builder-specific attributes specified in the configuration for this provider.</param>
4646
protected override void LazyInitialize(string name, NameValueCollection config)
4747
{
48-
// Default 'Optional' to false. base.Initialize() will override if specified in config.
48+
// Default 'Optional' to false. base.LazyInitialize() will override if specified in config.
4949
Optional = false;
5050

5151
base.LazyInitialize(name, config);
@@ -133,12 +133,22 @@ public override ICollection<KeyValuePair<string, string>> GetAllValues(string pr
133133
return d;
134134
}
135135

136+
/// <summary>
137+
/// Makes a determination about whether the input key is valid for this builder and backing store.
138+
/// </summary>
139+
/// <param name="key">The string to be validated. May be partial.</param>
140+
/// <returns>True if the string is valid. False if the string is not a valid key.</returns>
136141
public override bool ValidateKey(string key)
137142
{
138143
// Key Vault only allows alphanumerics and '-'. This builder also allows for one '/'.
139144
return Regex.IsMatch(key, "^[a-zA-Z0-9-]+(/?[a-zA-Z0-9-]+)?$");
140145
}
141146

147+
/// <summary>
148+
/// Transforms the raw key to a new string just before updating items in Strict and Greedy modes.
149+
/// </summary>
150+
/// <param name="rawKey">The key as read from the incoming config section.</param>
151+
/// <returns>The key string that will be left in the processed config section.</returns>
142152
public override string UpdateKey(string rawKey)
143153
{
144154
// Remove the version segment if it's there.

src/Base/KeyValueConfigBuilder.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public abstract class KeyValueConfigBuilder : ConfigurationBuilder
7474
/// <returns>True if the string is valid. False if the string is not a valid key.</returns>
7575
public virtual bool ValidateKey(string key) { return true; }
7676
/// <summary>
77-
/// Transforms the raw key read from the config file to a new string when updating items in Strict and Greedy modes.
77+
/// Transforms the raw key to a new string just before updating items in Strict and Greedy modes.
7878
/// </summary>
79-
/// <param name="rawKey">The key as read from the incomming config section.</param>
79+
/// <param name="rawKey">The key as read from the incoming config section.</param>
8080
/// <returns>The key string that will be left in the processed config section.</returns>
8181
public virtual string UpdateKey(string rawKey) { return rawKey; }
8282

@@ -116,6 +116,11 @@ protected virtual void LazyInitialize(string name, NameValueCollection config)
116116
_lazyInitialized = true;
117117
}
118118

119+
/// <summary>
120+
/// Perform token substitution on a config parameter passed through builder initialization using token values from appSettings.
121+
/// </summary>
122+
/// <param name="configName">The name of the parameter to be retrieved.</param>
123+
/// <returns>The updated parameter value if it exists. Null otherwise.</returns>
119124
protected string UpdateConfigSettingWithAppSettings(string configName)
120125
{
121126
string configValue = _config[configName];

src/Base/SectionHandler.cs

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,49 @@ internal interface ISectionHandler
1313
IEnumerator<KeyValuePair<string, object>> GetEnumerator();
1414
}
1515

16+
/// <summary>
17+
/// A class to be used by <see cref="KeyValueConfigBuilder"/>s to apply key/value config pairs to .Net configuration sections.
18+
/// </summary>
19+
/// <typeparam name="T">The type of <see cref="ConfigurationSection"/> that the implementing class can process.</typeparam>
1620
public abstract class SectionHandler<T> : ISectionHandler where T : ConfigurationSection
1721
{
22+
/// <summary>
23+
/// The <see cref="ConfigurationSection"/> instance being processed by this <see cref="SectionHandler{T}"/>.
24+
/// </summary>
1825
public T ConfigSection { get; private set; }
19-
public abstract void InsertOrUpdate(string newKey, string newValue, string oldKey = null, object oldItem = null);
26+
27+
/// <summary>
28+
/// Gets an <see cref="IEnumerator{T}"/> that iterates over the key/value pairs contained in the assigned <see cref="ConfigSection"/>. />
29+
/// </summary>
30+
/// <returns>An enumerator over pairs consisting of the existing key for a config value in the config section, and an object reference
31+
/// for the key/value pair to be passed in to <see cref="InsertOrUpdate(string, string, string, object)"/> while processing the config section.</returns>
2032
public abstract IEnumerator<KeyValuePair<string, object>> GetEnumerator();
33+
34+
/// <summary>
35+
/// Updates an existing config value in the assigned <see cref="ConfigSection"/> with a new key and a new value. The old config value
36+
/// can be located using the <paramref name="oldKey"/> or <paramref name="oldItem"/> parameters. If an old config value is not
37+
/// found, a new config value should be inserted.
38+
/// </summary>
39+
/// <param name="newKey">The updated key name for the config item.</param>
40+
/// <param name="newValue">The updated value for the config item.</param>
41+
/// <param name="oldKey">The old key name for the config item, or null.</param>
42+
/// <param name="oldItem">A reference to the old key/value pair obtained by <see cref="GetEnumerator"/>, or null.</param>
43+
public abstract void InsertOrUpdate(string newKey, string newValue, string oldKey = null, object oldItem = null);
2144
}
2245

46+
/// <summary>
47+
/// A class that can be used by <see cref="KeyValueConfigBuilder"/>s to apply key/value config pairs to <see cref="AppSettingsSection"/>.
48+
/// </summary>
2349
public class AppSettingsSectionHandler : SectionHandler<AppSettingsSection>
2450
{
51+
/// <summary>
52+
/// Updates an existing app setting in the assigned <see cref="SectionHandler{T}.ConfigSection"/> with a new key and a new value. The old setting
53+
/// can be located using the <paramref name="oldKey"/> parameter. If an old setting is not found, a new setting should be inserted.
54+
/// </summary>
55+
/// <param name="newKey">The updated key name for the app setting.</param>
56+
/// <param name="newValue">The updated value for the app setting.</param>
57+
/// <param name="oldKey">The old key name for the app setting, or null.</param>
58+
/// <param name="oldItem">The old key name for the app setting, or null., or null.</param>
2559
public override void InsertOrUpdate(string newKey, string newValue, string oldKey = null, object oldItem = null)
2660
{
2761
if (newValue != null)
@@ -34,6 +68,10 @@ public override void InsertOrUpdate(string newKey, string newValue, string oldKe
3468
}
3569
}
3670

71+
/// <summary>
72+
/// Gets an <see cref="IEnumerator{T}"/> that iterates over the key/value pairs contained in the assigned <see cref="SectionHandler{T}.ConfigSection"/>. />
73+
/// </summary>
74+
/// <returns>An enumerator over pairs where both values of the pair are the existing key for each setting in the appSettings section.</returns>
3775
public override IEnumerator<KeyValuePair<string, object>> GetEnumerator()
3876
{
3977
// Grab a copy of the keys array since we are using 'yield' and the Settings collection may change on us.
@@ -43,14 +81,26 @@ public override IEnumerator<KeyValuePair<string, object>> GetEnumerator()
4381
}
4482
}
4583

84+
/// <summary>
85+
/// A class that can be used by <see cref="KeyValueConfigBuilder"/>s to apply key/value config pairs to <see cref="ConnectionStringsSection"/>.
86+
/// </summary>
4687
public class ConnectionStringsSectionHandler : SectionHandler<ConnectionStringsSection>
4788
{
48-
public override void InsertOrUpdate(string newKey, string newValue, string oldKey = null, object oldValue = null)
89+
/// <summary>
90+
/// Updates an existing connection string in the assigned <see cref="SectionHandler{T}.ConfigSection"/> with a new name and a new value. The old
91+
/// connection string can be located using the <paramref name="oldItem"/> parameter. If an old connection string is not found, a new connection
92+
/// string should be inserted.
93+
/// </summary>
94+
/// <param name="newKey">The updated key name for the connection string.</param>
95+
/// <param name="newValue">The updated value for the connection string.</param>
96+
/// <param name="oldKey">The old key name for the connection string, or null.</param>
97+
/// <param name="oldItem">A reference to the old <see cref="ConnectionStringSettings"/> object obtained by <see cref="GetEnumerator"/>, or null.</param>
98+
public override void InsertOrUpdate(string newKey, string newValue, string oldKey = null, object oldItem = null)
4999
{
50100
if (newValue != null)
51101
{
52102
// Preserve the old entry if it exists, as it might have more than just name/connectionString attributes.
53-
ConnectionStringSettings cs = (oldValue as ConnectionStringSettings) ?? new ConnectionStringSettings();
103+
ConnectionStringSettings cs = (oldItem as ConnectionStringSettings) ?? new ConnectionStringSettings();
54104

55105
// Make sure there are no entries using the old or new name other than this one
56106
ConfigSection.ConnectionStrings.Remove(oldKey);
@@ -63,6 +113,11 @@ public override void InsertOrUpdate(string newKey, string newValue, string oldKe
63113
}
64114
}
65115

116+
/// <summary>
117+
/// Gets an <see cref="IEnumerator{T}"/> that iterates over the key/value pairs contained in the assigned <see cref="SectionHandler{T}.ConfigSection"/>. />
118+
/// </summary>
119+
/// <returns>An enumerator over pairs where the key is the existing name for each setting in the connectionStrings section, and the value
120+
/// is a reference to the <see cref="ConnectionStringSettings"/> object referred to by that name.</returns>
66121
public override IEnumerator<KeyValuePair<string, object>> GetEnumerator()
67122
{
68123
// The ConnectionStrings collection may change on us while we enumerate. :/

src/Base/SectionHandlerSection.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@
66

77
namespace Microsoft.Configuration.ConfigurationBuilders
88
{
9-
public class SectionHandlersSection : ConfigurationSection
9+
/// <summary>
10+
/// Provides programmatic access to the 'sectionHandlers' config section. This class can't be inherited.
11+
/// </summary>
12+
public sealed class SectionHandlersSection : ConfigurationSection
1013
{
1114
static readonly string handlerSectionName = "Microsoft.Configuration.ConfigurationBuilders.SectionHandlers";
1215

16+
/// <summary>
17+
/// Gets the collection of <see cref="SectionHandler{T}" />s defined for processing config sections with <see cref="KeyValueConfigBuilder"/>s./>
18+
/// </summary>
1319
[ConfigurationProperty("handlers", IsDefaultCollection = true, Options = ConfigurationPropertyOptions.IsDefaultCollection)]
14-
protected ProviderSettingsCollection Handlers
20+
public ProviderSettingsCollection Handlers
1521
{
1622
get { return (ProviderSettingsCollection)base["handlers"]; }
1723
}
1824

25+
/// <summary>
26+
/// Used to initialize a default set of section handlers. (For the appSettings and connectionStrings sections.)
27+
/// </summary>
1928
protected override void InitializeDefault()
2029
{
2130
// This only runs once at the top "parent" level of the config stack. If there is already an

0 commit comments

Comments
 (0)