RuleSettings Klasa

Definicja

Konfiguruje reguły zdarzeń ASP.NET. Klasa ta nie może być dziedziczona.

public ref class RuleSettings sealed : System::Configuration::ConfigurationElement
public sealed class RuleSettings : System.Configuration.ConfigurationElement
type RuleSettings = class
    inherit ConfigurationElement
Public NotInheritable Class RuleSettings
Inherits ConfigurationElement
Dziedziczenie

Przykłady

Poniższy fragment pliku konfiguracji pokazuje, jak deklaratywnie określić właściwości RuleSettings klasy.

<healthMonitoring>
    <rules>
        <add name="All Errors Default"
            eventName="All Errors"
            provider="EventLogProvider"
            profile="Default"
            minInterval="00:01:00"
        />
        <add name="All Audits Default"
            eventName="All Audits"
            provider="SqlWebEventProvider"
            profile="Default"
            minInterval="00:00:30"
        />
        <add name="Failure Audits Default"
            eventName="Failure Audits"
            provider="WmiWebEventProvider"
            profile="Critical"
            minInterval="00:00:30"
        />
        <add name="Request Processing Errors"
            eventName="Request Processing Errors"
            provider="CriticalMailEventProvider"
            profile="Default"
        />
        <add name="Infrastructure Notifications"
            eventName="Infrastructure Errors"
            provider="CriticalMailEventProvider"
            profile="Critical"
        />
   </rules>
</healthMonitoring>

W poniższym przykładzie kodu pokazano, jak utworzyć i ustawić wartości RuleSettings typu. Ten przykład kodu jest częścią większego przykładu udostępnionego dla klasy HealthMonitoringSection.

// Add a RuleSettings object to the Rules collection property.
RuleSettings ruleSetting = new RuleSettings("All Errors Default",
    "All Errors", "EventLogProvider");
ruleSetting.Name = "All Errors Custom";
ruleSetting.EventName = "All Errors";
ruleSetting.Provider = "EventLogProvider";
ruleSetting.Profile = "Custom";
ruleSetting.MaxLimit = Int32.MaxValue;
ruleSetting.MinInstances = 1;
ruleSetting.MinInterval = TimeSpan.Parse("00:00:30");
ruleSetting.Custom = "MyEvaluators.MyCustomeEvaluator2, MyCustom.dll";
healthMonitoringSection.Rules.Add(ruleSetting);
' Add a RuleSettings object to the Rules collection property.
Dim ruleSetting As RuleSettings = new RuleSettings("All Errors Default", _
    "All Errors", "EventLogProvider")
ruleSetting.Name = "All Errors Custom"
ruleSetting.EventName = "All Errors"
ruleSetting.Provider = "EventLogProvider"
ruleSetting.Profile = "Custom"
ruleSetting.MaxLimit = Int32.MaxValue
ruleSetting.MinInstances = 1
ruleSetting.MinInterval = TimeSpan.Parse("00:00:30")
ruleSetting.Custom = "MyEvaluators.MyCustomeEvaluator2, MyCustom.dll"
healthMonitoringSection.Rules.Add(ruleSetting)

Poniższy przykład kodu przedstawia sposób pobierania i wyświetlania RuleSettings wartości typu. Ten przykład kodu jest częścią większego przykładu udostępnionego dla klasy HealthMonitoringSection.

// Display contents of the Rules collection property
Console.WriteLine(
    "Rules Collection contains {0} values:", healthMonitoringSection.Rules.Count);

// Display all elements.
for (System.Int32 i = 0; i < healthMonitoringSection.Rules.Count; i++)
{
ruleSetting = healthMonitoringSection.Rules[i];
string name = ruleSetting.Name;
string eventName = ruleSetting.EventName;
string provider = ruleSetting.Provider;
string profile = ruleSetting.Profile;
int minInstances = ruleSetting.MinInstances;
int maxLimit = ruleSetting.MaxLimit;
TimeSpan minInterval = ruleSetting.MinInterval;
string custom = ruleSetting.Custom;
    string item = "Name='" + name + "', EventName='" + eventName +
        "', Provider =  '" + provider + "', Profile =  '" + profile +
        "', MinInstances =  '" + minInstances + "', MaxLimit =  '" + maxLimit +
        "', MinInterval =  '" + minInterval + "', Custom =  '" + custom + "'";
    Console.WriteLine("  Item {0}: {1}", i, item);
}
' Display contents of the Rules collection property
Console.WriteLine( _
    "Rules Collection contains {0} values:", healthMonitoringSection.Rules.Count)

