• Avalanche
  • Lexical SDK
  • Avalanche SDK
Show / Hide Table of Contents
  • Avalanche.Service
    • Introduction
    • Service
    • Handler
    • Request
    • Dependency Injection
    • Events
    • Examples
      • Quick Start
      • Expression
      • Mapper
  • Avalanche.Accessor
    • Introduction
    • Events
  • Avalanche.DataType
    • Introduction
    • Events
  • Avalanche.Binding
    • Introduction
    • Type
    • Events
  • Avalanche.Serialization
    • Introduction
    • Events
  • Avalanche.Localization
    • Introduction
    • Events
  • Avalanche.Converter
    • Introduction
    • Events
  • 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.Core
    • Introduction
    • Events
  • Avalanche.Utilities
    • Introduction
    • UnicodeString
    • Permutation
    • Tuples
    • StructList

Events

This class library produces events internally. Events are designed to human-readable and machine-readable, and to be processable inside process and outside process. Events are easily logged, stored, indexed, serialized, transmitted, and converted into simple formats, such as .json.

IEventInfo is an event type description.

// Choose event info
IEventInfo eventInfo = Services.Events.QueryErrorNoValue;
// Write event type info
Console.Error.WriteLine(eventInfo);
// { 
//      EventId = 1306003265, 
//      Key = "Avalanche.Service.QueryNoValue", 
//      Format = "{0}: No value.", 
//      MessageTemplate = "{request}: No value.", 
//      ArgumentNames = { "request" }, 
//      Description = "No value"
// }


IEvent information is attached to Exceptions and is readabled by IEventProvider interface.

// Create handler
Action<IQuery<string, string>> decorator = q => q.Response.SetValue( q.Request + "-Suffix" );
// Create service
IService service = Services.Create(decorator);

try
{
    // Issue request that is not handled
    service.GetRequired<int, int>(5);
} catch (ServiceException se) when (se is IEventProvider ep)
{
    // Get event
    IEvent @event = ep.Event!;
    // Formulate message from arguments
    string msg = String.Format(@event.EventInfo.Format, @event.Arguments);
    // Write event with arguments
    Console.Error.WriteLine(msg);
}


EventId can be used as criteria for filtering Exception catch.

try
{
    // Issue request that is not handled
    service.GetRequired<int, int>(5);
}
catch (ServiceException se) when (se.EventId() == Services.Events.QueryErrorNoValue.EventId)
{
    Console.Error.WriteLine("Query was not handled.");
}


QueryLogger is a handler that prints query results into a ILogger.

QueryLogger


Error Codes

Service related IEventInfo records.

Key EventId Description Message Template
Avalanche.Service.ErrorException 1306000030 Captured unexpected Exception {errorType}: {errorMessage}
Avalanche.Service.ServiceEventDisposed 1306000100 ServiceEvent that is sent when IService being disposed. {service} disposed.
Avalanche.Service.ServiceErrorDisposed 1306000130 Error that occurs when a disposed IService is used. {service} disposed.
Avalanche.Service.QueryCompleted 1306000200 IEntry resolved to Completed status. Query completed: {request}={value} ({status})
Avalanche.Service.QueryUnexpectedStatus 1306000230 Unexpected EntryStatus of IEntry. {request}: Unexpected status {status}, expected {newStatus}.
Avalanche.Service.QueryNotCompleted 1306000231 Query did not end at Completed status. {request}: did not complete.
Avalanche.Service.QueryNotProcessed 1306000232 Query was not processed. {request}: was not processed.
Avalanche.Service.QueryCancelled 1306000233 Query was canceled during processing. {request}: was cancelled.
Avalanche.Service.QueryInvalidCast 1306000234 Query invalid cast. {request}: {gotType} invalid cast to {targetType}.
Avalanche.Service.QueryEntryDisposed 1306000235 IEntry is disposed. {request}: disposed.
Avalanche.Service.QueryValueDisposed 1306000236 Value is disposed. {request}: Value disposed.
Avalanche.Service.QueryValueNulled 1306000237 Value is nulled. {request}: Value nulled.
Avalanche.Service.QueryNoValue 1306000238 No value {request}: No value.
Avalanche.Service.HandlerFailedToResolve 1306000330 Handler failed to resolve an unspecified value Failed to resolve {value}
Avalanche.Service.EntryUnexpectedStatus 1306000430 Unexpected EntryStatus of IEntry. {entry}: Unexpected status {status}, expected {newStatus}.
Avalanche.Service.EntrySetStatus 1306000431 Could not change status of IEntry. {entry}: Could not set status to {newStatus}
Avalanche.Service.EntrySetFlags 1306000432 Could not change flags of IEntry. {entry}: Could not set status to include {flagsToInclude}, and exclude {flagsToExclude}.
Avalanche.Service.EntryNotEntryObservable 1306000433 IEntry doesn't implement IEntryObservable. {entry}: is not IEntryObservable
Avalanche.Service.EntryNotEntryWritable 1306000434 IEntry doesn't implement IEntryWritable. {entry}: is not IEntryWritable
Avalanche.Service.EntryNotEntryReadable 1306000435 IEntry doesn't implement IEntryReadable. {entry}: is not IEntryReadable
Avalanche.Service.EntryDisposed 1306000436 IEntry is disposed. {entry}: disposed.
Avalanche.Service.EntryValueDisposed 1306000437 Value is disposed. {entry}: Value disposed.
Avalanche.Service.EntryValueNulled 1306000438 Value is nulled. {entry}: Value nulled.
Avalanche.Service.EntryInvalidCast 1306000439 Entry invalid cast. {request}: {gotType} invalid cast to {targetType}.
Avalanche.Service.ServiceBuilderNoEntryFactory 1306000630 IServiceBuilder needs IEntryFactoryBase IEntryCacheBase cannot be created without required parameters.
Avalanche.Service.ServiceBuilderNoCachePolicy 1306000631 IServiceBuilder needs IRequestPolicy No cache policy
Avalanche.Service.ServiceBuilderNoEntryProvider 1306000632 IServiceBuilder needs IEntryProviderBase IEntryCacheBase or IEntryFactoryBase is required.
Avalanche.Service.ServiceBuilderNoEntryResolver 1306000633 IServiceBuilder needs IEntryResolverBase Entry resolver parameters required.
Avalanche.Service.EntryCacheLineStoreDisposed 1306000730 Error that occurs when a disposed (object) is used. {object} disposed.
Back to top Copyright © 2017-2021 Toni Kalajainen, contact@avalanche.fi