Search Results for

    Show / Hide Table of Contents

    Class MetricTimeSpan

    Represents metric time span which represents hours, minutes and seconds. More info in the Time and length: Representations: Metric article.
    Inheritance
    object
    MetricTimeSpan
    Implements
    ITimeSpan
    IComparable
    IComparable<MetricTimeSpan>
    IEquatable<MetricTimeSpan>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Melanchall.DryWetMidi.Interaction
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public sealed class MetricTimeSpan : ITimeSpan, IComparable, IComparable<MetricTimeSpan>, IEquatable<MetricTimeSpan>

    Constructors

    MetricTimeSpan()

    Initializes a new instance of the MetricTimeSpan.
    Declaration
    public MetricTimeSpan()

    MetricTimeSpan(int, int, int)

    Initializes a new instance of the MetricTimeSpan with the specified numbers of hours, minutes and seconds.
    Declaration
    public MetricTimeSpan(int hours, int minutes, int seconds)
    Parameters
    Type Name Description
    int hours Number of hours.
    int minutes Number of minutes.
    int seconds Number of seconds.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    One of the following errors occurred:

    • hours is negative.
    • minutes is negative.
    • seconds is negative.

    MetricTimeSpan(int, int, int, int)

    Initializes a new instance of the MetricTimeSpan with the specified numbers of hours, minutes, seconds and milliseconds.
    Declaration
    public MetricTimeSpan(int hours, int minutes, int seconds, int milliseconds)
    Parameters
    Type Name Description
    int hours Number of hours.
    int minutes Number of minutes.
    int seconds Number of seconds.
    int milliseconds Number of milliseconds.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    One of the following errors occurred:

    • hours is negative.
    • minutes is negative.
    • seconds is negative.
    • milliseconds is negative.

    MetricTimeSpan(long)

    Initializes a new instance of the MetricTimeSpan with the specified number of microseconds.
    Declaration
    public MetricTimeSpan(long totalMicroseconds)
    Parameters
    Type Name Description
    long totalMicroseconds Number of microseconds which represents metric time span.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException totalMicroseconds is negative.

    MetricTimeSpan(TimeSpan)

    Initializes a new instance of the MetricTimeSpan with the specified TimeSpan object.
    Declaration
    public MetricTimeSpan(TimeSpan timeSpan)
    Parameters
    Type Name Description
    TimeSpan timeSpan Time interval to initialize the MetricTimeSpan.

    Properties

    Hours

    Gets the hours component of the time represented by the current MetricTimeSpan.
    Declaration
    public int Hours { get; }
    Property Value
    Type Description
    int

    Milliseconds

    Gets the milliseconds component of the time represented by the current MetricTimeSpan.
    Declaration
    public int Milliseconds { get; }
    Property Value
    Type Description
    int

    Minutes

    Gets the minutes component of the time represented by the current MetricTimeSpan.
    Declaration
    public int Minutes { get; }
    Property Value
    Type Description
    int

    Seconds

    Gets the seconds component of the time represented by the current MetricTimeSpan.
    Declaration
    public int Seconds { get; }
    Property Value
    Type Description
    int

    TotalDays

    Gets the value of the current MetricTimeSpan expressed in whole and fractional days.
    Declaration
    public double TotalDays { get; }
    Property Value
    Type Description
    double

    TotalHours

    Gets the value of the current MetricTimeSpan expressed in whole and fractional hours.
    Declaration
    public double TotalHours { get; }
    Property Value
    Type Description
    double

    TotalMicroseconds

    Gets the value of the current MetricTimeSpan expressed in microseconds.
    Declaration
    public long TotalMicroseconds { get; }
    Property Value
    Type Description
    long

    TotalMilliseconds

    Gets the value of the current MetricTimeSpan expressed in whole and fractional milliseconds.
    Declaration
    public double TotalMilliseconds { get; }
    Property Value
    Type Description
    double

    TotalMinutes

    Gets the value of the current MetricTimeSpan expressed in whole and fractional minutes.
    Declaration
    public double TotalMinutes { get; }
    Property Value
    Type Description
    double

    TotalSeconds

    Gets the value of the current MetricTimeSpan expressed in whole and fractional seconds.
    Declaration
    public double TotalSeconds { get; }
    Property Value
    Type Description
    double

    Methods

    Add(ITimeSpan, TimeSpanMode)

    Adds a time span to the current one.
    Declaration
    public ITimeSpan Add(ITimeSpan timeSpan, TimeSpanMode mode)
    Parameters
    Type Name Description
    ITimeSpan timeSpan Time span to add to the current one.
    TimeSpanMode mode Mode of the operation that defines meaning of time spans the operation will be performed on.
    Returns
    Type Description
    ITimeSpan Time span that is a sum of the timeSpan and the current time span.
    Remarks
    If timeSpan and the current time span have the same type, the result time span will be of this type too; otherwise - of the MathTimeSpan.
    Exceptions
    Type Condition
    ArgumentNullException timeSpan is invalid.
    InvalidEnumArgumentException mode specified an invalid value.

    Clone()

    Clones the current time span.
    Declaration
    public ITimeSpan Clone()
    Returns
    Type Description
    ITimeSpan Copy of the current time span.

    CompareTo(MetricTimeSpan)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
    Declaration
    public int CompareTo(MetricTimeSpan other)
    Parameters
    Type Name Description
    MetricTimeSpan other An object to compare with this instance.
    Returns
    Type Description
    int

    A value that indicates the relative order of the objects being compared. The return value has these meanings:

    ValueMeaning
    Less than zeroThis instance precedes other in the sort order.
    ZeroThis instance occurs in the same position in the sort order as other.
    Greater than zeroThis instance follows other in the sort order.

    CompareTo(object)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
    Declaration
    public int CompareTo(object other)
    Parameters
    Type Name Description
    object other An object to compare with this instance.
    Returns
    Type Description
    int

    A value that indicates the relative order of the objects being compared. The return value has these meanings:

    ValueMeaning
    Less than zeroThis instance precedes other in the sort order.
    ZeroThis instance occurs in the same position in the sort order as other.
    Greater than zeroThis instance follows other in the sort order.

    Divide(MetricTimeSpan)

    Divides the current time span by the specified MetricTimeSpan returning ration between them.
    Declaration
    public double Divide(MetricTimeSpan timeSpan)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan MetricTimeSpan to divide the current time span by.
    Returns
    Type Description
    double Ratio of the current MetricTimeSpan and timeSpan.
    Exceptions
    Type Condition
    ArgumentNullException timeSpan is null.
    DivideByZeroException timeSpan represents a time span of zero length.

    Divide(double)

    Shrinks the current time span by dividing its length by the specified divisor.
    Declaration
    public ITimeSpan Divide(double divisor)
    Parameters
    Type Name Description
    double divisor Divisor to shrink the time span by.
    Returns
    Type Description
    ITimeSpan Time span that is the current time span shrinked by the divisor.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException divisor is zero or negative.

    Equals(MetricTimeSpan)

    Indicates whether the current object is equal to another object of the same type.
    Declaration
    public bool Equals(MetricTimeSpan other)
    Parameters
    Type Name Description
    MetricTimeSpan other An object to compare with this object.
    Returns
    Type Description
    bool true if the current object is equal to the other parameter; otherwise, false.

    Equals(object)

    Determines whether the specified object is equal to the current object.
    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj The object to compare with the current object.
    Returns
    Type Description
    bool true if the specified object is equal to the current object; otherwise, false.
    Overrides
    object.Equals(object)

    GetHashCode()

    Returns the hash code for this instance.
    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int A 32-bit signed integer hash code.
    Overrides
    object.GetHashCode()

    Multiply(double)

    Stretches the current time span by multiplying its length by the specified multiplier.
    Declaration
    public ITimeSpan Multiply(double multiplier)
    Parameters
    Type Name Description
    double multiplier Multiplier to stretch the time span by.
    Returns
    Type Description
    ITimeSpan Time span that is the current time span stretched by the multiplier.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException multiplier is negative.

    Parse(string)

    Converts the string representation of a metric time span to its MetricTimeSpan equivalent.
    Declaration
    public static MetricTimeSpan Parse(string input)
    Parameters
    Type Name Description
    string input A string containing a time span to convert.
    Returns
    Type Description
    MetricTimeSpan A MetricTimeSpan equivalent to the time span contained in input.
    Exceptions
    Type Condition
    ArgumentException input is null or contains white-spaces only.
    FormatException input has invalid format.

    Subtract(ITimeSpan, TimeSpanMode)

    Subtracts a time span from the current one.
    Declaration
    public ITimeSpan Subtract(ITimeSpan timeSpan, TimeSpanMode mode)
    Parameters
    Type Name Description
    ITimeSpan timeSpan Time span to subtract from the current one.
    TimeSpanMode mode Mode of the operation that defines meaning of time spans the operation will be performed on.
    Returns
    Type Description
    ITimeSpan Time span that is a difference between the timeSpan and the current time span.
    Remarks
    If timeSpan and the current time span have the same type, the result time span will be of this type too; otherwise - of the MathTimeSpan.
    Exceptions
    Type Condition
    ArgumentNullException timeSpan is invalid.
    InvalidEnumArgumentException mode specified an invalid value.

    ToString()

    Returns a string that represents the current object.
    Declaration
    public override string ToString()
    Returns
    Type Description
    string A string that represents the current object.
    Overrides
    object.ToString()

    TryParse(string, out MetricTimeSpan)

    Converts the string representation of a metric time span to its MetricTimeSpan equivalent. A return value indicates whether the conversion succeeded.
    Declaration
    public static bool TryParse(string input, out MetricTimeSpan timeSpan)
    Parameters
    Type Name Description
    string input A string containing a time span to convert.
    MetricTimeSpan timeSpan When this method returns, contains the MetricTimeSpan equivalent of the time span contained in input, if the conversion succeeded, or null if the conversion failed. The conversion fails if the input is null or Empty, or is not of the correct format. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.
    Returns
    Type Description
    bool true if input was converted successfully; otherwise, false.

    Operators

    operator +(MetricTimeSpan, MetricTimeSpan)

    Adds two specified MetricTimeSpan instances.
    Declaration
    public static MetricTimeSpan operator +(MetricTimeSpan timeSpan1, MetricTimeSpan timeSpan2)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan1 The first MetricTimeSpan to add.
    MetricTimeSpan timeSpan2 The second MetricTimeSpan to add.
    Returns
    Type Description
    MetricTimeSpan An object whose value is the sum of the values of timeSpan1 and timeSpan2.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • timeSpan1 is null.
    • timeSpan2 is null.

    operator ==(MetricTimeSpan, MetricTimeSpan)

    Determines if two MetricTimeSpan objects are equal.
    Declaration
    public static bool operator ==(MetricTimeSpan timeSpan1, MetricTimeSpan timeSpan2)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan1 The first MetricTimeSpan to compare.
    MetricTimeSpan timeSpan2 The second MetricTimeSpan to compare.
    Returns
    Type Description
    bool true if time spans are equal, false otherwise.

    operator >(MetricTimeSpan, MetricTimeSpan)

    Indicates whether a specified MetricTimeSpan is greater than another one.
    Declaration
    public static bool operator >(MetricTimeSpan timeSpan1, MetricTimeSpan timeSpan2)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan1 The first MetricTimeSpan to compare.
    MetricTimeSpan timeSpan2 The second MetricTimeSpan to compare.
    Returns
    Type Description
    bool true if the value of timeSpan1 is greater than the value of timeSpan2; otherwise, false.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • timeSpan1 is null.
    • timeSpan2 is null.

    operator >=(MetricTimeSpan, MetricTimeSpan)

    Indicates whether a specified MetricTimeSpan is greater than or equal to another one.
    Declaration
    public static bool operator >=(MetricTimeSpan timeSpan1, MetricTimeSpan timeSpan2)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan1 The first MetricTimeSpan to compare.
    MetricTimeSpan timeSpan2 The second MetricTimeSpan to compare.
    Returns
    Type Description
    bool true if the value of timeSpan1 is greater than or equal to the value of timeSpan2; otherwise, false.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • timeSpan1 is null.
    • timeSpan2 is null.

    implicit operator TimeSpan(MetricTimeSpan)

    Converts MetricTimeSpan to TimeSpan.
    Declaration
    public static implicit operator TimeSpan(MetricTimeSpan timeSpan)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan MetricTimeSpan to convert to TimeSpan.
    Returns
    Type Description
    TimeSpan timeSpan represented as TimeSpan.

    implicit operator MetricTimeSpan(TimeSpan)

    Converts TimeSpan to MetricTimeSpan.
    Declaration
    public static implicit operator MetricTimeSpan(TimeSpan timeSpan)
    Parameters
    Type Name Description
    TimeSpan timeSpan TimeSpan to convert to MetricTimeSpan.
    Returns
    Type Description
    MetricTimeSpan timeSpan represented as MetricTimeSpan.

    operator !=(MetricTimeSpan, MetricTimeSpan)

    Determines if two MetricTimeSpan objects are not equal.
    Declaration
    public static bool operator !=(MetricTimeSpan timeSpan1, MetricTimeSpan timeSpan2)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan1 The first MetricTimeSpan to compare.
    MetricTimeSpan timeSpan2 The second MetricTimeSpan to compare.
    Returns
    Type Description
    bool false if time spans are equal, true otherwise.

    operator <(MetricTimeSpan, MetricTimeSpan)

    Indicates whether a specified MetricTimeSpan is less than another one.
    Declaration
    public static bool operator <(MetricTimeSpan timeSpan1, MetricTimeSpan timeSpan2)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan1 The first MetricTimeSpan to compare.
    MetricTimeSpan timeSpan2 The second MetricTimeSpan to compare.
    Returns
    Type Description
    bool true if the value of timeSpan1 is less than the value of timeSpan2; otherwise, false.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • timeSpan1 is null.
    • timeSpan2 is null.

    operator <=(MetricTimeSpan, MetricTimeSpan)

    Indicates whether a specified MetricTimeSpan is less than or equal to another one.
    Declaration
    public static bool operator <=(MetricTimeSpan timeSpan1, MetricTimeSpan timeSpan2)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan1 The first MetricTimeSpan to compare.
    MetricTimeSpan timeSpan2 The second MetricTimeSpan to compare.
    Returns
    Type Description
    bool true if the value of timeSpan1 is less than or equal to the value of timeSpan2; otherwise, false.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • timeSpan1 is null.
    • timeSpan2 is null.

    operator -(MetricTimeSpan, MetricTimeSpan)

    Subtracts a specified MetricTimeSpan from another one.
    Declaration
    public static MetricTimeSpan operator -(MetricTimeSpan timeSpan1, MetricTimeSpan timeSpan2)
    Parameters
    Type Name Description
    MetricTimeSpan timeSpan1 The minuend.
    MetricTimeSpan timeSpan2 The subtrahend.
    Returns
    Type Description
    MetricTimeSpan An object whose value is the result of the value of timeSpan1 minus the value of timeSpan2.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occurred:

    • timeSpan1 is null.
    • timeSpan2 is null.
    ArgumentException timeSpan1 is less than timeSpan2.

    Implements

    ITimeSpan
    IComparable
    IComparable<T>
    IEquatable<T>

    Extension Methods

    TimeSpanUtilities.IsZeroTimeSpan(ITimeSpan)
    TimeSpanUtilities.Round(ITimeSpan, TimeSpanRoundingPolicy, long, ITimeSpan, TempoMap)
    In this article
    Back to top 2024 / Generated by DocFX