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


C# Category.GetHashCode方法代码示例

本文整理汇总了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;
            });
        }
开发者ID:lenwen,项目名称:mvcforum,代码行数:17,代码来源:CategoryService.cs

示例2: EqualsTestGetHasCodesEquals

 public void EqualsTestGetHasCodesEquals()
 {
     Category o1 = new Category(1, "foo");
     Category o2 = new Category(1, "foo");
     Assert.AreEqual(o1.GetHashCode(), o2.GetHashCode());
 }
开发者ID:feupeu,项目名称:NyhedsfilterP2,代码行数:6,代码来源:CategoryTest.cs

示例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());
        }
开发者ID:juanplopes,项目名称:simple,代码行数:18,代码来源:EntityHelperIntegrationFixture.cs

示例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.");
 }
开发者ID:nithinphilips,项目名称:SMOz,代码行数:9,代码来源:CategoryTest.cs


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