当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeOffset.Equals方法代码示例

本文整理汇总了C#中DateTimeOffset.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeOffset.Equals方法的具体用法?C# DateTimeOffset.Equals怎么用?C# DateTimeOffset.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTimeOffset的用法示例。


在下文中一共展示了DateTimeOffset.Equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MostRecentlyUsed

        /// <summary>
        /// Initializes a new instance of the <see cref="MostRecentlyUsed"/> class.
        /// </summary>
        /// <param name="filePath">The full file path for the file.</param>
        /// <param name="lastOpened">The last time the file was opened by the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="filePath"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     Thrown if <paramref name="filePath"/> is an empty string.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     Thrown if <paramref name="lastOpened"/> is <see langword="DateTimeOffset.MinValue" /> or <see cref="DateTimeOffset.MaxValue"/>.
        /// </exception>
        public MostRecentlyUsed(string filePath, DateTimeOffset lastOpened)
        {
            {
                Lokad.Enforce.Argument(() => filePath);
                Lokad.Enforce.Argument(() => filePath, Lokad.Rules.StringIs.NotEmpty);

                Lokad.Enforce.With<ArgumentException>(
                    !lastOpened.Equals(DateTimeOffset.MinValue),
                    Resources.Exceptions_Messages_ArgumentException);
                Lokad.Enforce.With<ArgumentException>(
                    !lastOpened.Equals(DateTimeOffset.MaxValue),
                    Resources.Exceptions_Messages_ArgumentException);
            }

            m_FilePath = filePath;
            m_LastOpened = lastOpened;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:31,代码来源:MostRecentlyUsed.cs

示例2: CompareTwoDateInDiffTZ

		public void CompareTwoDateInDiffTZ ()
		{
			DateTimeOffset dt1 = new DateTimeOffset (2007, 12, 16, 15, 06, 00, new TimeSpan (1, 0, 0));
			DateTimeOffset dt2 = new DateTimeOffset (2007, 12, 16, 9, 06, 00, new TimeSpan (-5, 0, 0));
			DateTimeOffset dt3 = new DateTimeOffset (2007, 12, 16, 14, 06, 00, new TimeSpan (1, 0, 0));
			object o = dt1;
			Assert.IsTrue (dt1.CompareTo (dt2) == 0);
			Assert.IsTrue (DateTimeOffset.Compare (dt1, dt2) == 0);
			Assert.IsTrue (dt1 == dt2);
			Assert.IsTrue (dt1.Equals (dt2));
			Assert.IsFalse (dt1 == dt3);
			Assert.IsTrue (dt1 != dt3);
			Assert.IsFalse (dt1.EqualsExact (dt2));
			Assert.IsTrue (dt1.CompareTo (dt3) > 0);
			Assert.IsTrue (((IComparable)dt1).CompareTo (o) == 0);
		}
开发者ID:frje,项目名称:SharpLang,代码行数:16,代码来源:DateTimeOffsetTest.cs

示例3: EqualsObject

		public void EqualsObject ()
		{
			DateTimeOffset offset1 = new DateTimeOffset ();
			Assert.IsFalse (offset1.Equals (null), "null"); // found using Gendarme :)
			Assert.IsTrue (offset1.Equals (offset1), "self");
			DateTimeOffset offset2 = new DateTimeOffset (DateTime.Today);
			Assert.IsFalse (offset1.Equals (offset2), "1!=2");
			Assert.IsFalse (offset2.Equals (offset1), "2!=1");
		}
开发者ID:frje,项目名称:SharpLang,代码行数:9,代码来源:DateTimeOffsetTest.cs

示例4: Equals

        public static void Equals(DateTimeOffset dateTimeOffset1, object obj, bool expectedEquals, bool expectedEqualsExact)
        {
            Assert.Equal(expectedEquals, dateTimeOffset1.Equals(obj));
            if (obj is DateTimeOffset)
            {
                DateTimeOffset dateTimeOffset2 = (DateTimeOffset)obj;
                Assert.Equal(expectedEquals, dateTimeOffset1.Equals(dateTimeOffset2));
                Assert.Equal(expectedEquals, DateTimeOffset.Equals(dateTimeOffset1, dateTimeOffset2));

                Assert.Equal(expectedEquals, dateTimeOffset1.GetHashCode().Equals(dateTimeOffset2.GetHashCode()));
                Assert.Equal(expectedEqualsExact, dateTimeOffset1.EqualsExact(dateTimeOffset2));

                Assert.Equal(expectedEquals, dateTimeOffset1 == dateTimeOffset2);
                Assert.Equal(!expectedEquals, dateTimeOffset1 != dateTimeOffset2);
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:16,代码来源:DateTimeOffsetTests.cs

示例5: Initialize

        /// <summary>
        /// Initializes the builder. This resets all the
        /// internal data structures and prepares them for
        /// the reception of data for a new <see cref="TestSection"/>.
        /// </summary>
        /// <param name="name">The name of the test section.</param>
        /// <param name="startTime">The start time.</param>
        /// <exception cref="ArgumentNullException">
        ///   Thrown when <paramref name="name"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   Thrown when <paramref name="name"/> is an empty string.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   Thrown when <paramref name="startTime"/> is equal to <see cref="DateTimeOffset.MinValue"/>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   Thrown when <paramref name="startTime"/> is equal to <see cref="DateTimeOffset.MaxValue"/>.
        /// </exception>
        public void Initialize(string name, DateTimeOffset startTime)
        {
            {
             Lokad.Enforce.Argument(() => name);
             Lokad.Enforce.Argument(() => name, Lokad.Rules.StringIs.NotEmpty);

             Lokad.Enforce.With<ArgumentOutOfRangeException>(
               !startTime.Equals(DateTimeOffset.MinValue),
               Resources.Exceptions_Messages_ArgumentOutOfRange,
               startTime);
             Lokad.Enforce.With<ArgumentOutOfRangeException>(
               !startTime.Equals(DateTimeOffset.MaxValue),
               Resources.Exceptions_Messages_ArgumentOutOfRange,
               startTime);
             }

             Clear();
             m_Name = name;
             m_StartTime = startTime;
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:39,代码来源:TestSectionBuilder.cs

示例6: AddWarningMessage

        /// <summary>
        /// Adds the warning message.
        /// </summary>
        /// <param name="time">The time on which the message was logged.</param>
        /// <param name="warningMessage">The warning message.</param>
        /// <exception cref="ArgumentNullException">
        ///   Thrown when <paramref name="warningMessage"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   Thrown when <paramref name="warningMessage"/> is an empty string.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   Thrown when <paramref name="time"/> is equal to <see cref="DateTimeOffset.MinValue"/>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   Thrown when <paramref name="time"/> is equal to <see cref="DateTimeOffset.MaxValue"/>.
        /// </exception>
        /// <exception cref="CannotAddMessageToUninitializedTestSectionException">
        ///   Thrown when the <c>Initialize</c> method has not been called.
        /// </exception>
        public void AddWarningMessage(DateTimeOffset time, string warningMessage)
        {
            {
             Lokad.Enforce.Argument(() => warningMessage);
             Lokad.Enforce.Argument(() => warningMessage, Lokad.Rules.StringIs.NotEmpty);

             Lokad.Enforce.With<ArgumentOutOfRangeException>(
               !time.Equals(DateTimeOffset.MinValue),
               Resources.Exceptions_Messages_ArgumentOutOfRange,
               time);
             Lokad.Enforce.With<ArgumentOutOfRangeException>(
               !time.Equals(DateTimeOffset.MaxValue),
               Resources.Exceptions_Messages_ArgumentOutOfRange,
               time);
             }

             if (!WasInitialized)
             {
            throw new CannotAddMessageToUninitializedTestSectionException();
             }

             m_WarningMessages.Add(new DateBasedTestInformation(time, warningMessage));
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:43,代码来源:TestSectionBuilder.cs

示例7: ValidateDateNotDefault

 public static void ValidateDateNotDefault(DateTimeOffset date, string fieldName)
 {
     if(date.Equals(DateTimeOffset.MinValue) || date.Equals(DateTimeOffset.MaxValue))
         throw new OrderFieldBadFormatException(string.Format("{0} date value must have a valid logical date (not default value).", fieldName));
 }
开发者ID:RazorGator,项目名称:sdk_net,代码行数:5,代码来源:InputValidators.cs


注:本文中的DateTimeOffset.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。