Table of Contents

Class ServiceWithSetup<TOptions>

Namespace
ToSic.Sys.Services
Assembly
ToSic.Sys.Core.dll
[InternalApi_DoNotUse_MayChangeWithoutNotice("Still WIP as of v22")]
public abstract class ServiceWithSetup<TOptions> : ServiceBase, IHasLog, IHasOptions<TOptions>, IServiceWithSetup<TOptions> where TOptions : class

Type Parameters

TOptions
Inheritance
object
ServiceWithSetup<TOptions>
Implements
IHasOptions<TOptions>
Derived
Inherited Members

Constructors

ServiceWithSetup(string, NoParamOrder, object[]?)

protected ServiceWithSetup(string logName, NoParamOrder npo = default, object[]? connect = null)

Parameters

logName string
npo NoParamOrder
connect object[]

Properties

MyOptions

The options instance for this service, read-only.

public virtual TOptions MyOptions { get; }

Property Value

TOptions

Remarks

  1. Explicitly with a short name "MyOptions" so that the classes can have a subclass called "Options" without name conflicts.
  2. Will usually default to new/standard options of type TOptions.

Methods

GetDefaultOptions()

Method to generate new / default options. This should usually not be called, but it might; so if your service can work without valid options (or accesses options before setup), this would trigger.

This could also be triggered, if the service was created without the correct Generator. Note that it's always an option to just throw an exception.

You must override this to provide your own default options.

protected virtual TOptions GetDefaultOptions()

Returns

TOptions

Exceptions

ServiceOptionsRequiredException

Setup(TOptions)

public virtual void Setup(TOptions options)

Parameters

options TOptions