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


C# PropertyDictionary.Remove方法代码示例

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


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

示例1: EqualsEndEnd

        public void EqualsEndEnd()
        {
            PropertyDictionary<ProjectPropertyInstance> dictionary = new PropertyDictionary<ProjectPropertyInstance>();

            ProjectPropertyInstance p1 = ProjectPropertyInstance.Create("aabaaaa", "value1");
            ProjectPropertyInstance p2 = ProjectPropertyInstance.Create("baaaa", "value2");
            dictionary.Set(p1);
            dictionary.Set(p2);

            string constraint = "aabaaa";

            ProjectPropertyInstance p3 = ProjectPropertyInstance.Create("abaaa", "value3");
            dictionary.Set(p3);

            // Should match o3
            ProjectPropertyInstance value1 = MSBuildNameIgnoreCaseComparer.Mutable.GetValueWithConstraints<ProjectPropertyInstance>(dictionary, constraint, 1, 5);

            Assert.IsTrue(Object.ReferenceEquals(p3, value1), "Should have returned the 'abaaa' value");

            dictionary.Remove("abaaa"); // get rid of o3

            ProjectPropertyInstance value2 = MSBuildNameIgnoreCaseComparer.Mutable.GetValueWithConstraints<ProjectPropertyInstance>(dictionary, constraint, 1, 5);

            Assert.IsNull(value2, "Should not have been a match in the dictionary");

            // Even if the string is exactly the same, if only a substring is being compared, then although it 
            // will be judged equal, the hash codes will NOT be the same, and for that reason, a lookup in the 
            // dictionary will fail.  
            int originalHashCode = MSBuildNameIgnoreCaseComparer.Mutable.GetHashCode("aabaaa");
            try
            {
                MSBuildNameIgnoreCaseComparer.Mutable.SetConstraintsForUnitTestingOnly(constraint, 1, 5);

                Assert.IsTrue(MSBuildNameIgnoreCaseComparer.Mutable.Equals("aabaaa", constraint)); // same on both sides
                Assert.AreNotEqual(originalHashCode, MSBuildNameIgnoreCaseComparer.Mutable.GetHashCode(constraint));
            }
            finally
            {
                MSBuildNameIgnoreCaseComparer.Mutable.RemoveConstraintsForUnitTestingOnly();
            }
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:41,代码来源:MSBuildNameIgnoreCaseComparer_Tests.cs


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