Here are the examples of the csharp api System.Predicate.Invoke(XmlReader) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
Source : SerializationExtensions.cs
with Microsoft Public License
from oldrev
with Microsoft Public License
from oldrev
public static TGraph DeserializeFromXml<TVertex, TEdge, TGraph>(
this XmlReader reader,
Predicate<XmlReader> graphPredicate,
Predicate<XmlReader> vertexPredicate,
Predicate<XmlReader> edgePredicate,
Func<XmlReader, TGraph> graphFactory,
Func<XmlReader, TVertex> vertexFactory,
Func<XmlReader, TEdge> edgeFactory)
where TGraph : clreplaced, IMutableVertexAndEdgeSet<TVertex, TEdge>
where TEdge : IEdge<TVertex>
{
Contract.Requires(reader != null);
Contract.Requires(graphPredicate != null);
Contract.Requires(vertexPredicate != null);
Contract.Requires(edgePredicate != null);
Contract.Requires(graphFactory != null);
Contract.Requires(vertexFactory != null);
Contract.Requires(edgeFactory != null);
// find the graph node
TGraph g = null;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element &&
graphPredicate(reader))
{
g = graphFactory(reader);
break;
}
}
if (g == null)
throw new ArgumentException("could not find graph node");
using (var graphReader = reader.ReadSubtree())
{
while (graphReader.Read())
{
if (graphReader.NodeType == XmlNodeType.Element)
{
if (vertexPredicate(graphReader))
{
var vertex = vertexFactory(graphReader);
g.AddVertex(vertex);
}
else if (edgePredicate(reader))
{
var edge = edgeFactory(graphReader);
g.AddEdge(edge);
}
}
}
}
return g;
}
19
Source : SerializationExtensions.cs
with Microsoft Public License
from oldrev
with Microsoft Public License
from oldrev
public static TGraph DeserializeFromXml<TVertex, TEdge, TGraph>(
this XmlReader reader,
Predicate<XmlReader> graphPredicate,
Predicate<XmlReader> vertexPredicate,
Predicate<XmlReader> edgePredicate,
Func<XmlReader, TGraph> graphFactory,
Func<XmlReader, TVertex> vertexFactory,
Func<XmlReader, TEdge> edgeFactory)
where TGraph : clreplaced, IMutableVertexAndEdgeSet<TVertex, TEdge>
where TEdge : IEdge<TVertex>
{
Contract.Requires(reader != null);
Contract.Requires(graphPredicate != null);
Contract.Requires(vertexPredicate != null);
Contract.Requires(edgePredicate != null);
Contract.Requires(graphFactory != null);
Contract.Requires(vertexFactory != null);
Contract.Requires(edgeFactory != null);
// find the graph node
TGraph g = null;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element &&
graphPredicate(reader))
{
g = graphFactory(reader);
break;
}
}
if (g == null)
throw new ArgumentException("could not find graph node");
using (var graphReader = reader.ReadSubtree())
{
while (graphReader.Read())
{
if (graphReader.NodeType == XmlNodeType.Element)
{
if (vertexPredicate(graphReader))
{
var vertex = vertexFactory(graphReader);
g.AddVertex(vertex);
}
else if (edgePredicate(reader))
{
var edge = edgeFactory(graphReader);
g.AddEdge(edge);
}
}
}
}
return g;
}