Loupe - Log - Monitor - Resolve
Gibraltar.Agent.Metrics Namespace / EventMetricDefinition Class / TryGetValue Method / TryGetValue(Type,EventMetricDefinition) Method
A specific Type with attributes defining an event metric.
The output variable to receive the EventMetricDefinition object if found (null if not).

In This Topic
    TryGetValue(Type,EventMetricDefinition) Method
    In This Topic
    Find an existing event metric definition previously registered via EventMetric and EventMetricValue attributes on a specific Type.
    Syntax
    'Declaration
     
    
    Public Overloads Shared Function TryGetValue( _
       ByVal metricDataObjectType As Type, _
       ByRef value As EventMetricDefinition _
    ) As Boolean
    public static bool TryGetValue( 
       Type metricDataObjectType,
       out EventMetricDefinition value
    )

    Parameters

    metricDataObjectType
    A specific Type with attributes defining an event metric.
    value
    The output variable to receive the EventMetricDefinition object if found (null if not).

    Return Value

    False if no EventMetric attribute is found on the specified Type, or if no metric definition is registered with the 3-part Key found in that attribute, true if an EventMetricDefinition is registered with the given Key, or throws an exception if the registered definition found is not an EventMetricDefinition.
    Remarks
    This method overload can obtain a previously registered EventMetricDefinition created through EventMetric and EventMetricValue attributes, by specifying the Type containing those attributes. If the specified Type does not have an EventMetric attribute defined, or if the Type has an EventMetric attribute but has not been registered (e.g. by a call to EventMetricDefinition.Register(userObjectType)), then false is returned (with out value set to null). If an event metric defined by attributes on that Type has been successfully registered, then true is returned (with the registered EventMetricDefinition stored in the out value). If the metric definition found by the 3-part Key used in the EventMetric attribute is not an event metric (e.g. a sampled metric definition was registered with that Key), then an ArgumentException is thrown to signal your programming mistake. Inheritance and interfaces will not be searched, so the specified Type must directly define an event metric, but valid objects of a type assignable to the specified bound Type of this definition can be sampled from the specific event metric definition found.
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also