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
TEndpointThe type of IEndpoint to generate code for.
- Inheritance
-
objectBuilderBase<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
keystringendpointIEndpointgeneratorIEndpointGenerator
Returns
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
keystringendpointTEndpointgeneratorIEndpointGenerator
Returns
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
endpointTEndpointextraArgumentsList<TsExpression>generatorIEndpointGenerator
Returns
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
keystringendpointTEndpointgeneratorIEndpointGenerator
Returns
GetBaseType(TEndpoint, IEndpointGenerator)
Returns the TypedRest type the endpoint derives from.
protected abstract TsIdentifier GetBaseType(TEndpoint endpoint, IEndpointGenerator generator)
Parameters
endpointTEndpointgeneratorIEndpointGenerator