本文整理汇总了C#中System.App.Serialise方法的典型用法代码示例。如果您正苦于以下问题:C# App.Serialise方法的具体用法?C# App.Serialise怎么用?C# App.Serialise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.App
的用法示例。
在下文中一共展示了App.Serialise方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppSerialiseDeserialise
public void AppSerialiseDeserialise()
{
var originalApp = new App()
{
Key = Guid.NewGuid(),
Name = "Test App",
GroupKey = Guid.NewGuid(),
DeploymentDirectory = "DeploymentDirectory",
MajorVersion = "1.51.0",
Revision = 1,
Tags = new Dictionary<string, string>()
{
{ "tagKey", "Some tag value." },
{ "secondKey", "Multiline \r\n test!" }
}
};
App secondApp;
using (var stream = originalApp.Serialise())
{
secondApp = new App(stream);
}
Assert.AreEqual(originalApp.Key, secondApp.Key);
Assert.AreEqual(originalApp.Name, secondApp.Name);
Assert.AreEqual(originalApp.GroupKey, secondApp.GroupKey);
Assert.AreEqual(originalApp.DeploymentDirectory, secondApp.DeploymentDirectory);
Assert.AreEqual(originalApp.MajorVersion, secondApp.MajorVersion);
Assert.AreEqual(originalApp.Revision, secondApp.Revision);
Assert.IsNotNull(secondApp.Tags);
foreach (var tag in originalApp.Tags)
{
Assert.IsTrue(secondApp.Tags.ContainsKey(tag.Key));
Assert.AreEqual(tag.Value, secondApp.Tags[tag.Key]);
}
}
示例2: AppSerialiseDeserialiseNullTags
public void AppSerialiseDeserialiseNullTags()
{
var originalApp = new App()
{
Key = Guid.NewGuid(),
Name = "Test App",
GroupKey = Guid.NewGuid(),
DeploymentDirectory = "DeploymentDirectory",
MajorVersion = "1.51.0",
Revision = 1,
};
App secondApp;
using (var stream = originalApp.Serialise())
{
secondApp = new App(stream);
}
Assert.AreEqual(originalApp.Key, secondApp.Key);
Assert.AreEqual(originalApp.Name, secondApp.Name);
Assert.AreEqual(originalApp.GroupKey, secondApp.GroupKey);
Assert.AreEqual(originalApp.DeploymentDirectory, secondApp.DeploymentDirectory);
Assert.AreEqual(originalApp.MajorVersion, secondApp.MajorVersion);
Assert.AreEqual(originalApp.Revision, secondApp.Revision);
Assert.AreEqual(originalApp.Tags.Count, secondApp.Tags.Count);
}