本文整理汇总了C#中System.Duration类的典型用法代码示例。如果您正苦于以下问题:C# Duration类的具体用法?C# Duration怎么用?C# Duration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Duration类属于System命名空间,在下文中一共展示了Duration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValueOfDefaultIsFOREVER
public void ValueOfDefaultIsFOREVER()
{
Duration isInfinite = new Duration();
bool result = isInfinite.Milliseconds > 1.0E18;
Assert.True(result);
}
示例2: TestAddSeconds
public void TestAddSeconds()
{
Duration test = new Duration(5, 43200.0);
Duration result = test.AddSeconds(45.123);
Assert.AreEqual(5, result.Days);
Assert.AreEqual(43245.123, result.Seconds);
}
示例3: DaysToWaitTwoDays
public void DaysToWaitTwoDays()
{
Duration d = new Duration();
d.StartDate = new DateTime(2016, 1, 1);
d.EndDate = new DateTime(2016, 1, 3);
Assert.AreEqual(2, d.DaysToWait);
}
示例4: TestCompareTo
public void TestCompareTo()
{
Duration duration1 = new Duration(1, 0.0);
Duration duration2 = new Duration(1, 0.0);
Assert.IsTrue(duration1.CompareTo(duration2) == 0);
Assert.IsTrue(duration2.CompareTo(duration1) == 0);
Assert.IsTrue(duration1 >= duration2);
Assert.IsTrue(duration2 <= duration1);
Assert.IsTrue(duration1 <= duration2);
Assert.IsTrue(duration2 >= duration1);
duration2 = new Duration(2, 0.0);
Assert.IsTrue(duration1.CompareTo(duration2) < 0);
Assert.IsTrue(duration2.CompareTo(duration1) > 0);
Assert.IsTrue(duration1 < duration2);
Assert.IsTrue(duration2 > duration1);
Assert.IsTrue(duration1 <= duration2);
Assert.IsTrue(duration2 >= duration1);
duration2 = new Duration(1, 1.0);
Assert.IsTrue(duration1.CompareTo(duration2) < 0);
Assert.IsTrue(duration2.CompareTo(duration1) > 0);
Assert.IsTrue(duration1 < duration2);
Assert.IsTrue(duration2 > duration1);
Assert.IsTrue(duration1 <= duration2);
Assert.IsTrue(duration2 >= duration1);
}
示例5: DaysToWaitUsingLeapYear
public void DaysToWaitUsingLeapYear()
{
Duration d = new Duration();
d.StartDate = new DateTime(2000, 1, 1);
d.EndDate = new DateTime(2001, 1, 1);
Assert.AreEqual(366, d.DaysToWait);
}
示例6: OperatorDivision_Int64
public void OperatorDivision_Int64(int days, long nanoOfDay, long divisor, int expectedDays, long expectedNanoOfDay)
{
var duration = new Duration(days, nanoOfDay);
var actual = duration / divisor;
var expected = new Duration(expectedDays, expectedNanoOfDay);
Assert.AreEqual(expected, actual);
}
示例7: TestEquality
public void TestEquality()
{
Duration first = new Duration(5, 565.0);
Duration second = new Duration(5, 565.0);
Assert.AreEqual(first, second);
Assert.IsTrue(first.Equals(second));
Assert.IsTrue(second.Equals(first));
Assert.IsTrue(first == second);
Assert.IsTrue(second == first);
Assert.IsFalse(first != second);
Assert.IsFalse(second != first);
Assert.AreEqual(0, first.CompareTo(second));
Assert.AreEqual(0, second.CompareTo(first));
first = new Duration(5, 0.00001);
second = new Duration(4, 86399.99999);
Assert.AreNotEqual(first, second);
Assert.IsFalse(first.Equals(second));
Assert.IsFalse(second.Equals(first));
Assert.IsFalse(first == second);
Assert.IsFalse(second == first);
Assert.IsTrue(first != second);
Assert.IsTrue(second != first);
Assert.AreNotEqual(0, first.CompareTo(second));
Assert.AreNotEqual(0, second.CompareTo(first));
Assert.IsTrue(first.EqualsEpsilon(second, 1e-4));
Assert.IsTrue(second.EqualsEpsilon(first, 1e-4));
// Make sure a Duration compared with a non-Duration returns false
Assert.IsFalse(first.Equals(5));
}
示例8: TestAddDays
public void TestAddDays()
{
Duration test = new Duration(5, 43200.0);
Duration result = test.AddDays(45.5);
Assert.AreEqual(51, result.Days);
Assert.AreEqual(0.0, result.Seconds);
}
示例9: DaysPassedSinceJan01ToDec31
public void DaysPassedSinceJan01ToDec31()
{
Duration d = new Duration();
d.StartDate = new DateTime(2015, 1, 1);
d.EndDate = new DateTime(2015, 12, 31);
Assert.AreEqual(1, d.DaysPassed);
}
示例10: AsyncDebouncedAction
/// <summary>
/// Initializes a new instance of the <see cref="AsyncDebouncedAction" /> class.
/// </summary>
/// <param name="action">The action.</param>
/// <param name="duration">The duration is the amount of time the result of a successful execution is held, after the point a successful request was made.</param>
/// <param name="minimumGap">The minimum gap, is the time left after a successful execution before the action can be run again.</param>
public AsyncDebouncedAction(
[NotNull] Func<Task> action,
Duration duration,
Duration minimumGap = default(Duration))
: this(token => action(), duration, minimumGap)
{
if (action == null) throw new ArgumentNullException("action");
}
示例11: DurationValidator
/// <summary>
/// Initializes a new instance of the <see cref="DurationValidator" /> class.
/// </summary>
/// <param name="minValue">The minimum duration allowed to pass validation (inclusive).</param>
/// <param name="maxValue">The maximum duration allowed to pass validation (exclusive).</param>
/// <param name="rangeIsExclusive">If set to <see langword="true" /> the value must be outside the given range.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="minValue" /> is greater than <paramref name="maxValue" />.</exception>
public DurationValidator(Duration minValue, Duration maxValue, bool rangeIsExclusive = false)
{
if (minValue > maxValue)
throw new ArgumentOutOfRangeException(nameof(minValue), Resources.Validator_MinGreaterThanMax);
_minValue = minValue;
_maxValue = maxValue;
_exclusive = rangeIsExclusive;
}
示例12: CheckBoxBehavior
/// <summary>
/// Initializes a new instance of the <see cref="CheckBoxBehavior" /> class.
/// </summary>
public CheckBoxBehavior()
: base("CheckBehavior")
{
Duration duration = new Duration(TimeSpan.FromSeconds(.4f));
this.fadeIn = new SingleAnimation(0, 1, duration);
this.fadeOut = new SingleAnimation(1, 0, duration);
this.isChecked = false;
}
示例13: DurabilityServiceQosPolicyImpl
public DurabilityServiceQosPolicyImpl(HistoryQosPolicyKind kind, Duration serviceCleanupDelay
, int historyDepth, int getMaxSamplesQos, int getMaxInstancesQos, int getMaxSamplesPerInstanceQos, Bootstrap boostrap)
: base(boostrap)
{
this.HistoryQosPolicyKind = kind;
this.ServiceCleanupDelay = serviceCleanupDelay;
this.HistoryDepth = historyDepth;
this.MaxSamplesQos = getMaxSamplesQos;
this.MaxInstancesQos = getMaxInstancesQos;
this.MaxSamplesPerInstanceQos = getMaxSamplesPerInstanceQos;
}
示例14: Get
public bool Get(long DocProformaInvoice_ID)
{
string Err = null;
Clear();
string sql = @"select
dpi.IssueDate,
dpi.DocDuration,
dpi.DocDurationType,
dpi.TermsOfPayment_ID,
dpi.MethodOfPayment_ID,
mop.Atom_BankAccount_ID,
top.Description as TermsOfPayment_Description,
mop.PaymentType,
aba.TRR,
ao.Name,
ao.Tax_ID,
ao.Registration_ID
from DocProformaInvoice dpi
left join TermsOfPayment top on dpi.TermsOfPayment_ID = top.ID
left join MethodOfPayment mop on dpi.MethodOfPayment_ID = mop.ID
left join Atom_BankAccount aba on mop.Atom_BankAccount_ID = aba.ID
left join Atom_Bank ab on aba.Atom_Bank_ID = ab.ID
left join Atom_Organisation ao on ab.Atom_Organisation_ID = ao.ID
where dpi.ID = " + DocProformaInvoice_ID.ToString();
DataTable dt = new DataTable();
if (DBSync.DBSync.ReadDataTable(ref dt, sql, ref Err))
{
if (dt.Rows.Count > 0)
{
m_IssueDate = DocProformaInvoice_AddOn.IssueDate.Set(dt.Rows[0]["IssueDate"]);
m_Duration = DocProformaInvoice_AddOn.Duration.Set(dt.Rows[0]["DocDuration"],
dt.Rows[0]["DocDurationType"]);
m_TermsOfPayment = DocProformaInvoice_AddOn.TermsOfPayment.Set(dt.Rows[0]["TermsOfPayment_ID"],
dt.Rows[0]["TermsOfPayment_Description"]);
m_MethodOfPayment = DocProformaInvoice_AddOn.MethodOfPayment.Set(dt.Rows[0]["MethodOfPayment_ID"],
dt.Rows[0]["PaymentType"],
dt.Rows[0]["Name"],
dt.Rows[0]["Tax_ID"],
dt.Rows[0]["Registration_ID"],
dt.Rows[0]["TRR"],
dt.Rows[0]["Atom_BankAccount_ID"]);
}
return true;
}
else
{
LogFile.Error.Show("ERROR:TangentaDB:DocProformaInvoice_AddOn:Get:sql=" + sql + "\r\nErr=" + Err);
return false;
}
}
示例15: ScheduledActionResult
/// <summary>
/// Initializes a new instance of the <see cref="ScheduledActionResult"/> class.
/// </summary>
/// <param name="due">The due.</param>
/// <param name="started">The started.</param>
/// <param name="duration">The duration.</param>
/// <param name="exception">The exception.</param>
/// <param name="cancelled">if set to <see langword="true"/> the action was cancelled.</param>
/// <remarks></remarks>
protected ScheduledActionResult(
Instant due,
Instant started,
Duration duration,
[CanBeNull] Exception exception,
bool cancelled)
{
Due = due;
Started = started;
Duration = duration;
Exception = exception;
Cancelled = cancelled;
}