• Avalanche
  • Avalanche.Core
  • Lexical

    Show / Hide Table of Contents
    • Avalanche.Localization
      • Introduction
      • Localization
      • LocalizationFile
      • LocalizationFiles
      • LocalizationFileSystem
      • LocalizationFileFormat
      • LocalizationLine
      • LocalizationLines
      • TemplateFormat
      • CultureProvider
      • FallbackCultureProvider
      • ResourceManager
      • LocalizationError
      • Microsoft.Extensions
        • Introduction
        • DependencyInjection
        • FileProvider
        • Logging
        • ITextLocalizer
        • IFileLocalizer
        • Localization
        • AspNetCore
      • Pluralization
        • Introduction
        • Multiple plural parameters
        • Custom PluralRules
        • Invariant Culture
        • Unit Prefix
        • IPluralRule
        • IPluralNumber
        • IPluralRules
        • CLDRs
        • Unicode.CLDR41
        • Unicode.CLDR40
      • Articles
        • Alphabet localization
        • Benchmarks
        • Caching
        • Class Library
        • Demo
        • Diagnostics
        • Embedded resources
        • Emplacement
        • File localization
        • Text localization
    • Avalanche.Message
      • Introduction
      • IMessage
      • IMessageProvider
      • IMessageDescription
      • IMessageDescriptions
      • MessageLevel
      • Message printing
      • Messages and Exceptions
      • Logging
      • Validation
      • Localization
    • Avalanche.StatusCode
      • Introduction
      • HResult
        • Introduction
        • HResult.Facilities
        • BasicMessages
        • RpcMessages
        • DispatchMessages
        • ItfMessages
        • Win32Messages
        • ClrMessages
      • System
        • Introduction
        • AccessControlMessages
        • AggregateMessages
        • AppDomainMessages
        • ArgumentMessages
        • ArgumentNullMessages
        • ArgumentOutOfRangeMessages
        • ArithmeticMessages
        • ArrayMessages
        • AssemblyMessages
        • BadImageFormatMessages
        • CodeContractMessages
        • CodePageMessages
        • CollectionsMessages
        • CompilerServiceMessages
        • CryptographyMessages
        • CultureMessages
        • DiagnosticsMessages
        • EventSourceMessages
        • ExecutionEngineMessages
        • FormatMessages
        • HostProtectionMessages
        • IOMessages
        • IndexOutOfRangeMessages
        • InteropServiceMessages
        • InvalidCastMessages
        • InvalidOperationMessages
        • IsolatedStorageMessages
        • LazyMessages
        • MarshalerMessages
        • MemoryMessages
        • MiscellaneousMessages
        • NotImplementedMessages
        • NotSupportedMessages
        • ObjectDisposedMessages
        • OperationCanceledMessages
        • OverflowMessages
        • PlatformMessages
        • PolicyMessages
        • PrincipalMessages
        • ProgramMessages
        • ReferenceMessages
        • ReflectionMessages
        • RegionMessages
        • RemotingMessages
        • ResourcesMessages
        • SecurityMessages
        • SerializationMessages
        • StackMessages
        • TaskMessages
        • TextMessages
        • ThreadingMessages
        • TimeZoneMessages
        • TypeMessages
        • XmlMessages
    • Avalanche.Template
      • Introduction
      • TemplateFormats
      • ITemplatePrintable
      • ITemplateFormatPrintable
      • ITemplateText
      • ITemplateBreakdown
      • ITemplateFormat
      • ITemplateFormats
      • Extract Arguments
      • Emplacement
    • Avalanche.Tokenizer
      • Introduction
      • IToken
      • ITokenizer
      • Tokenizers
    • Avalanche.Service
      • Introduction
      • Service
        • IService
        • Construction
        • Query
        • CancellationToken
        • CachePolicy
        • Cast
        • Scope
        • Dispose
      • Handler
        • Introduction
        • IHandler
        • Cancel
        • Recursion
        • Cyclicity
        • Delegates
        • Casting
        • Invokable
        • Handlers
      • Request
        • Introduction
        • IRequest
        • [Request]
        • [ContextParameter]
        • Print Tree
      • Dependency Injection
        • Introduction
        • ServiceRequest<T>
        • Handler
        • CachePolicy
        • CancellationToken
        • QueryLogger
      • Examples
        • Expression Example
        • Mapper Example
      • ServiceMessages
    • Avalanche.Writer
      • Introduction
      • Writer
      • Referer
      • TypeCast
      • DefaultConstructor
      • DelegateWriter
      • WriterPipe
      • ConstantWriter
      • PassthroughWriter
      • Context
      • WriterMessages
    • Avalanche.Accessor
      • Introduction
      • AccessorServices
      • List
        • ListAccessor
        • ListConstructor
        • ListDeconstructor
        • ListDefaultConstructor
        • ListGet
        • ListSet
        • ListAdd
        • ListInsert
        • ListClear
        • ListCount
        • ListIndexOf
        • ListRemoveAt
        • ListReferer
      • Map
        • MapAccessor
        • MapConstructor
        • MapDeconstructor
        • MapDefaultConstructor
        • MapSet
        • MapGet
        • MapRemove
        • MapClear
        • MapCount
        • MapReferer
      • Record
        • RecordAccessor
        • RecordConstructor
        • RecordDeconstructor
        • RecordDefaultConstructor
      • Field
        • FieldAccessor
        • FieldReader
        • FieldWriter
        • FieldReferer
      • Dependency Injection
        • Introduction
      • AccessorMessages
    • Avalanche.Emit
      • Introduction
      • TypeBuilder
      • ConstructorBuilder
      • MethodBuilder
      • PropertyBuilder
      • FieldBuilder
      • Emit
      • Utilities
    • Avalanche.DataType
      • Introduction
      • IDataTypeBase
      • IDataType
      • IRecordType
      • IFieldType
      • IUnionType
      • IListType
      • IMapType
      • IValueType
      • IEnumerationType
      • IIntegerType
      • IRealType
      • IStringType
      • IAnyType
      • DataTypeRequest
      • PrintTree
      • DataTypeMessages
    • Avalanche.FileSystem
      • Introduction
      • Abstractions
        • IFileSystem
          • IFileSystemBrowse
          • IFileSystemCreateDirectory
          • IFileSystemDelete
          • IFileSystemFileAttribute
          • IFileSystemMount
          • IFileSystemMove
          • IFileSystemObserve
          • IFileSystemOpen
        • IEvent
        • IEntry
        • IOption
        • IToken
      • FileSystem
      • VirtualFileSystem
      • MemoryFileSystem
      • EmbeddedFileSystem
      • HttpFileSystem
      • Decoration
      • IFileProvider
      • Events
      • Utilities
        • Dispose
        • File Scanner
        • Visit Tree
        • File Operation
    • Avalanche.Identity
      • Introduction
      • Identity
      • IdentityParts
      • IdentityInterner
      • IdentityComparer
      • Print Tree
      • IdentityAccessors
        • Introduction
        • TypeName
    • Avalanche.Utilities
      • Introduction
      • Collections
        • Tuples
        • StructList
        • ArrayList
        • BijectionMap
        • LocakableDictionary
        • LockableList
        • MapList
        • Pipe
        • RingQueue
        • EnumerableExtensions
        • TupleUtilities
        • ArrayUtilities
      • Comparers
        • IGraphComparer
        • IGraphComparable
        • AlphaNumericComparer
        • EnumerableComparer
        • EnumerableGraphComparer
        • ReferenceComparer
        • KeyValuePairComparer
        • DefaultComparerProvider
        • RecordComparer
      • Cloners
        • ICloner
        • IGraphCloner
        • IGraphCloneable
        • EnumerableCloner
        • FieldCloner
        • PassthroughCloner
        • RecordCloner
        • ClonerProvider
      • Dispose
        • IDisposeAttachable
        • IDisposeBelatable
      • Provider
        • Introduction
        • ProviderBase
        • Delegate
        • Concatenation
        • Cache
        • ResultCapture
        • AsReadOnly
        • AsService
      • Record
        • IRecordDescription
        • IFieldDescription
        • IConstructorDescription
        • IConstructionDescription
        • IParameterDescription
        • IRecordProviders
        • RecordDelegates
          • RecordCreate
          • RecordClone
          • RecordCopy
          • IRecordDelegates
        • FieldDelegates
          • FieldRead
          • FieldWrite
          • RecreateWith
          • IFieldDelegates
      • String
        • IEscaper
        • UnicodeString
      • Miscellaneous
        • IIdGenerator
        • Permutation
        • IReadOnly
        • IUserDataContainer
        • Void
    • Avalanche.Core
      • License
      • Order

    Introduction

    IService interfaces are used for issuing queries to service handlers.

    // Create service
    IService<IRequestFor<Type>, Type> service = Services.Create<IRequestFor<Type>, Type>(ServiceHandlers.Instance, CachePolicies.Default);
    // Create request
    IRequestFor<Type> typeRequest = new TypeRequest("System.String");
    // Query type
    Type type = service.GetRequired(typeRequest);
    
    Service Stack

    Interfaces

    Each IService interface addresses a different aspect of service implementation.

    IServiceProvider
    └── IServiceBase
        ├── IService
        │   └── IServiceDisposable
        ├── IServiceT
        │   └── IServiceOf<Response>
        │       └── IService<Request, Response>
        │           └── IServiceDisposable<Request, Response>
        │
        ├── IServiceDecoration
        │   └── IServiceCast
        ├── IServiceObservable
        ├── IServiceLayer
        └── IServiceCastable
    
    ─── IServiceContainer
    
    IService
    /// <summary>Provides services for any request and response type.</summary>
    public interface IService : IServiceBase
    {
        /// <summary>Get possible value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns><typeparamref name="Response"/> value or null</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Response? Get<Request, Response>(in Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    
        /// <summary>Get value and expect to get value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns><typeparamref name="Response"/> value</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Response GetRequired<Request, Response>(in Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    
        /// <summary>Try get <typeparamref name="Response"/> value.</summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>true if was handled by <paramref name="service"/> and has <paramref name="response"/>.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        bool TryGet<Request, Response>(in Request request, [NotNullWhen(true)] out Response response, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    
        /// <summary>Get possible value</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>Task for <typeparamref name="Response"/> value.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Task<Response?> GetAsync<Request, Response>(Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    
        /// <summary>Get value and expect to get value.</summary>
        /// <typeparam name="Request">The highest level of type the caller wants to provide keys with.</typeparam>
        /// <typeparam name="Response">The highest level of type the caller wants read responses as.</typeparam>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>Task for <typeparamref name="Response"/> value.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Task<Response> GetRequiredAsync<Request, Response>(Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>true if was handled by <paramref name="service"/> and has <paramref name="response"/>.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        bool TryGetInitialized<Request, Response>(in Request request, [NotNullWhen(true)] out Response response, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    
        /// <summary>Get initialized value. Return value once it has been assigned to <see cref="IEntry"/>. It may not be completed when returned.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>Task for <typeparamref name="Response"/> value.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Task<Response?> GetInitializedAsync<Request, Response>(Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    
        /// <summary>Invoke <paramref name="request"/> but do not expect return value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>true if was handled</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException"></exception>
        bool TryInvoke<Request>(in Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    
        /// <summary>Invoke <paramref name="request"/> but do not expect return value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>true if was handled.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        Task<bool> InvokeAsync<Request>(Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null) where Request : notnull;
    }
    
    IService<Request, Response>
    /// <summary>Indicates that service has specific request response type.</summary>
    public interface IServiceT : IServiceBase { }
    
    /// <summary>Indicates that service has specific <typeparamref name="Response"/>.</summary>
    public interface IServiceOf<Response> : IServiceT { }
    
    /// <summary>Indicates that service has specific <typeparamref name="Request"/>.</summary>
    public interface IService<Request> : IServiceT where Request : notnull
    {
        /// <summary>Invoke <paramref name="request"/> but do not expect any return value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>true if was handled</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException"></exception>
        bool TryInvoke(in Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    
        /// <summary>Invoke <paramref name="request"/> but do not expect any return value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>true if was handled.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        Task<bool> InvokeAsync(Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    }
    
    /// <summary>Indicates that service has specific <typeparamref name="Request"/> and <typeparamref name="Response"/> type.</summary>
    public interface IService<Request, Response> : IService<Request>, IServiceOf<Response> where Request : notnull
    {
        /// <summary>Get possible value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns><typeparamref name="Response"/> value or null</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Response? Get(in Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    
        /// <summary>Get value and expect to get value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns><typeparamref name="Response"/> value</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Response GetRequired(in Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    
        /// <summary>Try get <typeparamref name="Response"/> value.</summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>true if was handled by <paramref name="service"/> and has <paramref name="response"/>.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        bool TryGet(in Request request, out Response? response, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    
        /// <summary>Get possible value</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>Task for <typeparamref name="Response"/> value.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Task<Response?> GetAsync(Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    
        /// <summary>Get value and expect to get value.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>Task for <typeparamref name="Response"/> value.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Task<Response> GetRequiredAsync(Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    
        /// <summary>Get initialized value. Return value once it has been assigned to <see cref="IEntry"/>. It may not be completed when returned.</summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>true if was handled by <paramref name="service"/> and has <paramref name="response"/>.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        bool TryGetInitialized(in Request request, [NotNullWhen(true)] out Response response, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    
        /// <summary>Get initialized value. Return value once it has been assigned to <see cref="IEntry"/>. It may not be completed when returned.</summary>
        /// <param name="request"></param>
        /// <param name="cancelToken">call abort signal</param>
        /// <param name="context">optional context parameters. If context parameters match to request, then query is not cached.</param>
        /// <returns>Task for <typeparamref name="Response"/> value.</returns>
        /// <exception cref="ServiceException"></exception>
        /// <exception cref="OperationCanceledException">if token is cancelled</exception>
        /// <exception cref="ObjectDisposedException">Service is disposed</exception>
        /// <exception cref="InvalidCastException">If result was not <typeparamref name="Response"/> type.</exception>
        Task<Response?> GetInitializedAsync(Request request, CancellationToken cancelToken = default, IDictionary<string, object>? context = null);
    }
    
    IServiceDecoration
    /// <summary>Service provider that is based on decorating another <see cref="IService"/>. Optional information for the implementation</summary>
    public interface IServiceDecoration : IServiceBase
    {
        /// <summary>Is decoration</summary>
        bool IsServiceDecoration { get; }
        /// <summary>The underlying <see cref="IService"/> this decoration is derivation of.</summary>
        IServiceBase? DecorationSource { get; }
    }
    
    /// <summary>Decorates <see cref="IService"/> in an unspecified way.</summary>
    public interface IServiceDecorator
    {
        /// <summary>Decorate <paramref name="service"/></summary>
        /// <param name="service"></param>
        /// <returns>Decorated version of <paramref name="service"/>. May or may not implement <see cref="IServiceDecoration"/>.</returns>
        IServiceBase Decorate(IServiceBase service);
    }
    
    /// <summary>Indicates that the decoration affects only the casting of the <see cref="IServiceBase"/>.</summary>
    public interface IServiceCast : IServiceDecoration
    {
    }
    
    IServiceObservable
    /// <summary>Service that can be observed for internal state changes.</summary>
    public interface IServiceObservable : IServiceBase, IObservable<ServiceEvent>
    {
    }
    
    /// <summary>Base class for service events</summary>
    public record ServiceEvent(IServiceBase sender);
    /// <summary>Service closed event</summary>
    public record ServiceClosedEvent(IServiceBase sender) : ServiceEvent(sender);
    
    IServiceLayer
    /// <summary>Indicates that service utilizes a source layer</summary>
    public interface IServiceLayer : IServiceBase
    {
        /// <summary>Source service</summary>
        IServiceBase? SourceService { get; }
    }
    
    IServiceCastable
    /// <summary>
    /// Service that can cast to <see cref="IService{Request, Response}"/>.
    /// </summary>
    public interface IServiceCastable : IServiceBase
    {
        /// <summary>Try cast to <see cref="IService"/>.</summary>
        bool TryCast([NotNullWhen(true)] out IService castedService);
        /// <summary>Try cast to <see cref="IService{Request, Response}"/>.</summary>
        bool TryCast<Request, Response>([NotNullWhen(true)] out IService<Request, Response> castedService) where Request : notnull;
        /// <summary>Try cast to <see cref="IService{Request, Response}"/>.</summary>
        bool TryCast(Type requestType, Type responseType, [NotNullWhen(true)] out IServiceT castedService);
    }
    
    IServiceContainer
    /// <summary>Indicates that class binds a <see cref="IService"/> instance.</summary>
    public interface IServiceContainer
    {
        /// <summary>Attached <see cref="IService"/>. </summary>
        /// <exception cref="InvalidOperationException">If read-only</exception>
        IService Service { get; set; }
    }
    


    Back to top Copyright © 2022 Toni Kalajainen, contact@avalanche.fi