• 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

    Status

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

    IMessageDescription is an event type description.

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


    IStatus information is attached to Exceptions and is readabled by IStatusProvider 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 (Exception e) 
    {
        //
        IMessage @event = e.StatusMessage()!;
        // Formulate message from arguments
        string msg = @event.MessageDescription.Template.Print(null, @event.Arguments);
        // Write event with arguments
        Console.Error.WriteLine(msg);
        // Let it fly
        throw;
    }
    


    EventId can be used as criteria for filtering Exception catch.

    // 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 (Exception e) when (e.HResult == Services.StatusCodes.BadQueryNoValue.Code)
    {
        Console.Error.WriteLine("Query was not handled.");
    }
    


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

    QueryLogger


    ServiceMessages

    Service related IMessageDescriptions.

    Key StatusCode Description Message Template Exception
    Avalanche.Service.GoodQueryCompleted 0A7AC050 Query completed: {request}={value} ({status})
    Avalanche.Service.BadException 8A7AC050 {errorType}: {errorMessage}
    Avalanche.Service.BadQueryUnexpectedStatus 8A7AC051 {request}: Unexpected status {status}, expected {newStatus}.
    Avalanche.Service.BadQueryNotCompleted 8A7AC052 {request}: did not complete.
    Avalanche.Service.BadQueryNotProcessed 8A7AC053 {request}: was not processed.
    Avalanche.Service.BadQueryCancelled 8A7AC054 {request}: was cancelled.
    Avalanche.Service.BadQueryInvalidCast 8A7AC055 {request}: {gotType} invalid cast to {targetType}.
    Avalanche.Service.BadQueryEntryDisposed 8A7AC056 {request}: disposed.
    Avalanche.Service.BadQueryValueDisposed 8A7AC057 {request}: Value disposed.
    Avalanche.Service.BadQueryValueNulled 8A7AC058 {request}: Value nulled.
    Avalanche.Service.BadQueryNoValue 8A7AC059 {request}: No value.
    Avalanche.Service.BadQueryCycle 8A7AC05A {request}: Query cycle. (Try GetInitialized?)
    Avalanche.Service.BadHandlerFailedToResolve 8A7AC05B Failed to resolve {value}
    Avalanche.Service.BadEntryUnexpectedStatus 8A7AC05C {entry}: Unexpected status {status}, expected {newStatus}.
    Avalanche.Service.BadEntrySetStatus 8A7AC05D {entry}: Could not set status to {newStatus}
    Avalanche.Service.BadEntrySetFlags 8A7AC05E {entry}: Could not set status to include {flagsToInclude}, and exclude {flagsToExclude}.
    Avalanche.Service.BadEntryNotEntryObservable 8A7AC05F {entry}: is not IEntryObservable
    Avalanche.Service.BadEntryNotWritable 8A7AC060 {entry}: is not IEntryWritable
    Avalanche.Service.BadEntryNotReadable 8A7AC061 {entry}: is not IEntryReadable
    Avalanche.Service.BadEntryDisposed 8A7AC062 {entry}: disposed.
    Avalanche.Service.BadEntryValueDisposed 8A7AC063 {entry}: Value disposed.
    Avalanche.Service.BadEntryValueNulled 8A7AC064 {entry}: Value nulled.
    Avalanche.Service.BadEntryInvalidCast 8A7AC065 {request}: {gotType} invalid cast to {targetType}.
    Avalanche.Service.BadEntryLinkFailed 8A7AC066 {entry}: link failed.
    Avalanche.Service.BadServiceBuilderNoEntryFactory 8A7AC067 IEntryFactoryBase is not assigned.
    Avalanche.Service.BadServiceBuilderNoCachePolicy 8A7AC068 No cache policy
    Avalanche.Service.BadServiceBuilderNoEntryProvider 8A7AC069 IEntryCacheBase or IEntryFactoryBase is required.
    Avalanche.Service.BadServiceBuildeNoEntryResolver 8A7AC06A Entry resolver parameters required.
    Back to top Copyright © 2022 Toni Kalajainen, contact@avalanche.fi