• Avalanche.Core
Search Results for

    Show / Hide Table of Contents
    • Avalanche.Accessor
      • Introduction
      • IAccessor
        • IAccessor
        • IListAccessor
        • IMapAccessor
        • IRecordAccessor
        • IContentAccessor
        • IOneOfAccessor
        • IAnyAccessor
      • .Net
        • Introduction
        • IList<T>
        • IDictionary<K,V>
        • FieldInfo
        • OneOfAttribute
        • StructLayoutAttribute
        • Class
      • Protobuf
        • Introduction
      • Articles
        • Dependency Injection
        • AccessorMessages
    • Avalanche.Binding
      • Introduction
    • Avalanche.Configuration
      • Introduction
      • Configuration Binding
      • ConfigurationExtensions
      • MemoryConfiguration
      • PrintTree
      • Saving IOptions
      • Yaml
    • Avalanche.Converter
      • Introduction
      • EnumConverter
      • Func<,>
      • HexConverter
      • PrimitiveConverter
      • StringConverter
    • Avalanche.Core
      • License
    • Avalanche.DataType
      • Introduction
      • DataType
        • IDataType
        • IListType
        • IMapType
        • IRecordType
        • IFieldType
        • IOneOfType
        • IAnyType
        • IStringType
        • IValueType
        • IIntegerType
        • IEnumerationType
        • IRealType
      • .Net
        • Introduction
        • IList<T>
        • IDictionary<K,V>
        • FieldInfo
        • Enum
        • OneOfAttribute
        • StructLayoutAttribute
        • Class
      • Protobuf
        • Introduction
      • Articles
        • DataTypeRequest
        • PrintTree
        • DataTypeMessages
    • Avalanche.Emit
      • Introduction
      • TypeBuilder
      • ConstructorBuilder
      • MethodBuilder
      • PropertyBuilder
      • FieldBuilder
      • Emit
      • Utilities
    • 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
        • FilterEnumerable
        • PollingFilterWatchToken
    • Avalanche.Identity
      • Introduction
      • Identity
      • IdentityParts
      • IdentityInterner
      • IdentityComparer
      • Print Tree
      • IdentityAccessors
        • Introduction
        • TypeName
    • Avalanche.Localization
      • Introduction
      • Localization
      • LocalizationFile
      • LocalizationFiles
      • LocalizationFileSystem
      • LocalizationFileFormat
      • LocalizationLine
      • LocalizationLines
      • TemplateFormat
      • CultureProvider
      • FallbackCultureProvider
      • ResourceManager
      • LocalizationError
      • Microsoft.Extensions
        • Introduction
        • DependencyInjection
        • FileProvider
        • Logging
        • ITextLocalizer
        • IFileLocalizer
        • Localization
      • Asp.Net
        • Introduction
        • Supplying localization
        • Inject to pages
        • Culture Assigned
        • Minimalistic Api
        • Diagnostics
      • Pluralization
        • Introduction
        • Multiple plural parameters
        • Custom PluralRules
        • Invariant Culture
        • Unit Prefix
        • IPluralRule
        • IPluralNumber
        • IPluralRules
        • CLDRs
        • Unicode.CLDR40
        • Unicode.CLDR41
        • Unicode.CLDR42
      • Articles
        • Alphabet localization
        • Benchmarks
        • Caching
        • Class Library
        • Demo
        • Diagnostics
        • Embedded resources
        • Emplacement
        • File localization
        • Text localization
        • Printing templates
    • Avalanche.Message
      • Introduction
      • IMessage
      • IMessageProvider
      • IMessageDescription
      • IMessageDescriptions
      • MessageLevel
      • Message printing
      • Messages and Exceptions
      • Microsoft.Extensions
        • DependencyInjection
      • Articles
        • Aggregate Messages
        • Localization
        • Logging
        • Validation
    • Avalanche.Options
      • Introduction
      • OptionsExtensions
      • OptionsMonitorCast
    • Avalanche.Service
      • Introduction
      • Service
        • Introduction
        • IService
        • IServiceDisposable
        • IServiceDecoration
        • IServiceCast
        • IServiceObservable
        • IServiceContainer
        • Construction
        • Query
        • CancellationToken
        • CachePolicy
        • Scope
      • Handler
        • Introduction
        • IHandler
        • IHandlerCast
        • IHandlerDecoration
        • IHandlerWithOrder
        • CancellationToken
        • Cyclicity
        • Delegates
        • Invokable
        • ExportAttribute
        • OrderAttribute
        • PrintTree
        • Recursion
      • Query
        • Introduction
        • IQuery
        • IQueryCast
        • IQueryDecoration
      • Entry
        • Introduction
        • IEntry
        • IEntryCast
        • IEntryDecoration
        • IEntryObservable
        • IEntryVisitable
        • EntryState
      • Request
        • Introduction
        • IRequest
        • IRequestFor
        • IRequestToBeCached
        • IRequestToBeDisposed
        • RequestAttribute
        • ContextParameterAttribute
        • Print Tree
      • Dependency Injection
        • Introduction
        • Asp.Net
        • ServiceRequest<T>
        • Decorating a service
        • Handler
        • CachePolicy
        • CancellationToken
        • QueryLogger
        • IHostBuilder
      • Examples
        • NodeCount
        • Expression
        • Mapper
      • Articles
        • Benchmarks
        • Error Handling
        • ServiceMessages
    • Avalanche.StatusCode
      • Introduction
      • HResult
        • Introduction
        • HResult.Facilities
        • BasicMessages
        • RpcMessages
        • DispatchMessages
        • StorageMessages
        • ItfMessages
        • Win32Messages
        • WindowsMessages
        • SspiMessages
        • CertMessages
        • MediaServerMessages
        • SetupApiMessages
        • ScardMessages
        • ComPlusMessages
        • ClrMessages
        • UserModeFilterManagerMessages
        • GraphicsMessages
        • TpmServicesMessages
        • TpmSoftwareMessages
        • PlaMessages
        • FveMessages
        • FwpMessages
        • NdisMessages
        • DltMessages
      • 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
      • HttpStatusCode
      • OpcUaStatusCode
    • Avalanche.Template
      • Introduction
      • TemplateFormats
      • ITemplatePrintable
      • ITemplateFormatPrintable
      • ITemplateText
      • ITemplateBreakdown
      • ITemplateFormat
      • ITemplateFormats
      • Extract Arguments
      • Emplacement
    • Avalanche.Tokenizer
      • Introduction
      • IToken
      • ITokenizer
      • Tokenizers
    • 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
        • ListCloner
        • DictionaryCloner
        • FieldCloner
        • PassthroughCloner
        • RecordCloner
        • ClonerProvider
      • Dispose
        • IDisposeAttachable
        • IDisposeBelatable
      • Provider
        • Introduction
        • ProviderBase
        • Delegate
        • Pipe
        • Cache
        • ResultCapture
        • AsReadOnly
        • AsService
        • IProviderEvent
      • Record
        • IRecordDescription
        • IFieldDescription
        • IConstructorDescription
        • IConstructionDescription
        • IParameterDescription
        • IRecordProviders
        • RecordDelegates
          • RecordCreate
          • RecordClone
          • RecordCopy
          • IRecordDelegates
        • FieldDelegates
          • FieldRead
          • FieldWrite
          • RecreateWith
          • IFieldDelegates
      • Reflection
        • EnumDescription
      • String
        • IEscaper
        • UnicodeString
        • Hex
      • Miscellaneous
        • IIdGenerator
        • Permutation
        • IReadOnly
        • IUserDataContainer
        • ITreeNode
        • Void
    • Avalanche.Writer
      • Introduction
      • ConstantWriter
      • Context
      • ConvertWriter
      • DefaultConstructor
      • DelegateWriter
      • PassthroughWriter
      • Referer
      • TypeCast
      • Writer
      • WriterPipe
      • WriterMessages

    IService

    IService interface is the default interface for issuing queries of all types.

    /// <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;
    }
    

    Type parameters are provided to query methods, e.g. GetRequired<Request, Response>().

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

    Any compatible Request and Response types work.

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

    IService<Request,Response>

    IService<Request, Response> have Request and Response types assigned.

    /// <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);
    }
    

    IService<Request, Response> has assigned type parameters and doesn't need them in query methods, e.g. GetRequired().

    // Create service
    IService<TypeRequest, Type> service = Services.Create<TypeRequest, Type>(ServiceHandlers.Instance);
    // Query type
    Type type = service.GetRequired("System.String");
    

    Any compatible Request and Response types work.

    // Create service
    IService<object, object> service = Services.Create<object, object>(ServiceHandlers.Instance);
    // Query type
    object type = service.GetRequired(new TypeRequest("System.String"));
    

    Full Example

    Full example
    using System;
    using System.Reflection;
    using Avalanche.Service;
    
    public class service_service
    {
        public static void Run()
        {
            {
                // <01>
                // Create service
                IService service = Services.Create(ServiceHandlers.Instance);
                // Create request
                IRequestFor<Type> typeRequest = new TypeRequest("System.String");
                // Query type
                Type type = service.GetRequired<IRequest, Type>(typeRequest);
                // </01>
                // Print service
                Console.WriteLine(service.ToString());
            }
            {
                // <02>
                // Create service
                IService service = Services.Create(ServiceHandlers.Instance);
                // Create request
                IRequestFor<Type> typeRequest = new TypeRequest("System.String");
                // Query type
                IReflect type = service.GetRequired<IRequest, IReflect>(typeRequest);
                // </02>
                // Print service
                Console.WriteLine(service.ToString());
            }
            {
                // <11>
                // Create service
                IService<TypeRequest, Type> service = Services.Create<TypeRequest, Type>(ServiceHandlers.Instance);
                // Query type
                Type type = service.GetRequired("System.String");
                // </11>
                // Print service
                Console.WriteLine(service.ToString());
            }
            {
                // <12>
                // Create service
                IService<object, object> service = Services.Create<object, object>(ServiceHandlers.Instance);
                // Query type
                object type = service.GetRequired(new TypeRequest("System.String"));
                // </12>
                // Print service
                Console.WriteLine(service.ToString());
            }
        }
    }
    
    In This Article
    Back to top Copyright © Toni Kalajainen