ProviderConfigurationSettings Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides the base class for displaying the provider configuration settings.
public ref class ProviderConfigurationSettings abstract
public abstract class ProviderConfigurationSettings
type ProviderConfigurationSettings = class
Public MustInherit Class ProviderConfigurationSettings
- Inheritance
-
ProviderConfigurationSettings
Examples
The following example builds a custom ProviderConfigSettings
class, which is derived from the ProviderConfigurationSettings class. The example loads and initializes the provider configuration settings and then uses the GetSettings method to obtain the key/value pairs. Finally, the Validate method checks for validation.
using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Web.Management.Client;
namespace ConfigSnippets {
class Program {
static void Main(string[] args) {
ProviderConfigSettings providerConfigSettings = new ProviderConfigSettings();
// Load the settings.
string[] arraysettings = {
"key0", "value0",
"key1", "value1",
"key2", "value2"
};
providerConfigSettings.LoadSettings(arraysettings);
Console.WriteLine("\nLoadSettings count: " + arraysettings.Length);
// Display the settings.
IDictionary<string, string> settings;
settings = (IDictionary<string, string>)providerConfigSettings.GetSettings();
Console.WriteLine("There are " + settings.Count +
" key value pairs in ProviderConfigSettings.");
foreach (KeyValuePair<string, string> keyValuePair in settings) {
Console.WriteLine(" " + keyValuePair.Key + ": " + keyValuePair.Value);
}
// Perform a validation check on the provider configuration settings.
string newmessage;
bool retval = providerConfigSettings.Validate(out newmessage);
Console.WriteLine("\nValidation returns a " + retval);
Console.WriteLine("Validation message: " + newmessage);
}
public class ProviderConfigSettings : ProviderConfigurationSettings {
IDictionary<string, string> _settings = new Dictionary<string, string>();
// overrides the abstract Settings property.
protected override System.Collections.IDictionary Settings {
get {
return (IDictionary)_settings;
}
}
// Overrides the abstract Validate method.
public override bool Validate(out string message) {
// Perform a validation check. If the key pairs collection
// contains more than three pairs, pass a return value of
// false and a failure message.
if (_settings.Count < 4) {
message = "Validation succesful";
return true;
} else {
message = "Validation failed - too many key value pairs";
return false;
}
}
}
}
}
Remarks
This class enables the derived class to check the settings of the provider.
Notes to Implementers
When you inherit from the ProviderConfigurationSettings class, you must override the following members: Settings property and Validate(String) method.
Constructors
ProviderConfigurationSettings() |
Initializes a new instance of the ProviderConfigurationSettings class. |
Properties
ProviderSpecificSettings | |
Settings |
When overridden in a derived class, gets the collection of settings that are specific to the host environment. |
Methods
GetSettings() |
Returns an array that contains the settings of the provider configuration. |
LoadSettings(String[]) |
Loads the settings from the specified array into the provider configuration settings. |
Validate(String) |
When overridden in a derived class, validates the provider configuration settings. |