Class UnionLinksDecorator<TLinkAddress>
- Namespace
- Foundation.Data.Doublets.Cli
- Assembly
- Foundation.Data.Doublets.Cli.dll
Many links networks seen as one (issue #149): the joining decorator of
a client's links with a server's, of a cache with its source, of the
networks of several services. The JavaScript counterpart is
UnionLinks of @link-foundation/link-cli-client, the Rust one
link_cli::UnionLinks.
public class UnionLinksDecorator<TLinkAddress> : LinksDecoratorBase<TLinkAddress>, INamedTypesLinks<TLinkAddress>, ILinks<TLinkAddress>, ILinks<TLinkAddress, LinksConstants<TLinkAddress>>, INamedTypes<TLinkAddress>, IComposedLinks<TLinkAddress> where TLinkAddress : struct, IUnsignedNumber<TLinkAddress>
Type Parameters
TLinkAddress
- Inheritance
-
LinksOperatorBase<TLinkAddress>LinksDecoratorBase<TLinkAddress>UnionLinksDecorator<TLinkAddress>
- Implements
-
INamedTypesLinks<TLinkAddress>ILinks<TLinkAddress>ILinks<TLinkAddress, LinksConstants<TLinkAddress>>INamedTypes<TLinkAddress>IComposedLinks<TLinkAddress>
- Inherited Members
-
LinksDecoratorBase<TLinkAddress>._constantsLinksDecoratorBase<TLinkAddress>._facadeLinksDecoratorBase<TLinkAddress>.FacadeLinksDecoratorBase<TLinkAddress>.ConstantsLinksOperatorBase<TLinkAddress>._linksLinksOperatorBase<TLinkAddress>.Links
- Extension Methods
Remarks
The members are in order, and the link at an address is the one of the first member that has it: a member shadows the ones after it, as a local overlay of minimongo or minilinks shadows the documents of the server. Reads see the links of every member that are not shadowed. Members whose addresses do not overlap (a RemapLinksDecorator<TLinkAddress> with an OffsetAddressMap<TLinkAddress> moves one out of the way of another) shadow nothing.
A new link is created in the first member, the primary one. An update, a delete and naming go to the member that has the link, so a link stays where it lives; the store of that member resolves the write, merges and cascades included, which keep to that member: a doublet is unique within its member, not across them.
A link created at a given address (EnsureCreated, the undo of a
delete) is created in the first member that claims the address, as a
remap claims the addresses of its map, else in the primary member: see
IComposedLinks<TLinkAddress>.
A link may refer to links of other members: a link of the client typed by a type of the server holds the address of the server's type. Names are found in the members in order, so a name of the primary member wins.
The union depends on no other layer of this library. A PermissionsDecorator<TLinkAddress> over it restricts every member at once, its rules and types coming from any of them, and one under it restricts a single member.
Constructors
UnionLinksDecorator(params INamedTypesLinks<TLinkAddress>[])
public UnionLinksDecorator(params INamedTypesLinks<TLinkAddress>[] members)
Parameters
membersINamedTypesLinks<TLinkAddress>[]The networks, the primary one first.
UnionLinksDecorator(IReadOnlyList<INamedTypesLinks<TLinkAddress>>)
public UnionLinksDecorator(IReadOnlyList<INamedTypesLinks<TLinkAddress>> members)
Parameters
membersIReadOnlyList<INamedTypesLinks<TLinkAddress>>The networks, the primary one first.
Properties
Members
The networks, the primary one first.
public IReadOnlyList<INamedTypesLinks<TLinkAddress>> Members { get; }
Property Value
- IReadOnlyList<INamedTypesLinks<TLinkAddress>>
Primary
The network new links are created in.
public INamedTypesLinks<TLinkAddress> Primary { get; }
Property Value
- INamedTypesLinks<TLinkAddress>
Methods
Claims(TLinkAddress)
Whether a member claims address; a member that is no IComposedLinks<TLinkAddress> claims every address.
public virtual bool Claims(TLinkAddress address)
Parameters
addressTLinkAddress
Returns
Count(IList<TLinkAddress>?)
Counts the restriction.
public override TLinkAddress Count(IList<TLinkAddress>? restriction)
Parameters
restrictionIList<TLinkAddress>The restriction.
Returns
- TLinkAddress
The link
Create(IList<TLinkAddress>?, WriteHandler<TLinkAddress>?)
Creates the restriction.
public override TLinkAddress Create(IList<TLinkAddress>? substitution, WriteHandler<TLinkAddress>? handler)
Parameters
substitutionIList<TLinkAddress>The restriction.
handlerWriteHandler<TLinkAddress>Optional callback; null continues without invoking a callback.
Returns
- TLinkAddress
The link
Delete(IList<TLinkAddress>?, WriteHandler<TLinkAddress>?)
Deletes the restriction.
public override TLinkAddress Delete(IList<TLinkAddress>? restriction, WriteHandler<TLinkAddress>? handler)
Parameters
restrictionIList<TLinkAddress>The restriction.
handlerWriteHandler<TLinkAddress>Optional callback; null continues without invoking a callback.
Returns
- TLinkAddress
Each(IList<TLinkAddress>?, ReadHandler<TLinkAddress>?)
Eaches the handler.
public override TLinkAddress Each(IList<TLinkAddress>? restriction, ReadHandler<TLinkAddress>? handler)
Parameters
restrictionIList<TLinkAddress>The restriction.
handlerReadHandler<TLinkAddress>The handler.
Returns
- TLinkAddress
The link
EnsureCreated(params TLinkAddress[])
Creates the links at addresses that no member has,
each in the first member that is an IComposedLinks<TLinkAddress>
claiming its address (a remap whose map has it), else in the primary one.
public virtual void EnsureCreated(params TLinkAddress[] addresses)
Parameters
addressesTLinkAddress[]
GetByName(string)
The link of name in the first member that has a link of that name it does not shadow.
public virtual TLinkAddress GetByName(string name)
Parameters
namestring
Returns
- TLinkAddress
GetName(TLinkAddress)
The name of link in the member that has it, else in the first member that names it.
public virtual string? GetName(TLinkAddress link)
Parameters
linkTLinkAddress
Returns
OwnerOf(TLinkAddress)
The position of the member the link at index is of, -1 when no member has it.
public virtual int OwnerOf(TLinkAddress index)
Parameters
indexTLinkAddress
Returns
PlaceOf(TLinkAddress)
The position of the member a new link at address is created in.
protected virtual int PlaceOf(TLinkAddress address)
Parameters
addressTLinkAddress
Returns
RemoveName(TLinkAddress)
Unnames link in the member that has it, the primary one when none does.
public virtual void RemoveName(TLinkAddress link)
Parameters
linkTLinkAddress
SetName(TLinkAddress, string)
Names link in the member that has it, the primary one when none does.
public virtual TLinkAddress SetName(TLinkAddress link, string name)
Parameters
linkTLinkAddressnamestring
Returns
- TLinkAddress
Shadowed(int, TLinkAddress)
Whether a member before the one at member has a link at index.
protected bool Shadowed(int member, TLinkAddress index)
Parameters
memberintindexTLinkAddress
Returns
Update(IList<TLinkAddress>?, IList<TLinkAddress>?, WriteHandler<TLinkAddress>?)
Updates the restriction.
public override TLinkAddress Update(IList<TLinkAddress>? restriction, IList<TLinkAddress>? substitution, WriteHandler<TLinkAddress>? handler)
Parameters
restrictionIList<TLinkAddress>The restriction.
substitutionIList<TLinkAddress>The substitution.
handlerWriteHandler<TLinkAddress>Optional callback; null continues without invoking a callback.
Returns
- TLinkAddress
The link