Table of Contents

Class XlinkResolver

Namespace
EncDotNet.S100.DataModel
Assembly
EncDotNet.S100.Core.dll

Resolves xlink:href cross-references against a pre-built index of a dataset's features and information types, keyed by gml:id (case-insensitive).

public sealed class XlinkResolver
Inheritance
XlinkResolver
Inherited Members

Remarks

Build an instance with Build(IEnumerable<KeyValuePair<string, object>>) at the top of a typed-model projection, then use Resolve<T>(string, string, ProjectionContext, string?) to follow each xlink:href. Unresolved references emit a Warning diagnostic with code "xlink.unresolved"; the typed model never throws for a missing target.

The lookup table accepts heterogeneous object types — features and information types from any S-100 product. The generic type parameter on Resolve<T>(string, string, ProjectionContext, string?) filters by the expected destination type, so a caller resolving a routeWaypoint reference can ask for T = S421Feature and receive null (plus a diagnostic) if the target happens to be an information type instead.

Methods

Build(IEnumerable<KeyValuePair<string, object>>)

Builds an xlink lookup from the supplied features and information types. Each object must expose a gml:id-style identifier; objects with a null or empty identifier are silently skipped (they are unreachable by xlink).

public static XlinkResolver Build(IEnumerable<KeyValuePair<string, object>> objects)

Parameters

objects IEnumerable<KeyValuePair<string, object>>

The objects to index. Pairs of (identifier, object) — typically built by enumerating the dataset's features and information types and projecting their Id property.

Returns

XlinkResolver

Contains(string)

Returns true if the supplied xlink:href target is present in the index. The leading # on a fragment identifier is stripped before lookup.

public bool Contains(string href)

Parameters

href string

Returns

bool

ResolveAny(string, string, ProjectionContext, string?)

Resolves an xlink:href without filtering by type. Useful when the caller needs to dispatch on the runtime type of the target (e.g. for references that may point to either a feature or an information type).

public object? ResolveAny(string href, string role, ProjectionContext context, string? relatedId = null)

Parameters

href string
role string
context ProjectionContext
relatedId string

Returns

object

Resolve<T>(string, string, ProjectionContext, string?)

Resolves an xlink:href value to a typed object. Returns null and reports a "xlink.unresolved" diagnostic when the target is missing or has a different type than T.

public T? Resolve<T>(string href, string role, ProjectionContext context, string? relatedId = null) where T : class

Parameters

href string

The raw xlink:href value.

role string

The association role (used for diagnostic text).

context ProjectionContext

The projection context for diagnostic reporting.

relatedId string

The gml:id of the referring object, if any.

Returns

T

Type Parameters

T

The expected destination object type.