ProfileSettingsCollection Class
Contains a collection of ProfileSettings objects. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
ProfileSettings objects are used to define event profiles.
The following code example shows how to use the ProfileSettingsCollection type. This code example is part of a larger example provided for the HealthMonitoringSection class.
// 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();
System.Configuration.ConfigurationElement
System.Configuration.ConfigurationElementCollection
System.Web.Configuration.ProfileSettingsCollection
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.