Table of Contents

Class TypesDecorator<TLinkAddress>

Namespace
Foundation.Data.Doublets.Cli
Assembly
Foundation.Data.Doublets.Cli.dll

A decorator that keeps a type hierarchy with recursive sub-typing and multiple inheritance in the links themselves. It is the C# port of typeSystem of @link-foundation/ui-links; the Rust counterpart is link_cli::TypesDecorator.

public class TypesDecorator<TLinkAddress> : LinksDecoratorBase<TLinkAddress>, ILinks<TLinkAddress>, ILinks<TLinkAddress, LinksConstants<TLinkAddress>>, ITypes<TLinkAddress> where TLinkAddress : struct, IUnsignedNumber<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>, IShiftOperators<TLinkAddress, int, TLinkAddress>, IBitwiseOperators<TLinkAddress, TLinkAddress, TLinkAddress>, IMinMaxValue<TLinkAddress>

Type Parameters

TLinkAddress
Inheritance
LinksOperatorBase<TLinkAddress>
LinksDecoratorBase<TLinkAddress>
TypesDecorator<TLinkAddress>
Implements
ILinks<TLinkAddress>
ILinks<TLinkAddress, LinksConstants<TLinkAddress>>
ITypes<TLinkAddress>
Inherited Members
LinksDecoratorBase<TLinkAddress>._constants
LinksDecoratorBase<TLinkAddress>._facade
LinksDecoratorBase<TLinkAddress>.Facade
LinksDecoratorBase<TLinkAddress>.Constants
LinksOperatorBase<TLinkAddress>._links
LinksOperatorBase<TLinkAddress>.Links
Extension Methods

Remarks

The pinned types of PinnedTypesDecorator<TLinkAddress> are (1: 1 1), (2: 1 2), (3: 1 3), …: with the root at address 1 they are sub-types of it, so a pinned store is already a hierarchy. Queries read the decorated links; writes go through this decorator, so a derived decorator that checks writes sees them. The class is not sealed and every member is virtual.

Constructors

A hierarchy whose markers are the points named Type and Extends, created when missing.

public TypesDecorator(INamedTypesLinks<TLinkAddress> links)

Parameters

links INamedTypesLinks<TLinkAddress>
public TypesDecorator(ILinks<TLinkAddress> links, TypeMarkers<TLinkAddress> markers)

Parameters

links ILinks<TLinkAddress>
markers TypeMarkers<TLinkAddress>

A hierarchy without multiple inheritance.

public TypesDecorator(ILinks<TLinkAddress> links, TLinkAddress root)

Parameters

links ILinks<TLinkAddress>
root TLinkAddress
public TypesDecorator(ILinks<TLinkAddress> links, TLinkAddress root, TLinkAddress extendsMarker)

Parameters

links ILinks<TLinkAddress>
root TLinkAddress
extendsMarker TLinkAddress

Fields

ExtendsName

The name of the Extends marker point.

public const string ExtendsName = "Extends"

Field Value

string

RootName

The name of the root type point.

public const string RootName = "Type"

Field Value

string

Properties

Extends

The Extends marker, or the null link when there is none.

public TLinkAddress Extends { get; }

Property Value

TLinkAddress

Root

The root type, (Type: Type Type).

public TLinkAddress Root { get; }

Property Value

TLinkAddress

Methods

AncestorsOf(TLinkAddress)

Every type type is, itself first, breadth first, without repeats.

public virtual IReadOnlyList<TLinkAddress> AncestorsOf(TLinkAddress type)

Parameters

type TLinkAddress

Returns

IReadOnlyList<TLinkAddress>

Define()

Defines a direct sub-type of Root.

public virtual TLinkAddress Define()

Returns

TLinkAddress

Define(TLinkAddress, params TLinkAddress[])

Defines a type (S: parent S) that also extends every type in more.

public virtual TLinkAddress Define(TLinkAddress parent, params TLinkAddress[] more)

Parameters

parent TLinkAddress
more TLinkAddress[]

Returns

TLinkAddress

The points named Type and Extends, each created as a point (x: x x) and named when missing.

public static TypeMarkers<TLinkAddress> EnsureMarkers(ILinks<TLinkAddress> links, INamedTypes<TLinkAddress> names)

Parameters

links ILinks<TLinkAddress>
names INamedTypes<TLinkAddress>

Returns

TypeMarkers<TLinkAddress>

The point named name, created and named when missing.

public static TLinkAddress EnsurePoint(ILinks<TLinkAddress> links, INamedTypes<TLinkAddress> names, string name)

Parameters

links ILinks<TLinkAddress>
names INamedTypes<TLinkAddress>
name string

Returns

TLinkAddress

Extend(TLinkAddress, TLinkAddress)

Makes type extend parent: the pair (p: type parent) marked by (m: Extends p). Returns the pair. Refused when parent is a direct sub-type (parent: type parent) of type, whose definition is that very doublet.

public virtual TLinkAddress Extend(TLinkAddress type, TLinkAddress parent)

Parameters

type TLinkAddress
parent TLinkAddress

Returns

TLinkAddress

Instance(TLinkAddress)

A value (v: type v) of type.

public virtual TLinkAddress Instance(TLinkAddress type)

Parameters

type TLinkAddress

Returns

TLinkAddress

Instance(TLinkAddress, TLinkAddress)

A value (v: type target) of type.

public virtual TLinkAddress Instance(TLinkAddress type, TLinkAddress target)

Parameters

type TLinkAddress
target TLinkAddress

Returns

TLinkAddress

IsA(IList<TLinkAddress>, TLinkAddress)

IsA(TLinkAddress, TLinkAddress) for a link given as (index, source, target), stored or not.

public virtual bool IsA(IList<TLinkAddress> link, TLinkAddress type)

Parameters

link IList<TLinkAddress>
type TLinkAddress

Returns

bool

IsA(TLinkAddress, TLinkAddress)

Whether link is type itself or of it.

public virtual bool IsA(TLinkAddress link, TLinkAddress type)

Parameters

link TLinkAddress
type TLinkAddress

Returns

bool

IsExtension(TLinkAddress)

Whether link is a pair that gives a type one more parent.

public virtual bool IsExtension(TLinkAddress link)

Parameters

link TLinkAddress

Returns

bool

IsOf(IList<TLinkAddress>, TLinkAddress)

IsOf(TLinkAddress, TLinkAddress) for a link given as (index, source, target), stored or not.

public virtual bool IsOf(IList<TLinkAddress> link, TLinkAddress type)

Parameters

link IList<TLinkAddress>
type TLinkAddress

Returns

bool

IsOf(TLinkAddress, TLinkAddress)

Whether link is strictly of type: starting from its source and the types the link itself extends, through any depth of sub-types and parents, cycles included. A type is not of itself; IsA(TLinkAddress, TLinkAddress) is.

public virtual bool IsOf(TLinkAddress link, TLinkAddress type)

Parameters

link TLinkAddress
type TLinkAddress

Returns

bool

IsType(TLinkAddress)

Whether link is a type: it exists and points at itself.

public virtual bool IsType(TLinkAddress link)

Parameters

link TLinkAddress

Returns

bool

ParentsOf(TLinkAddress)

The direct parents of a type: its source (unless it is a point) and what it extends.

public virtual IReadOnlyList<TLinkAddress> ParentsOf(TLinkAddress type)

Parameters

type TLinkAddress

Returns

IReadOnlyList<TLinkAddress>

TypeOf(TLinkAddress)

The type of a link: its source; the null link for a missing link.

public virtual TLinkAddress TypeOf(TLinkAddress link)

Parameters

link TLinkAddress

Returns

TLinkAddress