Class NetworkRule
- Namespace
- SpatialNET.Network
- Assembly
- SpatialNET.Network.dll
A rule that counts the direct neighbours of an element and compares the count with an allowed range (ADR 0052). Build one with SpatialNET.Network.NetworkRule.ForNodes(System.String,SpatialNET.Network.TypeSet) or SpatialNET.Network.NetworkRule.ForEdges(System.String,SpatialNET.Network.TypeSet), or resolve a SpatialNET.Network.NetworkRuleDefinition with SpatialNET.Network.NetworkRule.FromDefinition(SpatialNET.Network.NetworkRuleDefinition,SpatialNET.Network.TypeRegistry). Immutable and thread-safe; use it for any number of checks (SpatialNET.Network.NetworkValidation).
public sealed class NetworkRuleInheritance
Inherited Members
Properties
CountTypes
The edge types that are counted.
public TypeSet CountTypes { get; }Property Value
EndFilter
For an edge rule, which ends are checked.
public RuleEndFilter EndFilter { get; }Property Value
EndTypes
The node types of SpatialNET.Network.NetworkRule.EndFilter; null for SpatialNET.Network.RuleEndFilter.All.
public TypeSet? EndTypes { get; }Property Value
Id
The id of the rule.
public string Id { get; }Property Value
Max
The largest allowed count; null for no upper limit.
public int? Max { get; }Property Value
- int?
Min
The smallest allowed count.
public int Min { get; }Property Value
Severity
How serious a violation is.
public RuleSeverity Severity { get; }Property Value
Subject
Whether the rule checks nodes or edges.
public RuleSubject Subject { get; }Property Value
SubjectTypes
The types that are checked.
public TypeSet SubjectTypes { get; }Property Value
Methods
AsWarning()
The same rule with the severity SpatialNET.Network.RuleSeverity.Warning.
public NetworkRule AsWarning()Returns
ForEdges(string, TypeSet)
Starts a rule that checks the edges of the given types and counts the other edges at their ends.
public static EdgeRuleBuilder ForEdges(string id, TypeSet subjectTypes)Parameters
Returns
Exceptions
- ArgumentNullException
-
subjectTypesisnull. - ArgumentException
-
idisnull, empty or white space.
ForNodes(string, TypeSet)
Starts a rule that checks the nodes of the given types and counts the edges at them.
public static NodeRuleBuilder ForNodes(string id, TypeSet subjectTypes)Parameters
idstring-
The id of the rule; not empty.
subjectTypesTypeSet-
The node types to check; SpatialNET.Network.TypeSet.Untyped addresses helper nodes.
Returns
Exceptions
- ArgumentNullException
-
subjectTypesisnull. - ArgumentException
-
idisnull, empty or white space.
FromDefinition(NetworkRuleDefinition, TypeRegistry)
Resolves a row into a rule, with the patterns resolved against the type registry.
public static NetworkRule FromDefinition(NetworkRuleDefinition definition, TypeRegistry types)Parameters
definitionNetworkRuleDefinition-
The row.
typesTypeRegistry-
The types of the network.
Returns
Exceptions
- ArgumentNullException
-
An argument is
null. - ArgumentException
-
The definition cannot be a rule: no id, a pattern that cannot be read, that matches no type or only a type of the wrong kind, an end filter on a node rule, or end types without an end filter. The message names the rule id.
- ArgumentOutOfRangeException
-
Minis below 0 or aboveMax; the message names the rule id.
ToDefinition()
Gives the rule as a row, so that SpatialNET.Network.NetworkRule.FromDefinition(SpatialNET.Network.NetworkRuleDefinition,SpatialNET.Network.TypeRegistry) resolves it to an equal rule.
public NetworkRuleDefinition ToDefinition()Returns
Exceptions
- InvalidOperationException
-
A type set of the rule was made from type ids (SpatialNET.Network.TypeSet.Of(System.Collections.Generic.IEnumerable{System.Int32})) and has no pattern text. Rules from SpatialNET.Network.NetworkRule.FromDefinition(SpatialNET.Network.NetworkRuleDefinition,SpatialNET.Network.TypeRegistry) and from sets resolved by a SpatialNET.Network.TypeRegistry always have it.
ToString()
A readable form for reports, for example KV-FREIES-ENDE: edges [*, Kastenverbinder, ], ends not [, Kasten, ], other edges [, Leitung, *] = 1. For people, not for parsing.
public override string ToString()