本文整理汇总了C#中Parent.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Parent.Save方法的具体用法?C# Parent.Save怎么用?C# Parent.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parent
的用法示例。
在下文中一共展示了Parent.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestParentAndChildRelationsWhenBinaryDeserializing
public void TestParentAndChildRelationsWhenBinaryDeserializing()
{
var parent = new Parent("Parent");
var child = parent.CreateChild("Child");
Assert.AreEqual(((IParent)child).Parent, parent);
var file = _filesHelper.GetTempFile();
parent.Save(file);
var loadedParent = ModelBase.Load<Parent>(file, SerializationMode.Binary);
Assert.AreEqual(parent, ((IParent)loadedParent.Children[0]).Parent);
}
示例2: TestParentAndChildRelationsWhenXmlDeserializing
public void TestParentAndChildRelationsWhenXmlDeserializing()
{
var parent = new Parent("Parent");
var child = parent.CreateChild("Child");
Assert.AreEqual(((IParent)child).Parent, parent);
Parent loadedParent;
using (var memoryStream = new MemoryStream())
{
parent.Save(memoryStream, SerializationMode.Xml, null);
memoryStream.Position = 0L;
loadedParent = ModelBase.Load<Parent>(memoryStream, SerializationMode.Xml, null);
}
Assert.AreEqual(parent, ((IParent)loadedParent.Children[0]).Parent);
}
示例3: TestParentAndChildRelationsWhenBinaryDeserializing
public void TestParentAndChildRelationsWhenBinaryDeserializing()
{
var parent = new Parent("Parent");
var child = parent.CreateChild("Child");
Assert.AreEqual(((IParent)child).Parent, parent);
var file = _filesHelper.GetTempFile();
parent.Save(file);
#if SILVERLIGHT
file.Position = 0L;
#endif
var loadedParent = SavableModelBase<Parent>.Load(file);
Assert.AreEqual(parent, ((IParent)loadedParent.Children[0]).Parent);
}