當前位置: 首頁>>代碼示例>>C#>>正文


C# System.Duration類代碼示例

本文整理匯總了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);
        }
開發者ID:irinabov,項目名稱:debian-qpid-cpp,代碼行數:7,代碼來源:messaging.test.duration.cs

示例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);
 }
開發者ID:AnalyticalGraphicsInc,項目名稱:czml-writer,代碼行數:7,代碼來源:TestDuration.cs

示例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);
 }
開發者ID:s-moon,項目名稱:30-Websites-in-ASP-Net,代碼行數:7,代碼來源:DurationTest.cs

示例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);
        }
開發者ID:AnalyticalGraphicsInc,項目名稱:czml-writer,代碼行數:27,代碼來源:TestDuration.cs

示例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);
 }
開發者ID:s-moon,項目名稱:30-Websites-in-ASP-Net,代碼行數:7,代碼來源:DurationTest.cs

示例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);
 }
開發者ID:ivandrofly,項目名稱:nodatime,代碼行數:7,代碼來源:DurationTest.Operators.cs

示例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));
        }
開發者ID:slojo404,項目名稱:czml-writer,代碼行數:31,代碼來源:TestDuration.cs

示例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);
 }
開發者ID:AnalyticalGraphicsInc,項目名稱:czml-writer,代碼行數:7,代碼來源:TestDuration.cs

示例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);
 }
開發者ID:s-moon,項目名稱:30-Websites-in-ASP-Net,代碼行數:7,代碼來源:DurationTest.cs

示例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");
 }
開發者ID:webappsuk,項目名稱:CoreLibraries,代碼行數:14,代碼來源:AsyncDebouncedAction.cs

示例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;
 }
開發者ID:webappsuk,項目名稱:CoreLibraries,代碼行數:15,代碼來源:DurationValidator.cs

示例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;
 }
開發者ID:WaveEngine,項目名稱:Components,代碼行數:11,代碼來源:CheckBoxBehavior.cs

示例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;
 }
開發者ID:Egipto87,項目名稱:DOOP.ec,代碼行數:11,代碼來源:DurabilityServiceQosPolicyImpl.cs

示例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;
            }
        }
開發者ID:dstrucl,項目名稱:Tangenta40,代碼行數:52,代碼來源:DocProformaInvoice_AddOn.cs

示例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;
 }
開發者ID:webappsuk,項目名稱:CoreLibraries,代碼行數:22,代碼來源:ScheduledActionResult.cs


注:本文中的System.Duration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。