Class TimeSpanUtilities
Provides useful utilities for working with
ITimeSpan.
Inheritance
TimeSpanUtilities
Assembly: Melanchall.DryWetMidi.dll
Syntax
public static class TimeSpanUtilities
Methods
GetMaxTimeSpan(TimeSpanType)
Gets an object that represents maximum value of time span defined by the specified
time span type.
Declaration
public static ITimeSpan GetMaxTimeSpan(TimeSpanType timeSpanType)
Parameters
| Type |
Name |
Description |
| TimeSpanType |
timeSpanType |
The type of time span to get maximum value. |
Returns
| Type |
Description |
| ITimeSpan |
An object that represents maximum value of time span defined by timeSpanType. |
Exceptions
GetZeroTimeSpan(TimeSpanType)
Gets an object that represents zero value of time span defined by the specified
time span type.
Declaration
public static ITimeSpan GetZeroTimeSpan(TimeSpanType timeSpanType)
Parameters
| Type |
Name |
Description |
| TimeSpanType |
timeSpanType |
The type of time span to get zero value. |
Returns
| Type |
Description |
| ITimeSpan |
An object that represents zero value of time span defined by timeSpanType. |
Exceptions
GetZeroTimeSpan<TTimeSpan>()
Gets an object that represents zero value of time span defined by the specified
time span type.
Declaration
public static TTimeSpan GetZeroTimeSpan<TTimeSpan>() where TTimeSpan : ITimeSpan
Returns
| Type |
Description |
| TTimeSpan |
An object that represents zero value of time span defined by TTimeSpan. |
Type Parameters
| Name |
Description |
| TTimeSpan |
The type of time span to get zero value. |
IsZeroTimeSpan(ITimeSpan)
Gets a value indicating whether the specified time span is zero or not.
Declaration
public static bool IsZeroTimeSpan(this ITimeSpan timeSpan)
Parameters
| Type |
Name |
Description |
| ITimeSpan |
timeSpan |
Time span to check. |
Returns
| Type |
Description |
| bool |
true if the timeSpan represents zero time span;
otherwise, false. |
Exceptions
Parse(string)
Converts the string representation of a time span to its
ITimeSpan equivalent.
Declaration
public static ITimeSpan Parse(string input)
Parameters
| Type |
Name |
Description |
| string |
input |
A string containing a time span to convert. |
Returns
Exceptions
Round(ITimeSpan, TimeSpanRoundingPolicy, long, ITimeSpan, TempoMap)
Rounds a time span using the specified step and rounding policy.
Declaration
public static ITimeSpan Round(this ITimeSpan timeSpan, TimeSpanRoundingPolicy roundingPolicy, long time, ITimeSpan step, TempoMap tempoMap)
Parameters
| Type |
Name |
Description |
| ITimeSpan |
timeSpan |
Time span to round. |
| TimeSpanRoundingPolicy |
roundingPolicy |
Policy according to which the timeSpan should be rounded. |
| long |
time |
Time os the timeSpan. |
| ITimeSpan |
step |
Step to round the timeSpan by. |
| TempoMap |
tempoMap |
Tempo map used to calculate new time span. |
Returns
| Type |
Description |
| ITimeSpan |
A new time span which is the timeSpan rounded using the passed parameters. |
Exceptions
TryParse(string, out ITimeSpan)
Converts the string representation of a time span to its
ITimeSpan equivalent.
A return value indicates whether the conversion succeeded.
Declaration
public static bool TryParse(string input, out ITimeSpan timeSpan)
Parameters
| Type |
Name |
Description |
| string |
input |
A string containing a time span to convert. |
| ITimeSpan |
timeSpan |
When this method returns, contains the ITimeSpan
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. |
TryParse(string, TimeSpanType, out ITimeSpan)
Converts the string representation of a time span to its
ITimeSpan equivalent using
the specified type of time span. A return value indicates whether the conversion succeeded.
Declaration
public static bool TryParse(string input, TimeSpanType timeSpanType, out ITimeSpan timeSpan)
Parameters
| Type |
Name |
Description |
| string |
input |
A string containing a time span to convert. |
| TimeSpanType |
timeSpanType |
the type of time span to convert input to. |
| ITimeSpan |
timeSpan |
When this method returns, contains the ITimeSpan
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. |