本文整理匯總了C#中System.Xml.Linq.XElement.ThrowIfNull方法的典型用法代碼示例。如果您正苦於以下問題:C# XElement.ThrowIfNull方法的具體用法?C# XElement.ThrowIfNull怎麽用?C# XElement.ThrowIfNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Linq.XElement
的用法示例。
在下文中一共展示了XElement.ThrowIfNull方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Deserialize
public MessageColor Deserialize(XElement colorElement)
{
colorElement.ThrowIfNull("colorElement");
return new MessageColor(
ColorSerializer.Instance.Deserialize((string)colorElement.Attribute("color")));
}
示例2: Deserialize
public Sprite Deserialize(XElement spriteElement)
{
spriteElement.ThrowIfNull("spriteElement");
return new Sprite(
CoordinateSerializer.Instance.Deserialize((string)spriteElement.Attribute("coordinate")),
CharacterSerializer.Instance.Deserialize(spriteElement.Element("character")));
}
示例3: Deserialize
public ActorInstanceLayer Deserialize(XElement actorInstanceLayerElement)
{
actorInstanceLayerElement.ThrowIfNull("actorInstanceLayerElement");
return new ActorInstanceLayer(
(Guid)actorInstanceLayerElement.Attribute("boardId"),
SizeSerializer.Instance.Deserialize((string)actorInstanceLayerElement.Attribute("size")),
actorInstanceLayerElement.Elements("actorInstance").Select(ActorInstanceSerializer.Instance.Deserialize));
}
示例4: Deserialize
public Character Deserialize(XElement characterElement)
{
characterElement.ThrowIfNull("characterElement");
return new Character(
Byte.Parse((string)characterElement.Attribute("symbol")),
ColorSerializer.Instance.Deserialize((string)characterElement.Attribute("foregroundColor")),
ColorSerializer.Instance.Deserialize((string)characterElement.Attribute("backgroundColor")));
}
示例5: Deserialize
public SpriteLayer Deserialize(XElement spriteLayerElement)
{
spriteLayerElement.ThrowIfNull("spriteLayerElement");
return new SpriteLayer(
(Guid)spriteLayerElement.Attribute("boardId"),
SizeSerializer.Instance.Deserialize((string)spriteLayerElement.Attribute("size")),
spriteLayerElement.Elements("sprite").Select(SpriteSerializer.Instance.Deserialize));
}
示例6: Deserialize
public SoundEffect Deserialize(XElement soundEffectElement)
{
soundEffectElement.ThrowIfNull("soundEffectElement");
return new SoundEffect(
(Guid)soundEffectElement.Attribute("id"),
(string)soundEffectElement.Attribute("name"),
(string)soundEffectElement.Attribute("description"),
BinarySerializer.Instance.Deserialize((string)soundEffectElement.Element("data")));
}
示例7: Deserialize
public MessageAnswer Deserialize(XElement answerElement)
{
answerElement.ThrowIfNull("answerElement");
return new MessageAnswer(
(Guid)answerElement.Attribute("id"),
(string)answerElement.Attribute("text"),
MessagePartSerializer.Instance.Deserialize(answerElement),
EventHandlerCollectionSerializer.Instance.Deserialize(answerElement));
}
示例8: Deserialize
public Actor Deserialize(XElement actorElement)
{
actorElement.ThrowIfNull("actorElement");
return new Actor(
(Guid)actorElement.Attribute("id"),
(string)actorElement.Attribute("name"),
(string)actorElement.Attribute("description"),
CharacterSerializer.Instance.Deserialize(actorElement.Element("character")));
}
示例9: Deserialize
public Message Deserialize(XElement messageElement)
{
messageElement.ThrowIfNull("messageContainer");
return new Message(
(Guid)messageElement.Attribute("id"),
(string)messageElement.Attribute("name"),
(string)messageElement.Attribute("description"),
ColorSerializer.Instance.Deserialize((string)messageElement.Attribute("backgroundColor")),
MessagePartSerializer.Instance.Deserialize(messageElement));
}
示例10: Deserialize
public Player Deserialize(XElement playerElement)
{
playerElement.ThrowIfNull("playerElement");
return new Player(
(Guid)playerElement.Attribute("id"),
(Guid)playerElement.Attribute("boardId"),
CoordinateSerializer.Instance.Deserialize((string)playerElement.Attribute("coordinate")),
CharacterSerializer.Instance.Deserialize(playerElement.Element("character")),
EventHandlerCollectionSerializer.Instance.Deserialize(playerElement));
}
示例11: Deserialize
public MessageQuestion Deserialize(XElement questionElement)
{
questionElement.ThrowIfNull("questionElement");
return new MessageQuestion(
(string)questionElement.Attribute("prompt"),
ColorSerializer.Instance.Deserialize((string)questionElement.Attribute("questionForegroundColor")),
ColorSerializer.Instance.Deserialize((string)questionElement.Attribute("unselectedAnswerForegroundColor")),
ColorSerializer.Instance.Deserialize((string)questionElement.Attribute("selectedAnswerForegroundColor")),
ColorSerializer.Instance.Deserialize((string)questionElement.Attribute("selectedAnswerBackgroundColor")),
questionElement.Elements("answer").Select(MessageAnswerSerializer.Instance.Deserialize));
}
示例12: Deserialize
public Timer Deserialize(XElement timerElement)
{
timerElement.ThrowIfNull("timerElement");
return new Timer(
(Guid)timerElement.Attribute("id"),
(string)timerElement.Attribute("name"),
(string)timerElement.Attribute("description"),
TimeSpan.ParseExact((string)timerElement.Attribute("interval"), "c", CultureInfo.InvariantCulture),
Enum<TimerState>.Parse((string)timerElement.Attribute("state")),
TimeSpan.ParseExact((string)timerElement.Attribute("elapsed"), "c", CultureInfo.InvariantCulture),
EventHandlerCollectionSerializer.Instance.Deserialize(timerElement));
}
示例13: Deserialize
public ActorInstance Deserialize(XElement actorInstanceElement)
{
actorInstanceElement.ThrowIfNull("actorInstanceElement");
return new ActorInstance(
(Guid)actorInstanceElement.Attribute("id"),
(string)actorInstanceElement.Attribute("name"),
(string)actorInstanceElement.Attribute("description"),
(Guid)actorInstanceElement.Attribute("actorId"),
(Guid)actorInstanceElement.Attribute("boardId"),
CoordinateSerializer.Instance.Deserialize((string)actorInstanceElement.Attribute("coordinate")),
CharacterSerializer.Instance.Deserialize(actorInstanceElement.Element("character")),
EventHandlerCollectionSerializer.Instance.Deserialize(actorInstanceElement));
}
示例14: Deserialize
public World Deserialize(XElement worldElement)
{
worldElement.ThrowIfNull("worldElement");
return new World(
(Guid)worldElement.Attribute("id"),
(int)worldElement.Attribute("version"),
(string)worldElement.Attribute("title"),
PlayerSerializer.Instance.Deserialize(worldElement.Element("startingPlayer")),
worldElement.Elements("board").Select(BoardSerializer.Instance.Deserialize),
worldElement.Elements("actor").Select(ActorSerializer.Instance.Deserialize),
worldElement.Elements("message").Select(MessageSerializer.Instance.Deserialize),
worldElement.Elements("timer").Select(TimerSerializer.Instance.Deserialize),
worldElement.Elements("soundEffect").Select(SoundEffectSerializer.Instance.Deserialize),
worldElement.Elements("song").Select(SongSerializer.Instance.Deserialize));
}
示例15: Deserialize
public Board Deserialize(XElement boardElement)
{
boardElement.ThrowIfNull("boardElement");
return new Board(
(Guid)boardElement.Attribute("id"),
(string)boardElement.Attribute("name"),
(string)boardElement.Attribute("description"),
SizeSerializer.Instance.Deserialize((string)boardElement.Attribute("size")),
SpriteLayerSerializer.Instance.Deserialize(boardElement.Element("backgroundLayer")),
SpriteLayerSerializer.Instance.Deserialize(boardElement.Element("foregroundLayer")),
ActorInstanceLayerSerializer.Instance.Deserialize(boardElement.Element("actorInstanceLayer")),
boardElement.Elements("boardExit").Select(BoardExitSerializer.Instance.Deserialize),
boardElement.Elements("timer").Select(TimerSerializer.Instance.Deserialize),
EventHandlerCollectionSerializer.Instance.Deserialize(boardElement));
}