本文整理汇总了C#中Network.SaveToStream方法的典型用法代码示例。如果您正苦于以下问题:C# Network.SaveToStream方法的具体用法?C# Network.SaveToStream怎么用?C# Network.SaveToStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network.SaveToStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveToStreamAndLoadFromStream
private Network SaveToStreamAndLoadFromStream(Network network)
{
string fileName = Path.GetTempFileName();
Network loadedNetwork = null;
_fileNames.Add(fileName);
using (FileStream fileStream = File.Open(fileName, FileMode.Create))
{
network.SaveToStream(fileStream);
}
Assert.IsFalse(network.IsDirty);
bool fileExists = File.Exists(fileName);
Assert.AreEqual(true, fileExists);
if (fileExists)
{
using (FileStream fileStream = File.Open(fileName, FileMode.Open))
{
loadedNetwork = Network.LoadFromStream(fileStream);
}
Assert.IsFalse(loadedNetwork.IsDirty);
}
Assert.IsNotNull(loadedNetwork);
return loadedNetwork;
}
示例2: IsDirtyTest
public void IsDirtyTest()
{
Network network = new Network();
Assert.IsTrue(network.IsDirty);
using (MemoryStream memoryStream = new MemoryStream())
{
network.SaveToStream(memoryStream);
}
Assert.IsFalse(network.IsDirty);
NetworkNode networkNode = network.Nodes.Add();
Assert.IsTrue(network.IsDirty);
using (MemoryStream memoryStream = new MemoryStream())
{
network.SaveToStream(memoryStream);
}
Assert.IsFalse(network.IsDirty);
networkNode.Name = "Node 1";
Assert.IsTrue(network.IsDirty);
using (MemoryStream memoryStream = new MemoryStream())
{
network.SaveToStream(memoryStream);
}
Assert.IsFalse(network.IsDirty);
}
示例3: TypeTest
public void TypeTest()
{
Network network = new Network();
Assert.IsTrue(network.IsDirty);
network.Nodes.Add();
network.Nodes.Add();
Assert.IsTrue(network.IsDirty);
NetworkEdge networkEdge = network.Edges.Add(network.Nodes[0], network.Nodes[1]);
Assert.AreEqual(NetworkEdgeType.IsA, networkEdge.Type);
using (MemoryStream memoryStream = new MemoryStream())
{
network.SaveToStream(memoryStream);
}
Assert.IsFalse(network.IsDirty);
networkEdge.Type = NetworkEdgeType.Agent;
Assert.IsTrue(network.IsDirty);
Assert.AreEqual(NetworkEdgeType.Agent, networkEdge.Type);
}