Primitively Primitively
Primitively Primitively
DocFX + Singulink = ♥

Search Results for

    Class SingleAttribute

    This attribute should be used on a partial record struct to source generate a Primitively ISingle type that encapsulates a float value.

    Inheritance
    object
    Attribute
    PrimitiveAttribute
    NumericAttribute
    SingleAttribute
    Inherited Members
    PrimitiveAttribute.ImplementIValidatableObject
    Namespace: Primitively
    Assembly: Primitively.Abstractions.dll
    Syntax
    [AttributeUsage(AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
    public sealed class SingleAttribute : NumericAttribute
    Remarks

    The generated Primitively type will enforce the specified minimum and maximum value constraints.

    Examples

    These examples show how to use the Single attribute to source generate a Primitively ISingle type.

    [Single]
    public partial record struct Example;
    
    [Single(Minimum = 1.10f)]
    public partial record struct Example;
    
    [Single(Minimum = -10.10f, Maximum = 10.10f)]
    public partial record struct Example;
    
    [Single(2, Minimum = -10.10f, Maximum = 10.10f)]
    public partial record struct Example;

    Constructors

    SingleAttribute()

    Initializes a new instance of the SingleAttribute class.

    Declaration
    public SingleAttribute()

    SingleAttribute(int)

    Initializes a new instance of the SingleAttribute class with the specified number of fractional digits.

    Declaration
    public SingleAttribute(int digits)
    Parameters
    Type Name Description
    int digits

    The number of fractional digits in the value of the source generated Primitively ISingle type.

    SingleAttribute(int, MidpointRounding)

    Initializes a new instance of the SingleAttribute class with the specified number of fractional digits and rounding mode.

    Declaration
    public SingleAttribute(int digits, MidpointRounding mode)
    Parameters
    Type Name Description
    int digits

    The number of fractional digits in the value of the source generated Primitively ISingle type.

    MidpointRounding mode

    The rounding specification for how to round value of the source generated Primitively ISingle type if it is midway between two other numbers.

    Properties

    Digits

    Gets the number of fractional digits in the value of the source generated Primitively IDouble type.

    Declaration
    public int Digits { get; }
    Property Value
    Type Description
    int
    Remarks

    Valid values are: -1 to 6. Values above 6 will default to: -1. Values below -1 with default to: -1. A value of -1 will result in: no rounding.

    Maximum

    Gets or sets the maximum value supported by the source generated Primitively ISingle type.

    Declaration
    public float Maximum { get; set; }
    Property Value
    Type Description
    float

    The default value is float.MinValue. An assigned value should not be less than the Minimum value.

    Minimum

    Gets or sets the minimum value supported by the source generated Primitively ISingle type.

    Declaration
    public float Minimum { get; set; }
    Property Value
    Type Description
    float

    The default value is float.MaxValue. An assigned value should not be greater than the Maximum value.

    Mode

    Gets the rounding specification for how to round value of the source generated Primitively ISingle type if it is midway between two other numbers.

    Declaration
    public MidpointRounding Mode { get; }
    Property Value
    Type Description
    MidpointRounding
    Remarks

    If the value of Digits is -1, this property will have no effect.

    © Electronic Hands. All rights reserved.