本文整理匯總了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);
}
}
}