本文整理汇总了C#中Category.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Category.GetHashCode方法的具体用法?C# Category.GetHashCode怎么用?C# Category.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category.GetHashCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSubCategories
public List<Category> GetSubCategories(Category category, List<Category> allCategories, int level = 2)
{
var cacheKey = string.Concat(CacheKeys.Category.StartsWith, "GetSubCategories", "-", category.GetHashCode(), "-", level);
return _cacheService.CachePerRequest(cacheKey, () =>
{
var catsToReturn = new List<Category>();
var cats = allCategories.Where(x => x.ParentCategory != null && x.ParentCategory.Id == category.Id).OrderBy(x => x.SortOrder);
foreach (var cat in cats)
{
cat.Level = level;
catsToReturn.Add(cat);
catsToReturn.AddRange(GetSubCategories(cat, allCategories, level + 1));
}
return catsToReturn;
});
}
示例2: EqualsTestGetHasCodesEquals
public void EqualsTestGetHasCodesEquals()
{
Category o1 = new Category(1, "foo");
Category o2 = new Category(1, "foo");
Assert.AreEqual(o1.GetHashCode(), o2.GetHashCode());
}
示例3: TestHashCodeOnNoKey
public void TestHashCodeOnNoKey()
{
var t1 = new Category();
t1.Id = 12;
var t2 = new Category();
t2.Id = 12;
var t3 = new Category();
t3.Id = 13;
t2.GetHashCode().Should().Not.Be(t1.GetHashCode());
t1.GetHashCode().Should().Not.Be(t2.GetHashCode());
t3.GetHashCode().Should().Not.Be(t1.GetHashCode());
t1.GetHashCode().Should().Not.Be(t3.GetHashCode());
t3.GetHashCode().Should().Not.Be(t2.GetHashCode());
t2.GetHashCode().Should().Not.Be(t3.GetHashCode());
}
示例4: GetHashCodeTest
public void GetHashCodeTest()
{
Category target = new Category(); // TODO: Initialize to an appropriate value
int expected = 0; // TODO: Initialize to an appropriate value
int actual;
actual = target.GetHashCode();
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}