Table of Contents

Interface ICodeMetric<TCodeElement, TNumeric>

Namespace
NDepend.CodeModel
Assembly
NDepend.API.dll

Represent a code metric, a correspondance between a set of code elements and some numerical values.

public interface ICodeMetric<TCodeElement, TNumeric> : IEnumerable<ICodeMetricValue<TCodeElement, TNumeric>>, IEnumerable where TCodeElement : class, ICodeElement where TNumeric : struct

Type Parameters

TCodeElement

The code element type that is ICodeElement or that implements ICodeElement.

TNumeric

The numeric value type that is one of these type: byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal.

Inherited Members
Extension Methods

Remarks

A code metric object is returned by extension methods of ExtensionMethodsSequenceUsage defined on sequences of code elements.
A custom code metric object can also be created through the particular method ExtensionMethodsHelpers.FillIterative<TCodeElement>(IEnumerable<TCodeElement>, Func<IEnumerable<TCodeElement>, IEnumerable<TCodeElement>>).

Properties (6)

DefinitionDomain

Gets the sequence of code elements for which this code metric is defined.

IEnumerable<TCodeElement> DefinitionDomain { get; }

Property Value

IEnumerable<TCodeElement>

Remarks

This method has a O(DefinitionDomainCount) time complexity.

DefinitionDomainCount

Gets the number of code elements for which this code metric is defined.

int DefinitionDomainCount { get; }

Property Value

int

Remarks

This method has a constant time complexity.

this[TCodeElement]

Gets this code metric value for codeElement. Gets null if the metric is not defined for codeElement.

TNumeric? this[TCodeElement codeElement] { get; }

Parameters

codeElement TCodeElement

The code element.

Property Value

TNumeric?

Remarks

This accessor is equivalent to the method ValueOf(TCodeElement).
This method has a constant time complexity.

MaxValue

Gets the the maximum value in this.Values.

TNumeric? MaxValue { get; }

Property Value

TNumeric?

Remarks

If this.DefinitionDomainCount is zero, returns null.
This method has a O(DefinitionDomainCount) time complexity.

MinValue

Gets the the minimum value in this.Values.

TNumeric? MinValue { get; }

Property Value

TNumeric?

Remarks

If this.DefinitionDomainCount is zero, returns null.
This method has a O(DefinitionDomainCount) time complexity.

Values

Gets the sequence of this code metric values taken by all code elements in this.DefinitionDomain. Numeric values are sorted with an ascending order in the sequence.

IEnumerable<TNumeric> Values { get; }

Property Value

IEnumerable<TNumeric>

Remarks

Gets an empty sequence if DefinitionDomain is empty.
Notice that this.Values.Count() can be lower than this.DefinitionDomainCount if several code elements have the same value.
This method has a O(DefinitionDomainCount) time complexity.

Methods (3)

DefinedFor(TCodeElement)

Gets a value indicating whether this code metric is defined for codeElement.

bool DefinedFor(TCodeElement codeElement)

Parameters

codeElement TCodeElement

The code element.

Returns

bool

Remarks

This method has a constant time complexity.

ElementsWithValue(TNumeric)

Gets the sequence of code elements for which, this code metric value is equal to value Gets an empty sequence if no code element are matched.

IEnumerable<TCodeElement> ElementsWithValue(TNumeric value)

Parameters

value TNumeric

The value.

Returns

IEnumerable<TCodeElement>

Remarks

This method has a O(DefinitionDomainCount) time complexity.

ValueOf(TCodeElement)

Gets this code metric value for codeElement. Gets null if the metric is not defined for codeElement.

TNumeric? ValueOf(TCodeElement codeElement)

Parameters

codeElement TCodeElement

The code element.

Returns

TNumeric?

Remarks

This method has a constant time complexity.

See Also

ICodeMetricValue<TCodeElement, TNumeric>
FillIterative<TCodeElement>(IEnumerable<TCodeElement>, Func<IEnumerable<TCodeElement>, IEnumerable<TCodeElement>>)