HealthMonitoringSection.Profiles Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient une collection ProfileSettingsCollection d’objets ProfileSettings.
public:
property System::Web::Configuration::ProfileSettingsCollection ^ Profiles { System::Web::Configuration::ProfileSettingsCollection ^ get(); };
[System.Configuration.ConfigurationProperty("profiles")]
public System.Web.Configuration.ProfileSettingsCollection Profiles { get; }
[<System.Configuration.ConfigurationProperty("profiles")>]
member this.Profiles : System.Web.Configuration.ProfileSettingsCollection
Public ReadOnly Property Profiles As ProfileSettingsCollection
Valeur de propriété
Collection ProfileSettingsCollection d'objets ProfileSettings. La valeur par défaut est une collection ProfileSettingsCollection vide.
- Attributs
Exemples
L'exemple de code suivant montre comment utiliser la propriété Profiles. Cet exemple de code fait partie d’un exemple plus grand fourni pour la HealthMonitoringSection classe.
// Add a ProfileSettings object to the Profiles collection property.
ProfileSettings profileSetting = new ProfileSettings("Default");
profileSetting.Name = "Custom";
profileSetting.MaxLimit = Int32.MaxValue;
profileSetting.MinInstances = 1;
profileSetting.MinInterval = TimeSpan.Parse("00:01:00");
profileSetting.Custom = "MyEvaluators.MyCustomeEvaluator, MyCustom.dll";
healthMonitoringSection.Profiles.Add(profileSetting);
// Add a ProfileSettings object to the Profiles collection property.
healthMonitoringSection.Profiles.Add(new ProfileSettings("Default"));
// Add a ProfileSettings object to the Profiles collection property.
healthMonitoringSection.Profiles.Add(new ProfileSettings("Critical",
1, 1024, new TimeSpan(0, 0, 00)));
// Add a ProfileSettings object to the Profiles collection property.
healthMonitoringSection.Profiles.Add(new ProfileSettings("Targeted",
1, Int32.MaxValue, new TimeSpan(0, 0, 10),
"MyEvaluators.MyTargetedEvaluator, MyCustom.dll"));
// Insert an ProfileSettings object into the Profiles collection property.
healthMonitoringSection.Profiles.Insert(1, new ProfileSettings("Default2"));
// Display contents of the Profiles collection property
Console.WriteLine(
"Profiles Collection contains {0} values:",
healthMonitoringSection.Profiles.Count);
// Display all elements.
for (System.Int32 i = 0; i < healthMonitoringSection.Profiles.Count; i++)
{
profileSetting = healthMonitoringSection.Profiles[i];
string name = profileSetting.Name;
int minInstances = profileSetting.MinInstances;
int maxLimit = profileSetting.MaxLimit;
TimeSpan minInterval = profileSetting.MinInterval;
string custom = profileSetting.Custom;
string item = "Name='" + name +
"', MinInstances = '" + minInstances + "', MaxLimit = '" + maxLimit +
"', MinInterval = '" + minInterval + "', Custom = '" + custom + "'";
Console.WriteLine(" Item {0}: {1}", i, item);
}
// See if the ProfileSettings collection property contains the event 'Default'.
Console.WriteLine("Profiles contains 'Default': {0}.",
healthMonitoringSection.Profiles.Contains("Default"));
// Get the index of the 'Default' ProfileSettings in the Profiles collection property.
Console.WriteLine("Profiles index for 'Default': {0}.",
healthMonitoringSection.Profiles.IndexOf("Default"));
// Get a named ProfileSettings
profileSetting = healthMonitoringSection.Profiles["Default"];
// Remove a ProfileSettings object from the Profiles collection property.
healthMonitoringSection.Profiles.Remove("Default");
// Remove a ProfileSettings object from the Profiles collection property.
healthMonitoringSection.Profiles.RemoveAt(0);
// Clear all ProfileSettings object from the Profiles collection property.
healthMonitoringSection.Profiles.Clear();
' Add a ProfileSettings object to the Profiles collection property.
Dim profileSetting As ProfileSettings = New ProfileSettings("Default")
profileSetting.Name = "Custom"
profileSetting.MaxLimit = Int32.MaxValue
profileSetting.MinInstances = 1
profileSetting.MinInterval = TimeSpan.Parse("00:01:00")
profileSetting.Custom = "MyEvaluators.MyCustomeEvaluator, MyCustom.dll"
healthMonitoringSection.Profiles.Add(profileSetting)
' Add a ProfileSettings object to the Profiles collection property.
healthMonitoringSection.Profiles.Add(new ProfileSettings("Default"))
' Add a ProfileSettings object to the Profiles collection property.
healthMonitoringSection.Profiles.Add(new ProfileSettings("Critical", _
1, 1024, new TimeSpan(0, 0, 00)))
' Add a ProfileSettings object to the Profiles collection property.
healthMonitoringSection.Profiles.Add(new ProfileSettings("Targeted", _
1, Int32.MaxValue, new TimeSpan(0, 0, 10), _
"MyEvaluators.MyTargetedEvaluator, MyCustom.dll"))
' Insert an ProfileSettings object into the Profiles collection property.
healthMonitoringSection.Profiles.Insert(1, new ProfileSettings("Default2"))
' Display contents of the Profiles collection property
Console.WriteLine( _
"Profiles Collection contains {0} values:", _
healthMonitoringSection.Profiles.Count)
' Display all elements.
For i As System.Int32 = 0 To healthMonitoringSection.Profiles.Count - 1
profileSetting = healthMonitoringSection.Profiles(i)
Dim name As String = profileSetting.Name
Dim minInstances As Integer = profileSetting.MinInstances
Dim maxLimit As Integer = profileSetting.MaxLimit
Dim minInterval As TimeSpan = profileSetting.MinInterval
Dim custom As String = profileSetting.Custom
Dim item As String = "Name='" & name & _
"', MinInstances = '" & minInstances & "', MaxLimit = '" & maxLimit & _
"', MinInterval = '" & minInterval.ToString() & "', Custom = '" & custom & "'"
Console.WriteLine(" Item {0}: {1}", i, item)
Next
' See if the ProfileSettings collection property contains the event 'Default'.
Console.WriteLine("Profiles contains 'Default': {0}.", _
healthMonitoringSection.Profiles.Contains("Default"))
' Get the index of the 'Default' ProfileSettings in the Profiles collection property.
Console.WriteLine("Profiles index for 'Default': {0}.", _
healthMonitoringSection.Profiles.IndexOf("Default"))
' Get a named ProfileSettings
profileSetting = healthMonitoringSection.Profiles("Default")
' Remove a ProfileSettings object from the Profiles collection property.
healthMonitoringSection.Profiles.Remove("Default")
' Remove a ProfileSettings object from the Profiles collection property.
healthMonitoringSection.Profiles.RemoveAt(0)
' Clear all ProfileSettings object from the Profiles collection property.
healthMonitoringSection.Profiles.Clear()