本文整理汇总了C#中Actor.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# Actor.Deserialize方法的具体用法?C# Actor.Deserialize怎么用?C# Actor.Deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actor
的用法示例。
在下文中一共展示了Actor.Deserialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeTestFailedNoNode
public void DeserializeTestFailedNoNode()
{
Actor target = new Actor();
ArgumentNullException expected = new ArgumentNullException("node", "Provided node must not be null.");
ArgumentNullException actual = Assert.Throws<ArgumentNullException>(() => target.Deserialize(null));
Assert.Equal(expected.Message, actual.Message);
}
示例2: DeserializeTestSuccessfull
public void DeserializeTestSuccessfull()
{
string xmlContent =
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><Actors><Actor><id>79415</id><Image>actors/79415.jpg</Image><Name>Nathan Fillion</Name><Role>Richard Castle</Role><SortOrder>0</SortOrder></Actor></Actors>";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(xmlContent);
System.Xml.XmlNode actoresNode = doc.ChildNodes[1];
System.Xml.XmlNode actorNode = actoresNode.ChildNodes[0];
Actor target = new Actor();
target.Deserialize(actorNode);
Assert.Equal(79415, target.Id);
Assert.Equal("actors/79415.jpg", target.ImagePath);
Assert.Equal("Nathan Fillion", target.Name);
Assert.Equal("Richard Castle", target.Role);
Assert.Equal(0, target.SortOrder);
}
示例3: DeserializeActors
/// <summary>
/// Deserializes all actors of the series.
/// </summary>
private void DeserializeActors()
{
if (this.actorsDoc == null || this.actorsDoc.ChildNodes.Count == 0)
{
return;
}
this.Actors = new List<Actor>();
XmlNode actorsNode = this.actorsDoc.ChildNodes[1];
foreach (XmlNode currentNode in actorsNode)
{
if (currentNode.Name.Equals("Actor", StringComparison.OrdinalIgnoreCase))
{
Actor deserializes = new Actor();
deserializes.Deserialize(currentNode);
this.Actors.Add(deserializes);
}
}
}