本文整理汇总了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();
}
}