• 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

    Introduction

    Avalanche.StatusCodes.System.dll contains mscorlib.txt statuscodes, [git], [www].

    Add package reference to .csproj.

    <PropertyGroup>
        <RestoreAdditionalProjectSources>https://avalanche.fi/Avalanche.Core/nupkg/index.json</RestoreAdditionalProjectSources>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Avalanche.StatusCodes.System"/>
    </ItemGroup>
    

    SystemMessages.Messages contains statuscodes and display texts that are automatically scraped from MIT-licensed mscorlib.dll (Multi-language Standard Common Object Runtime Library).

    Each key from mscorlib.txt is assigned with a message description.

    IMessageDescription messageDescription = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"];
    

    Each key is assigned with a permanent code. Codes have facility value 0x23450000 for successful codes and 0xA3450000 for errors.

    IMessageDescription messageDescription = SystemMessages.Messages.Codes[unchecked((int)0xA34500CB)];
    int code = messageDescription.Code!.Value;
    

    Most descriptions are associated with a HResult code.

    int? hresult = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"].HResult;
    

    Most descriptions have an associated exception type.

    Type? error = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"].Exception as Type;
    

    Descriptions have a template text.

    // Get template text
    ITemplateText templateText = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"].Template;
    // Print template text
    WriteLine(templateText); // "Parameter name: {0}"
    

    And each key is organized by group and is assigned to a class and a field.

    // Argumentize file not found 
    IMessage filenotfound = SystemMessages.IO.FileNotFoundFileName.New("file.txt");
    // Print template text
    WriteLine(filenotfound); // "Could not find file 'file.txt'."
    

    Note however that there is a heuristic algorithm that chooses class and field name, and is prone to errors, which may be corrected later. Therefore, it is recommended to not use field reference, but instead refer by Key or by Code.

    IMessageDescription messageDescription1 = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"];
    IMessageDescription messageDescription2 = SystemMessages.Messages.Codes[unchecked((int)0xA34500CB)];
    
    Full example
    using Avalanche.Message;
    using Avalanche.StatusCode;
    using Avalanche.Template;
    using static System.Console;
    
    class system_index
    {
        public static void Run()
        {
            {
                // <10>
                IMessageDescription messageDescription = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"];
                // </10>
            }
            {
                // <11>
                IMessageDescription messageDescription = SystemMessages.Messages.Codes[unchecked((int)0xA34500CB)];
                int code = messageDescription.Code!.Value;
                // </11>
            }
            {
                // <12>
                int? hresult = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"].HResult;
                // </12>
            }
            {
                // <13>
                Type? error = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"].Exception as Type;
                // </13>
            }
            {
                // <14>
                // Get template text
                ITemplateText templateText = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"].Template;
                // Print template text
                WriteLine(templateText); // "Parameter name: {0}"
                // </14>
            }
            {
                // <15>
                // Argumentize file not found 
                IMessage filenotfound = SystemMessages.IO.FileNotFoundFileName.New("file.txt");
                // Print template text
                WriteLine(filenotfound); // "Could not find file 'file.txt'."
                // </15>
            }
            {
                // <16>
                IMessageDescription messageDescription1 = SystemMessages.Messages.Keys["mscorlib.Arg_ParamName_Name"];
                IMessageDescription messageDescription2 = SystemMessages.Messages.Codes[unchecked((int)0xA34500CB)];
                // </16>
            }
        }
    }
    

    Table

    SystemMessages.Instance contains following message descriptions:

    Field Name Description
    AccessControl System.Security.AccessControl.*
    Aggregate System.AggregateException
    AppDomain System.AppDomain.*
    Argument System.ArgumentException
    ArgumentNull System.ArgumentNullException
    ArgumentOutOfRange System.ArgumentOutOfRangeException
    Arithmetic
    Array
    Assembly
    BadImageFormat System.BadImageFormatException
    CodeContract
    CodePage
    Collections System.Collections.*
    CompilerService System.Runtime.CompilerServices.*
    Cryptography System.Security.Cryptography.*
    Culture System.Globalization.Culture*
    Diagnostics System.Diagnostics.*
    EventSource System.Diagnostics.Tracing.EventSourceException
    ExecutionEngine
    Format System.FormatException
    HostProtection System.Security.HostProtectionException
    IO System.IO.*
    IndexOutOfRange System.IndexOutOfRangeException
    InteropService System.Runtime.InteropServices.*
    InvalidCast System.InvalidCastException
    InvalidOperation System.InvalidOperationException
    IsolatedStorage System.IO.IsolatedStorage.*
    Lazy System.Threading.Lazy
    Marshaler
    Memory
    Miscellaneous
    NotImplemented System.NotImplementedException
    NotSupported System.NotSupportedException
    ObjectDisposed System.ObjectDisposedException
    OperationCanceled System.OperationCanceledException
    Overflow System.OverflowException
    Platform
    Policy System.Security.Policy.*
    Principal System.Security.Principal.*
    Program System.InvalidProgramException
    Reference
    Reflection System.Reflection.*
    Region
    Remoting System.Runtime.Remoting.*
    Resources System.Resources.*
    Security System.Security.*
    Serialization System.Runtime.Serialization.*
    Stack
    Task System.Threading.Tasks.*
    Text System.Text.*
    Threading System.Threading.*
    TimeZone
    Type
    Xml System.Xml.*
    This document is partially derived from work with following license.
    /*This file is a derivate of a source file that has following license (below). 
    
    ========================================================================
    The MIT License (MIT)
    
    Copyright (c) Microsoft Corporation
    
    Permission is hereby granted, free of charge, to any person obtaining a copy 
    of this software and associated documentation files (the "Software"), to deal 
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is 
    furnished to do so, subject to the following conditions: 
    
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software. 
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
    ======================================================================*/
    In This Article
    Back to top Copyright © Toni Kalajainen