本文整理汇总了C#中Locator.FindBy方法的典型用法代码示例。如果您正苦于以下问题:C# Locator.FindBy方法的具体用法?C# Locator.FindBy怎么用?C# Locator.FindBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locator
的用法示例。
在下文中一共展示了Locator.FindBy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NullPredicateOnFindByThrows
public void NullPredicateOnFindByThrows()
{
IReadWriteLocator locator = new Locator();
locator.FindBy(null);
}
示例2: BadSearchModeOnFindByThrows
public void BadSearchModeOnFindByThrows()
{
IReadWriteLocator locator = new Locator();
locator.FindBy((SearchMode)254, delegate { return true; });
}
示例3: FindingByPredicateReturnsClosestResultsOnDuplicateKey
public void FindingByPredicateReturnsClosestResultsOnDuplicateKey()
{
object o1 = new object();
object o2 = new object();
IReadWriteLocator rootLocator = new Locator();
IReadWriteLocator childLocator = new Locator(rootLocator);
rootLocator.Add("foo", o1);
childLocator.Add("foo", o2);
IReadableLocator results;
results = childLocator.FindBy(
SearchMode.Up,
delegate(KeyValuePair<object, object> kvp)
{
return true;
});
Assert.AreEqual(1, results.Count);
Assert.AreSame(o2, results.Get("foo"));
}
示例4: FindingByPredicateCanFindsResultsFromBothParentAndChild
public void FindingByPredicateCanFindsResultsFromBothParentAndChild()
{
object o = new object();
string s = "Hello world";
IReadWriteLocator rootLocator = new Locator();
IReadWriteLocator childLocator = new Locator(rootLocator);
rootLocator.Add("foo", o);
childLocator.Add("bar", s);
IReadableLocator results;
results = childLocator.FindBy(
SearchMode.Up,
delegate(KeyValuePair<object, object> kvp)
{
return true;
});
Assert.AreEqual(2, results.Count);
Assert.AreSame(o, results.Get("foo"));
Assert.AreSame(s, results.Get("bar"));
}
示例5: FindingByPredicateCanClimbTheTree
public void FindingByPredicateCanClimbTheTree()
{
object o = new object();
IReadWriteLocator rootLocator = new Locator();
IReadWriteLocator childLocator = new Locator(rootLocator);
rootLocator.Add("bar", o);
IReadableLocator results;
results = childLocator.FindBy(
SearchMode.Up,
delegate(KeyValuePair<object, object> kvp)
{
return true;
});
Assert.AreEqual(1, results.Count);
Assert.AreSame(o, results.Get("bar"));
}
示例6: DefaultFindByBehaviorIsAskParent
public void DefaultFindByBehaviorIsAskParent()
{
object o = new object();
IReadWriteLocator rootLocator = new Locator();
IReadWriteLocator childLocator = new Locator(rootLocator);
rootLocator.Add("foo", o);
IReadableLocator results;
results = childLocator.FindBy(delegate(KeyValuePair<object, object> kvp)
{
return true;
});
Assert.AreEqual(1, results.Count);
}
示例7: CanFindByPredicate
public void CanFindByPredicate()
{
bool wasCalled = false;
object o1 = new object();
object o2 = new object();
IReadWriteLocator locator = new Locator();
locator.Add("foo1", o1);
locator.Add("foo2", o2);
IReadableLocator results;
results = locator.FindBy(
delegate(KeyValuePair<object, object> kvp)
{
wasCalled = true;
return kvp.Key.Equals("foo1");
});
Assert.IsNotNull(results);
Assert.IsTrue(wasCalled);
Assert.AreEqual(1, results.Count);
Assert.AreSame(o1, results.Get("foo1"));
}