• 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

    IntegerType

    IIntegerType is a interface for features of integer types.

    /// <summary>Integer type description</summary>
    /// <remarks>Valid type has "MinValue" and "MaxValue" assigned.</remarks>
    public interface IIntegerType : INumberType, IUnitProvider, IValueRangeProvider<BigInteger> 
    { 
    }
    
    /// <summary>Description of number type features</summary>
    public interface INumberType : IValueType
    {
        /// <summary>
        /// Internal base type.
        /// 2 for binaries, and 10 for decimal.
        /// </summary>
        int? Base { get; set; }
    
        /// <summary>
        /// Precision of significand digits in units of <see cref="Base"/>. 
        /// 
        /// This is mantissa for floating point types, and integer digits for integer types.
        /// For fixed points, the sum of <see cref="IRealType.IntegerPrecision"/> and <see cref="IRealType.FractionPrecision"/>.
        /// 
        /// Null if not valid for the number type.
        /// </summary>
        int? SignificandPrecision { get; set; }
    
        /// <summary>Does the type have sign feature.</summary>
        bool SignCapability { get; set; }
    }
    
    /// <summary>Provides Unit property.</summary>
    public interface IUnitProvider
    {
        /// <summary>Unit property, e.g. "m/s".</summary>
        string? Unit { get; set; }
    }
    
    /// <summary>Interface for min and max value range properties.</summary>
    public interface IValueRangeProvider<T> where T : struct
    {
        /// <summary>Minimum value. Null if not valid for type, assigned or assignable.</summary>
        Nullable<T> MinValue { get; set; }
        /// <summary>Maximum value. Null if not valid for type, assigned or assignable.</summary>
        Nullable<T> MaxValue { get; set; }
    }
    

    IntegerType is the default implementation.

    IIntegerType datatype = new IntegerType
    {
        Name = Identities.CreateName("uint16").SetReadOnly(),
        Annotations = { },
        Description = "",
        Nullable = true,
        Referable = true,
        MinValue = (BigInteger?)0,
        MaxValue = (BigInteger?)65536,
        SignCapability = false,
        SignificandPrecision = 16,
        Base = 2
    }.SetReadOnly();
    
    uint16 : IIntegerType { Base = 2, SignificandPrecision = 16, SignCapability = False, Nullable = True, Referable = True, Description = "", Annotations = [], MinValue = 0, MaxValue = 65536 }
    

    IntegerTypeRequest is request for an integer type when sub-requests are needed.

    // Create service
    IService service = Services.Create((ServiceHandlers.Instance, DataTypeHandlers.Instance));
    // Create request
    IntegerTypeRequest request = new IntegerTypeRequest
    {
        Name = Identities.CreateName("uint16").SetReadOnly(),
        Annotations = { },
        Description = "",
        Nullable = false,
        Referable = null,
        MinValue = (BigInteger?)0,
        MaxValue = (BigInteger?)65536,
        SignCapability = false,
        SignificandPrecision = 16,
        Base = 2
    };
    // Query
    IIntegerType datatype = service.GetRequired<IRequestFor<IIntegerType>, IIntegerType>(request);
    

    DataTypeRequest<IIntegerType> is a request for integer type by Type.

    // Create service
    IService service = Services.Create((ServiceHandlers.Instance, DataTypeHandlers.Instance));
    // Create request
    DataTypeRequest<IIntegerType> request = new(typeof(int));
    // Request
    IIntegerType datatype = service.GetRequired<DataTypeRequest<IIntegerType>, IIntegerType>(request);
    
    int : IIntegerType { Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = -2147483648, MaxValue = 2147483647 }
    

    DataTypes facade contains type definitions for .NET types.

    WriteLine(DataTypes.Bool.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.SByte.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.Byte.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.Short.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.UShort.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.Int.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.UInt.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.Long.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.ULong.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    WriteLine(DataTypes.BigInteger.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
    
    bool : IIntegerType { Base = 2, SignificandPrecision = 1, SignCapability = False, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = 0, MaxValue = 1 }
    sbyte : IIntegerType { Base = 2, SignificandPrecision = 8, SignCapability = True, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = -128, MaxValue = 127 }
    byte : IIntegerType { Base = 2, SignificandPrecision = 8, SignCapability = False, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = 0, MaxValue = 255 }
    short : IIntegerType { Base = 2, SignificandPrecision = 16, SignCapability = True, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = -32768, MaxValue = 32767 }
    ushort : IIntegerType { Base = 2, SignificandPrecision = 16, SignCapability = False, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = 0, MaxValue = 65535 }
    int : IIntegerType { Base = 2, SignificandPrecision = 32, SignCapability = True, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = -2147483648, MaxValue = 2147483647 }
    uint : IIntegerType { Base = 2, SignificandPrecision = 32, SignCapability = False, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = 0, MaxValue = 4294967295 }
    long : IIntegerType { Base = 2, SignificandPrecision = 64, SignCapability = True, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = -9223372036854775808, MaxValue = 9223372036854775807 }
    ulong : IIntegerType { Base = 2, SignificandPrecision = 64, SignCapability = False, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0, MinValue = 0, MaxValue = 18446744073709551615 }
    BigInteger : IIntegerType { Base = 2, SignCapability = True, Nullable = False, Referable = False, Annotations = [], DefaultValue = 0 }
    

    Full Example

    Full example
    using System.Numerics;
    using Avalanche.DataType;
    using Avalanche.Identity;
    using Avalanche.Service;
    using Avalanche.Utilities;
    using static System.Console;
    
    public class integertype
    {
        public static void Run()
        {
            {
                // <01>
                IIntegerType datatype = new IntegerType
                {
                    Name = Identities.CreateName("uint16").SetReadOnly(),
                    Annotations = { },
                    Description = "",
                    Nullable = true,
                    Referable = true,
                    MinValue = (BigInteger?)0,
                    MaxValue = (BigInteger?)65536,
                    SignCapability = false,
                    SignificandPrecision = 16,
                    Base = 2
                }.SetReadOnly();
                // </01>
                // Print
                WriteLine(datatype.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
            }
            {
                // <03>
                // Create service
                IService service = Services.Create((ServiceHandlers.Instance, DataTypeHandlers.Instance));
                // Create request
                IntegerTypeRequest request = new IntegerTypeRequest
                {
                    Name = Identities.CreateName("uint16").SetReadOnly(),
                    Annotations = { },
                    Description = "",
                    Nullable = false,
                    Referable = null,
                    MinValue = (BigInteger?)0,
                    MaxValue = (BigInteger?)65536,
                    SignCapability = false,
                    SignificandPrecision = 16,
                    Base = 2
                };
                // Query
                IIntegerType datatype = service.GetRequired<IRequestFor<IIntegerType>, IIntegerType>(request);
                // </03>
                // Print
                WriteLine(datatype.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
            }
            {
                // <04>
                // Create service
                IService service = Services.Create((ServiceHandlers.Instance, DataTypeHandlers.Instance));
                // Create request
                DataTypeRequest<IIntegerType> request = new(typeof(int));
                // Request
                IIntegerType datatype = service.GetRequired<DataTypeRequest<IIntegerType>, IIntegerType>(request);
                // </04>
                // Print
                WriteLine(datatype.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
            }
            {
                // <05>
                WriteLine(DataTypes.Bool.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.SByte.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.Byte.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.Short.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.UShort.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.Int.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.UInt.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.Long.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.ULong.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                WriteLine(DataTypes.BigInteger.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
                // </05>
            }
        }
    }
    
    Back to top Copyright © 2022 Toni Kalajainen, contact@avalanche.fi