當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。