本文整理汇总了C#中Graph.PrepareView方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.PrepareView方法的具体用法?C# Graph.PrepareView怎么用?C# Graph.PrepareView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.PrepareView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NodeViewShouldNotIncludeLinksNotMatchingPredicate
public void NodeViewShouldNotIncludeLinksNotMatchingPredicate()
{
// arrange
var graph = new Graph();
var nodeA1 = graph.AddNode(new SampleNode("A1"));
var nodeA2 = graph.AddNode(new SampleNode("A2"));
var link1 = graph.AddLink(nodeA1, nodeA2, new SampleLink("1"));
var link2 = graph.AddLink(nodeA1, nodeA2, new SampleLink("2"));
// act
var view = graph.PrepareView(x => x.Id.StartsWith("A"), x => ((SampleLink)x).Name != "1");
// assert
var nodeA1View = view.Nodes.Single(x => x.Node == nodeA1);
Assert.That(nodeA1View.OutboundLinks, Has.No.Member(link1));
}
示例2: ShouldFilterOutLinks
public void ShouldFilterOutLinks()
{
// arrange
var graph = new Graph();
var nodeA1 = graph.AddNode(new SampleNode("A1"));
var nodeA2 = graph.AddNode(new SampleNode("A2"));
var link1 = graph.AddLink(nodeA1, nodeA2, new SampleLink("1"));
var link2 = graph.AddLink(nodeA1, nodeA2, new SampleLink("2"));
// act
var view = graph.PrepareView(x => true, x => (x is SampleLink) && ((SampleLink)x).Name == "1");
// assert
Assert.That(view.Links, Has
.Member(link1)
.And.Not.Member(link2),
"Nodes has not been filtered");
}
示例3: ShouldFilterOutNodes
public void ShouldFilterOutNodes()
{
// arrange
var graph = new Graph();
var nodeA1 = graph.AddNode(new SampleNode("A1"));
var nodeA2 = graph.AddNode(new SampleNode("A2"));
var nodeB1 = graph.AddNode(new SampleNode("B1"));
var nodeB2 = graph.AddNode(new SampleNode("B2"));
// act
var view = graph.PrepareView(x => x.Id.StartsWith("A"), x => true);
// assert
Assert.That(view.Nodes.Select(x => x.Node), Has
.Member(nodeA1)
.And.Member(nodeA2)
.And.Not.Member(nodeB1)
.And.Not.Member(nodeB2),
"Nodes has not been filtered");
}
示例4: ShouldNotIncludeLinksWithEndNotMatchingPredicate
public void ShouldNotIncludeLinksWithEndNotMatchingPredicate()
{
// arrange
var graph = new Graph();
var nodeA1 = graph.AddNode(new SampleNode("A1"));
var nodeA2 = graph.AddNode(new SampleNode("A2"));
var nodeB1 = graph.AddNode(new SampleNode("B1"));
var nodeB2 = graph.AddNode(new SampleNode("B2"));
var link1 = graph.AddLink(nodeA1, nodeB2, new SampleLink("1"));
var link2 = graph.AddLink(nodeB1, nodeA2, new SampleLink("2"));
var link3 = graph.AddLink(nodeA1, nodeA2, new SampleLink("3"));
// act
var view = graph.PrepareView(x => x.Id.StartsWith("A"), x => true);
// assert
Assert.That(view.Links, Has
.No.Member(link1)
.And.No.Member(link2)
.And.Member(link3));
}