Table of Contents

Class BuilderBase<TEndpoint>

Namespace
TypedRest.CodeGeneration.TypeScript.Endpoints
Assembly
TypedRest.CodeGeneration.TypeScript.dll

Common base class for IBuilder<TEndpoint>s.

public abstract class BuilderBase<TEndpoint> : IBuilder<TEndpoint>, IBuilder where TEndpoint : IEndpoint

Type Parameters

TEndpoint

The type of IEndpoint to generate code for.

Inheritance
object
BuilderBase<TEndpoint>
Implements
IBuilder<TEndpoint>
Derived

Methods

Build(string, IEndpoint, IEndpointGenerator)

Builds the getter exposing endpoint on its parent, plus any types needed for it.

public (TsGetter getter, IEnumerable<ITsType> types) Build(string key, IEndpoint endpoint, IEndpointGenerator generator)

Parameters

key string
endpoint IEndpoint
generator IEndpointGenerator

Returns

(TsGetter getter, IEnumerable<ITsType> types)

Build(string, TEndpoint, IEndpointGenerator)

Builds the getter exposing endpoint on its parent, plus any types needed for it.

public (TsGetter getter, IEnumerable<ITsType> types) Build(string key, TEndpoint endpoint, IEndpointGenerator generator)

Parameters

key string
endpoint TEndpoint
generator IEndpointGenerator

Returns

(TsGetter getter, IEnumerable<ITsType> types)

BuildConstructor(TEndpoint, List<TsExpression>, IEndpointGenerator)

Builds the constructor of a generated endpoint class, or null to inherit the base constructor.

protected virtual TsConstructor? BuildConstructor(TEndpoint endpoint, List<TsExpression> extraArguments, IEndpointGenerator generator)

Parameters

endpoint TEndpoint
extraArguments List<TsExpression>
generator IEndpointGenerator

Returns

TsConstructor

Remarks

An endpoint that knows its own relative URI bakes it into the super() call and drops the parameter. An endpoint in an element position does not know its URI - it is handed one per element by the collection or indexer that owns it - so it must keep forwarding the parameter. Hard-coding a URI there would still compile, because TypeScript accepts a constructor with fewer parameters where one with more is expected, but every element would silently resolve to the same URI at runtime.

GetBase(string, TEndpoint, IEndpointGenerator)

Returns the TypedRest type the endpoint derives from, any additional types generated along the way, and any constructor arguments beyond the referrer and the relative URI.

protected virtual (TsIdentifier baseType, IEnumerable<ITsType> types, IEnumerable<TsExpression> extraArguments) GetBase(string key, TEndpoint endpoint, IEndpointGenerator generator)

Parameters

key string
endpoint TEndpoint
generator IEndpointGenerator

Returns

(TsIdentifier baseType, IEnumerable<ITsType> types, IEnumerable<TsExpression> extraArguments)

GetBaseType(TEndpoint, IEndpointGenerator)

Returns the TypedRest type the endpoint derives from.

protected abstract TsIdentifier GetBaseType(TEndpoint endpoint, IEndpointGenerator generator)

Parameters

endpoint TEndpoint
generator IEndpointGenerator

Returns

TsIdentifier