' Display all elements.
For i As System.Int32 = 0 To healthMonitoringSection.Rules.Count -1
ruleSetting = healthMonitoringSection.Rules(i)
Dim name As String = ruleSetting.Name
Dim eventName As String = ruleSetting.EventName
Dim provider As String = ruleSetting.Provider
Dim profile As String = ruleSetting.Profile
Dim minInstances As Integer = ruleSetting.MinInstances
Dim maxLimit As Integer = ruleSetting.MaxLimit
Dim minInterval As TimeSpan = ruleSetting.MinInterval
Dim custom As String = ruleSetting.Custom
    Dim item As String = "Name='" & name & "', EventName='" & eventName & _
        "', Provider =  '" & provider & "', Profile =  '" & profile & _
        "', MinInstances =  '" & minInstances & "', MaxLimit =  '" & maxLimit & _
        "', MinInterval =  '" & minInterval.ToString() & "', Custom =  '" & custom & "'"
    Console.WriteLine("  Item {0}: {1}", i, item)
Next

Uwagi

Reguły zdarzeń określają, które zdarzenie, przy użyciu którego profilu, jest wyzwalane do którego dostawcy.

Konstruktory

Nazwa Opis
RuleSettings(String, String, String, String, Int32, Int32, TimeSpan, String)

Inicjuje BufferModeSettings nowe wystąpienie klasy, w którym określono wszystkie wartości.

RuleSettings(String, String, String, String, Int32, Int32, TimeSpan)

Inicjuje RuleSettings nowe wystąpienie klasy, w którym określono wszystkie wartości z wyjątkiem tych klasy Custom .

RuleSettings(String, String, String)

Inicjuje nowe wystąpienie RuleSettings klasy przy użyciu ustawień domyślnych, ale określono nazwę, nazwę zdarzenia i dostawcę.

Właściwości

Nazwa Opis
CurrentConfiguration

Pobiera odwołanie do wystąpienia najwyższego poziomu Configuration, które reprezentuje hierarchię konfiguracji, do którego należy bieżące wystąpienie ConfigurationElement.

(Odziedziczone po ConfigurationElement)
Custom

Pobiera lub ustawia w pełni kwalifikowany typ klasy niestandardowej, która implementuje IWebEventCustomEvaluatorelement .

ElementInformation

Pobiera obiekt ElementInformation zawierający informacje i funkcje obiektu ConfigurationElement, które nie można dostosowywać.

(Odziedziczone po ConfigurationElement)
ElementProperty

Pobiera obiekt ConfigurationElementProperty reprezentujący sam obiekt ConfigurationElement.

(Odziedziczone po ConfigurationElement)
EvaluationContext

Pobiera obiekt ContextInformation dla obiektu ConfigurationElement.

(Odziedziczone po ConfigurationElement)
EventName

Pobiera lub ustawia nazwę EventMappingSettings obiektu, do których ma zastosowanie ta reguła.

HasContext

Pobiera wartość wskazującą, czy właściwość CurrentConfiguration jest null.

(Odziedziczone po ConfigurationElement)
Item[ConfigurationProperty]

Pobiera lub ustawia właściwość lub atrybut tego elementu konfiguracji.

(Odziedziczone po ConfigurationElement)
Item[String]

Pobiera lub ustawia właściwość, atrybut lub element podrzędny tego elementu konfiguracji.

(Odziedziczone po ConfigurationElement)
LockAllAttributesExcept

Pobiera kolekcję zablokowanych atrybutów.

(Odziedziczone po ConfigurationElement)
LockAllElementsExcept

Pobiera kolekcję zablokowanych elementów.

(Odziedziczone po ConfigurationElement)
LockAttributes

Pobiera kolekcję zablokowanych atrybutów.

(Odziedziczone po ConfigurationElement)
LockElements

Pobiera kolekcję zablokowanych elementów.

(Odziedziczone po ConfigurationElement)
LockItem

Pobiera lub ustawia wartość wskazującą, czy element jest zablokowany.

(Odziedziczone po ConfigurationElement)
MaxLimit

