Chat Support
Loupe - Log - Monitor - Resolve
Gibraltar.Agent.Metrics Namespace / SampledMetricDefinition Class / TryGetValue Method / TryGetValue(Type,String,SampledMetricDefinition) Method
A specific Type with attributes defining one or more sampled metrics.
The counter name of the desired individual sampled metric definition defined by attributes on the specified Type.
The output variable to receive the SampledMetricDefinition object if found (null if not).

In This Topic
    TryGetValue(Type,String,SampledMetricDefinition) Method
    In This Topic
    Find an existing sampled metric definition previously registered via SampledMetric and SampledMetricValue attributes on a specific Type, by its counter name.
    Syntax
    'Declaration
     
    
    Public Overloads Shared Function TryGetValue( _
       ByVal userObjectType As Type, _
       ByVal counterName As String, _
       ByRef value As SampledMetricDefinition _
    ) As Boolean

    Parameters

    userObjectType
    A specific Type with attributes defining one or more sampled metrics.
    counterName
    The counter name of the desired individual sampled metric definition defined by attributes on the specified Type.
    value
    The output variable to receive the SampledMetricDefinition object if found (null if not).

    Return Value

    False if no SampledMetric attribute is found on the specified Type, or if no metric definition is registered with the 3-part Key found in that attribute (combined with the specified counter name), true if a SampledMetricDefinition is registered with the given Key, or throws an exception if the registered definition found is not a SampledMetricDefinition.
    Exceptions
    ExceptionDescription
    The userObjectType or counterName was null or empty.
    The metric definition found for the specified key is not a sampled metric definition.
    Remarks
    This method overload can obtain a previously registered SampledMetricDefinition created through SampledMetric and SampledMetricValue attributes, by specifying the Type containing those attributes. If the specified Type does not have a SampledMetric attribute defined, or if the Type has a SampledMetric attribute but has not been registered (e.g. by a call to SampledMetricDefinition.Register(userObjectType)), then false is returned (with out value set to null). If a sampled metric defined by attributes on that Type has been successfully registered, then true is returned (with the registered SampledMetricDefinition stored in the out value). If the metric definition found by the 3-part Key used in the SampledMetric attribute (along with the specified counter name) is not a sampled metric (e.g. an event 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 the sampled metric, but valid objects of a type assignable to the specified bound Type of this definition can be sampled from the specific sampled 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