当前位置: 首页>>代码示例>>C#>>正文


C# XElement.ThrowIfNull方法代码示例

本文整理汇总了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")));
        }
开发者ID:tj-miller,项目名称:TextAdventure,代码行数:7,代码来源:MessageColorSerializer.cs

示例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")));
        }
开发者ID:tj-miller,项目名称:TextAdventure,代码行数:8,代码来源:SpriteSerializer.cs

示例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));
        }
开发者ID:nathan-alden,项目名称:old-text-adventure-engine,代码行数:9,代码来源:ActorInstanceLayerSerializer.cs

示例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")));
        }
开发者ID:tj-miller,项目名称:TextAdventure,代码行数:9,代码来源:CharacterSerializer.cs

示例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));
        }
开发者ID:nathan-alden,项目名称:old-text-adventure-engine,代码行数:9,代码来源:SpriteLayerSerializer.cs

示例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")));
        }
开发者ID:tj-miller,项目名称:TextAdventure,代码行数:10,代码来源:SoundEffectSerializer.cs

示例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));
        }
开发者ID:tj-miller,项目名称:TextAdventure,代码行数:10,代码来源:MessageAnswerSerializer.cs

示例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")));
        }
开发者ID:nathan-alden,项目名称:old-text-adventure-engine,代码行数:10,代码来源:ActorSerializer.cs

示例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));
        }
开发者ID:tj-miller,项目名称:TextAdventure,代码行数:11,代码来源:MessageSerializer.cs

示例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));
        }
开发者ID:nathan-alden,项目名称:old-text-adventure-engine,代码行数:11,代码来源:PlayerSerializer.cs

示例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));
        }
开发者ID:nathan-alden,项目名称:old-text-adventure-engine,代码行数:12,代码来源:MessageQuestionSerializer.cs

示例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));
        }
开发者ID:nathan-alden,项目名称:old-text-adventure-engine,代码行数:13,代码来源:TimerSerializer.cs

示例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));
        }
开发者ID:tj-miller,项目名称:TextAdventure,代码行数:14,代码来源:ActorInstanceSerializer.cs

示例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));
        }
开发者ID:nathan-alden,项目名称:old-text-adventure-engine,代码行数:16,代码来源:WorldSerializer.cs

示例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));
        }
开发者ID:nathan-alden,项目名称:old-text-adventure-engine,代码行数:16,代码来源:BoardSerializer.cs


注:本文中的System.Xml.Linq.XElement.ThrowIfNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。