Pobiera lub ustawia maksymalną liczbę zgłoszonych zdarzeń tego samego typu.

MinInstances

Pobiera lub ustawia minimalną liczbę wystąpień tego samego typu zdarzenia, zanim zdarzenie zostanie zgłoszone do dostawcy.

MinInterval

Pobiera lub ustawia minimalny interwał czasu między dwoma zdarzeniami tego samego typu.

Name

Pobiera lub ustawia nazwę RuleSettings obiektu.

Profile

Pobiera lub ustawia nazwę ProfileSettings obiektu, do których ma zastosowanie ta reguła.

Properties

Pobiera kolekcję właściwości.

(Odziedziczone po ConfigurationElement)
Provider

Pobiera lub ustawia nazwę ProviderSettings obiektu, do których ma zastosowanie ta reguła.

Metody

Nazwa Opis
DeserializeElement(XmlReader, Boolean)

Odczytuje kod XML z pliku konfiguracji.

(Odziedziczone po ConfigurationElement)
Equals(Object)

Porównuje bieżące wystąpienie ConfigurationElement z określonym obiektem.

(Odziedziczone po ConfigurationElement)
GetHashCode()

Pobiera unikatową wartość reprezentującą bieżące wystąpienie ConfigurationElement.

(Odziedziczone po ConfigurationElement)
GetTransformedAssemblyString(String)

Zwraca przekształconą wersję określonej nazwy zestawu.

(Odziedziczone po ConfigurationElement)
GetTransformedTypeString(String)

Zwraca przekształconą wersję określonej nazwy typu.

(Odziedziczone po ConfigurationElement)
GetType()

Pobiera Type bieżącego wystąpienia.

(Odziedziczone po Object)
Init()

Ustawia obiekt ConfigurationElement na stan początkowy.

(Odziedziczone po ConfigurationElement)
InitializeDefault()

Służy do inicjowania domyślnego zestawu wartości dla obiektu ConfigurationElement.

(Odziedziczone po ConfigurationElement)
IsModified()

Wskazuje, czy ten element konfiguracji został zmodyfikowany od czasu ostatniego zapisania lub załadowania, gdy został zaimplementowany w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
IsReadOnly()

Pobiera wartość wskazującą, czy obiekt ConfigurationElement jest tylko do odczytu.

(Odziedziczone po ConfigurationElement)
ListErrors(IList)

Dodaje błędy nieprawidłowej właściwości w tym obiekcie ConfigurationElement i we wszystkich elementach podrzędnych do przekazanej listy.

(Odziedziczone po ConfigurationElement)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Object.

(Odziedziczone po Object)
OnDeserializeUnrecognizedAttribute(String, String)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany atrybut.

(Odziedziczone po ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

Pobiera wartość wskazującą, czy podczas deserializacji napotkano nieznany element.

(Odziedziczone po ConfigurationElement)
OnRequiredPropertyNotFound(String)

Zgłasza wyjątek, gdy nie można odnaleźć wymaganej właściwości.

(Odziedziczone po ConfigurationElement)
PostDeserialize()

Wywoływana po deserializacji.

(Odziedziczone po ConfigurationElement)
PreSerialize(XmlWriter)

Wywoływana przed serializacji.

(Odziedziczone po ConfigurationElement)
Reset(ConfigurationElement)

Resetuje stan wewnętrzny obiektu ConfigurationElement, w tym blokady i kolekcje właściwości.

(Odziedziczone po ConfigurationElement)
ResetModified()

Resetuje wartość metody IsModified(), aby false po zaimplementowaniu w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SerializeElement(XmlWriter, Boolean)

Zapisuje zawartość tego elementu konfiguracji w pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SerializeToXmlElement(XmlWriter, String)

Zapisuje zewnętrzne tagi tego elementu konfiguracji do pliku konfiguracji po zaimplementowaniu w klasie pochodnej.

(Odziedziczone po ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

Ustawia właściwość na określoną wartość.

(Odziedziczone po ConfigurationElement)
SetReadOnly()

Ustawia właściwość IsReadOnly() dla obiektu ConfigurationElement i wszystkich podelementów.

(Odziedziczone po ConfigurationElement)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Modyfikuje obiekt ConfigurationElement, aby usunąć wszystkie wartości, które nie powinny być zapisywane.

(Odziedziczone po ConfigurationElement)

Dotyczy

Zobacz też