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>._constantsLinksDecoratorBase<TLinkAddress>._facadeLinksDecoratorBase<TLinkAddress>.FacadeLinksDecoratorBase<TLinkAddress>.ConstantsLinksOperatorBase<TLinkAddress>._linksLinksOperatorBase<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
TypesDecorator(INamedTypesLinks<TLinkAddress>)
A hierarchy whose markers are the points named Type and
Extends, created when missing.
public TypesDecorator(INamedTypesLinks<TLinkAddress> links)
Parameters
linksINamedTypesLinks<TLinkAddress>
TypesDecorator(ILinks<TLinkAddress>, TypeMarkers<TLinkAddress>)
public TypesDecorator(ILinks<TLinkAddress> links, TypeMarkers<TLinkAddress> markers)
Parameters
linksILinks<TLinkAddress>markersTypeMarkers<TLinkAddress>
TypesDecorator(ILinks<TLinkAddress>, TLinkAddress)
A hierarchy without multiple inheritance.
public TypesDecorator(ILinks<TLinkAddress> links, TLinkAddress root)
Parameters
linksILinks<TLinkAddress>rootTLinkAddress
TypesDecorator(ILinks<TLinkAddress>, TLinkAddress, TLinkAddress)
public TypesDecorator(ILinks<TLinkAddress> links, TLinkAddress root, TLinkAddress extendsMarker)
Parameters
linksILinks<TLinkAddress>rootTLinkAddressextendsMarkerTLinkAddress
Fields
ExtendsName
The name of the Extends marker point.
public const string ExtendsName = "Extends"
Field Value
RootName
The name of the root type point.
public const string RootName = "Type"
Field Value
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
typeTLinkAddress
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
parentTLinkAddressmoreTLinkAddress[]
Returns
- TLinkAddress
EnsureMarkers(ILinks<TLinkAddress>, INamedTypes<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
linksILinks<TLinkAddress>namesINamedTypes<TLinkAddress>
Returns
- TypeMarkers<TLinkAddress>
EnsurePoint(ILinks<TLinkAddress>, INamedTypes<TLinkAddress>, string)
The point named name, created and named when missing.
public static TLinkAddress EnsurePoint(ILinks<TLinkAddress> links, INamedTypes<TLinkAddress> names, string name)
Parameters
linksILinks<TLinkAddress>namesINamedTypes<TLinkAddress>namestring
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
typeTLinkAddressparentTLinkAddress
Returns
- TLinkAddress
Instance(TLinkAddress)
A value (v: type v) of type.
public virtual TLinkAddress Instance(TLinkAddress type)
Parameters
typeTLinkAddress
Returns
- TLinkAddress
Instance(TLinkAddress, TLinkAddress)
A value (v: type target) of type.
public virtual TLinkAddress Instance(TLinkAddress type, TLinkAddress target)
Parameters
typeTLinkAddresstargetTLinkAddress
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
linkIList<TLinkAddress>typeTLinkAddress
Returns
IsA(TLinkAddress, TLinkAddress)
Whether link is type itself or of it.
public virtual bool IsA(TLinkAddress link, TLinkAddress type)
Parameters
linkTLinkAddresstypeTLinkAddress
Returns
IsExtension(TLinkAddress)
Whether link is a pair that gives a type one more parent.
public virtual bool IsExtension(TLinkAddress link)
Parameters
linkTLinkAddress
Returns
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
linkIList<TLinkAddress>typeTLinkAddress
Returns
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
linkTLinkAddresstypeTLinkAddress
Returns
IsType(TLinkAddress)
Whether link is a type: it exists and points at itself.
public virtual bool IsType(TLinkAddress link)
Parameters
linkTLinkAddress
Returns
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
typeTLinkAddress
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
linkTLinkAddress
Returns
- TLinkAddress