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


C# DateTimeOffset.GetHashCode方法代码示例

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


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

示例1: HashCodeShouldHaveSameBehaviorOfNetType

		public void HashCodeShouldHaveSameBehaviorOfNetType()
		{
			var type = new DateTimeOffsetType();
			var now = DateTimeOffset.Now;
			var exactClone = new DateTimeOffset(now.Ticks, now.Offset);
			(now.GetHashCode() == exactClone.GetHashCode()).Should().Be.EqualTo(now.GetHashCode() == type.GetHashCode(exactClone, EntityMode.Poco));
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:7,代码来源:DateTimeOffsetFixture.cs

示例2: 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

示例3: ChangeTime

 private static DateTimeOffset ChangeTime(DateTimeOffset date, object more)
 {
     var random = new Random(date.GetHashCode() + more.GetHashCode());
     return new DateTimeOffset(date.Year, date.Month, date.Day, random.Next(0, 23), random.Next(0, 59), random.Next(0, 59), random.Next(0, 999), date.Offset);
 }
开发者ID:wei-zhou,项目名称:diamond,代码行数:5,代码来源:FakeDataPage.xaml.cs

示例4: CreateContactAsync

 private static async Task CreateContactAsync(DbConnection connection, Guid saleHeaderId, string employee, DateTimeOffset date, int index)
 {
     var random = new Random(date.GetHashCode() + saleHeaderId.GetHashCode() + employee.GetHashCode() + index);
     var method = methods[random.Next(0, methods.Count - 1)];
     await connection.CreateCommand("INSERT INTO [tc_customer_contact]([id],[sale_id],[method],[value],[created],[created_by],[modified],[modified_by])" +
         "VALUES(@id,@sale_id,@method,@value,@created,@created_by,@modified,@modified_by)")
         .AddParameter("@id", DbType.Guid, 0, Guid.NewGuid())
         .AddParameter("@sale_id", DbType.Guid, 0, saleHeaderId)
         .AddParameter("@method", DbType.Byte, 0, method)
         .AddParameter("@value", DbType.String, 1024, GenerateRandomMethodValue(random, method))
         .AddParameter("@status", DbType.Byte, 0, states[random.Next(0, states.Count - 1)])
         .AddParameter("@created", DbType.DateTimeOffset, 0, date)
         .AddParameter("@created_by", DbType.String, 64, employee)
         .AddParameter("@modified", DbType.DateTimeOffset, 0, date)
         .AddParameter("@modified_by", DbType.String, 64, employee)
         .ExecuteNonQueryAsync();
 }
开发者ID:wei-zhou,项目名称:diamond,代码行数:17,代码来源:FakeDataPage.xaml.cs

示例5: CreateSaleLineAsync

 private static async Task CreateSaleLineAsync(DbConnection connection, Guid saleHeaderId, string employee, DateTimeOffset date, int index)
 {
     var random = new Random(date.GetHashCode() + saleHeaderId.GetHashCode() + employee.GetHashCode() + index);
     var product = products[random.Next(0, products.Count - 1)];
     await connection.CreateCommand("INSERT INTO [tc_sale_line]([id],[sale_id],[product_name],[product_description],[product_detail],[unit_price],[quantity],[status],[created],[created_by],[modified],[modified_by])" +
         "VALUES(@id,@sale_id,@product_name,@product_description,@product_detail,@unit_price,@quantity,@status,@created,@created_by,@modified,@modified_by)")
         .AddParameter("@id", DbType.Guid, 0, Guid.NewGuid())
         .AddParameter("@sale_id", DbType.Guid, 0, saleHeaderId)
         .AddParameter("@product_name", DbType.String, 64, product)
         .AddParameter("@product_description", DbType.String, 1024, descriptions[random.Next(0, descriptions.Count - 1)])
         .AddParameter("@product_detail", DbType.Xml, 0, GenerateProductDetail(random, product))
         .AddParameter("@unit_price", DbType.Currency, 0, (decimal)Math.Round((random.NextDouble() + .1D) * random.Next(10000, 10000 * 10000)))
         .AddParameter("@quantity", DbType.Int32, 0, random.Next(1, 3))
         .AddParameter("@status", DbType.Byte, 0, states[random.Next(0, states.Count - 1)])
         .AddParameter("@created", DbType.DateTimeOffset, 0, date)
         .AddParameter("@created_by", DbType.String, 64, employee)
         .AddParameter("@modified", DbType.DateTimeOffset, 0, date)
         .AddParameter("@modified_by", DbType.String, 64, employee)
         .ExecuteNonQueryAsync();
 }
开发者ID:wei-zhou,项目名称:diamond,代码行数:20,代码来源:FakeDataPage.xaml.cs

示例6: CreateSaleHeaderAsync

 private static async Task<Guid> CreateSaleHeaderAsync(DbConnection connection, string employee, DateTimeOffset date)
 {
     var random = new Random(date.GetHashCode() + employee.GetHashCode());
     int maxDayNumber, maxTotalNumber;
     {
         var raw = await connection.CreateCommand("SELECT MAX(sale_day_number) FROM tc_sale_header WHERE [created] >= CONVERT(DATETIMEOFFSET, @from) AND [created] < CONVERT(DATETIMEOFFSET, @to)")
             .AddParameter("@from", DbType.AnsiString, 64, date.ToString("d", CultureInfo.InvariantCulture))
             .AddParameter("@to", DbType.AnsiString, 64, date.AddDays(1).ToString("d", CultureInfo.InvariantCulture))
             .ExecuteScalarAsync();
         maxDayNumber = Convert.IsDBNull(raw) ? 0 : (int)raw;
     }
     {
         var raw = await connection.CreateCommand("SELECT MAX(sale_total_number) FROM tc_sale_header")
             .ExecuteScalarAsync();
         maxTotalNumber = Convert.IsDBNull(raw) ? 0 : (int)raw;
     }
     var id = Guid.NewGuid();
     await connection.CreateCommand("INSERT INTO [tc_sale_header]([id],[sale_number],[sale_day_number],[sale_total_number],[sales_person_name],[customer_name],[status],[created],[created_by],[modified],[modified_by])" +
         "VALUES(@id,@number_text,@day_number,@total_number,@sales_person_name,@customer_name,@status,@created,@created_by,@modified,@modified_by)")
         .AddParameter("@id", DbType.Guid, 0, id)
         .AddParameter("@number_text", DbType.AnsiString, 64, GenerateNumberText(date, maxDayNumber + 1, maxTotalNumber + 1))
         .AddParameter("@day_number", DbType.Int32, 0, maxDayNumber + 1)
         .AddParameter("@total_number", DbType.Int32, 0, maxTotalNumber + 1)
         .AddParameter("@sales_person_name", DbType.String, 64, employee)
         .AddParameter("@customer_name", DbType.String, 64, names[random.Next(0, names.Count - 1)])
         .AddParameter("@status", DbType.Byte, 0, states[random.Next(0, states.Count - 1)])
         .AddParameter("@created", DbType.DateTimeOffset, 0, date)
         .AddParameter("@created_by", DbType.String, 64, employee)
         .AddParameter("@modified", DbType.DateTimeOffset, 0, date)
         .AddParameter("@modified_by", DbType.String, 64, employee)
         .ExecuteNonQueryAsync();
     return id;
 }
开发者ID:wei-zhou,项目名称:diamond,代码行数:33,代码来源:FakeDataPage.xaml.cs


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