Struct Duration
Represents the duration of time that a Timeline is active.
Inherited Members
Namespace: System.Windows
Assembly: OpenSilver.dll
Syntax
public struct Duration
Constructors
| Improve this Doc View SourceDuration(TimeSpan)
Declaration
public Duration(TimeSpan timeSpan)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | timeSpan | Represents the initial time interval of this duration. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | timeSpan evaluates as less than System.TimeSpan.Zero. |
Properties
| Improve this Doc View SourceAutomatic
Gets a Duration value that is automatically determined.
Declaration
public static readonly Duration Automatic { get; }
Property Value
Type | Description |
---|---|
Duration | A Duration initialized to an automatic value. |
Forever
Gets a Duration value that represents an infinite interval.
Declaration
public static readonly Duration Forever { get; }
Property Value
Type | Description |
---|---|
Duration | A Duration initialized to a forever value. |
HasTimeSpan
Declaration
public readonly bool HasTimeSpan { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if this Duration is a TimeSpan value; otherwise, false. |
TimeSpan
Declaration
public readonly TimeSpan TimeSpan { get; }
Property Value
Type | Description |
---|---|
System.TimeSpan |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException |
Methods
| Improve this Doc View SourceAdd(Duration)
Declaration
public Duration Add(Duration duration)
Parameters
Type | Name | Description |
---|---|---|
Duration | duration | An instance of Duration that represents the value of the current instance plus duration. |
Returns
Type | Description |
---|---|
Duration | If each involved Duration has values, a Duration that represents the combined values. Otherwise this method returns null. |
Compare(Duration, Duration)
Compares one Duration value to another.
Declaration
public static int Compare(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The first instance of Duration to compare. |
Duration | t2 | The second instance of Duration to compare. |
Returns
Type | Description |
---|---|
System.Int32 | If t1 is less than t2, a negative value that represents the difference. If t1 is equal to t2, a value of 0. If t1 is greater than t2, a positive value that represents the difference. |
Equals(Object)
Determines whether a specified object is equal to a Duration.
Declaration
public override bool Equals(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Object to check for equality. |
Returns
Type | Description |
---|---|
System.Boolean | true if value is equal to this Duration; otherwise, false. |
Overrides
Equals(Duration)
Declaration
public bool Equals(Duration duration)
Parameters
Type | Name | Description |
---|---|---|
Duration | duration | The Duration to check for equality. |
Returns
Type | Description |
---|---|
System.Boolean | true if duration is equal to this Duration; otherwise, false. |
Equals(Duration, Duration)
Determines whether two Duration values are equal.
Declaration
public static bool Equals(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | First Duration to compare. |
Duration | t2 | Second Duration to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if t1 is equal to t2; otherwise, false. |
GetHashCode()
Gets a hash code for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | The hash code identifier. |
Overrides
Plus(Duration)
Returns the specified instance of Duration.
Declaration
public static Duration Plus(Duration duration)
Parameters
Type | Name | Description |
---|---|---|
Duration | duration | The instance of Duration to get. |
Returns
Type | Description |
---|---|
Duration | An instance of Duration. |
Subtract(Duration)
Declaration
public Duration Subtract(Duration duration)
Parameters
Type | Name | Description |
---|---|---|
Duration | duration |
Returns
Type | Description |
---|---|
Duration | The subtracted Duration. |
ToString()
Converts a Duration to a System.String representation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String representation of this Duration. |
Overrides
Operators
| Improve this Doc View SourceAddition(Duration, Duration)
Adds two Duration values together.
Declaration
public static Duration operator +(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The first Duration to add. |
Duration | t2 | The second Duration to add. |
Returns
Type | Description |
---|---|
Duration | If both Duration values have TimeSpan values, this method returns the sum of those two values. If either value is set to Automatic, the method returns Automatic. If either value is set to Forever, the method returns Forever. If either t1 or t2 has no value, this method returns null. |
Equality(Duration, Duration)
Determines whether two Duration cases are equal.
Declaration
public static bool operator ==(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The first Duration to compare. |
Duration | t2 | The second Duration to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if both Duration values have equal property values, or if all Duration values are null. Otherwise, this method returns false. |
GreaterThan(Duration, Duration)
Determines if one Duration is greater than another.
Declaration
public static bool operator>(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The Duration value to compare. |
Duration | t2 | The second Duration value to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if both t1 and t2 have values and t1 is greater than t2; otherwise, false. |
GreaterThanOrEqual(Duration, Duration)
Determines whether a Duration is greater than or equal to another.
Declaration
public static bool operator >=(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The first instance of Duration to compare. |
Duration | t2 | The second instance of Duration to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if both t1 and t2 have values and t1 is greater than or equal to t2; otherwise, false. |
Implicit(TimeSpan to Duration)
Declaration
public static implicit operator Duration(TimeSpan timeSpan)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | timeSpan |
Returns
Type | Description |
---|---|
Duration | A created Duration. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | timeSpan evaluates as less than System.TimeSpan.Zero. |
Inequality(Duration, Duration)
Determines if two Duration cases are not equal.
Declaration
public static bool operator !=(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The first Duration to compare. |
Duration | t2 | The second Duration to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if exactly one of t1 or t2 represent a value, or if they both represent values that are not equal; otherwise, false. |
LessThan(Duration, Duration)
Determines if a Duration is less than the value of another instance.
Declaration
public static bool operator <(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The first Duration to compare. |
Duration | t2 | The second Duration to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if both t1 and t2 have values and t1 is less than t2; otherwise, false. |
LessThanOrEqual(Duration, Duration)
Determines if a Duration is less than or equal to another.
Declaration
public static bool operator <=(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The Duration to compare. |
Duration | t2 | The Duration to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if both t1 and t2 have values and t1 is less than or equal to t2; otherwise, false. |
Subtraction(Duration, Duration)
Subtracts the value of one Duration from another.
Declaration
public static Duration operator -(Duration t1, Duration t2)
Parameters
Type | Name | Description |
---|---|---|
Duration | t1 | The first Duration. |
Duration | t2 | The Duration to subtract. |
Returns
Type | Description |
---|---|
Duration | If each Duration has values, a Duration that represents the value of t1 minus t2. If t1 has a value of Forever and t2 has a value of TimeSpan, this method returns Forever. Otherwise this method returns null. |
UnaryPlus(Duration)
Returns the specified Duration.
Declaration
public static Duration operator +(Duration duration)
Parameters
Type | Name | Description |
---|---|---|
Duration | duration | The Duration to get. |
Returns
Type | Description |
---|---|
Duration | The Duration operation result. |