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


C# XmlReader.ReadContentAsBoolean方法代码示例

本文整理汇总了C#中System.Xml.XmlReader.ReadContentAsBoolean方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadContentAsBoolean方法的具体用法?C# XmlReader.ReadContentAsBoolean怎么用?C# XmlReader.ReadContentAsBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlReader的用法示例。


在下文中一共展示了XmlReader.ReadContentAsBoolean方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsNull

 public static bool IsNull(XmlReader reader)
 {
   bool result = reader.MoveToAttribute("null", UPnPConsts.NS_XSI) && reader.ReadContentAsBoolean();
   reader.MoveToElement();
   return result;
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:6,代码来源:SoapHelper.cs

示例2: LoadLevel

        private void LoadLevel(XmlReader reader, ContentManager content)
        {
            string aCurrentElement = string.Empty;

            int aPositionX = 0;
            int aPositionY = 0;

            //vars for the spawning of objects
            float aSpawnPosX = 0;
            float aSpawnPosY = 0;
            string formation = string.Empty;
            bool mirrored = false;

            while (reader.Read())
            {
                if(reader.NodeType == XmlNodeType.EndElement &&
                    reader.Name.Equals("level", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                else if (reader.NodeType == XmlNodeType.Element)
                {
                    aCurrentElement = reader.Name;

                    switch (aCurrentElement)
                    {
                        case "name":
                            {
                                levelName = reader.ReadElementContentAsString();
                                break;
                            }
                        case "nextlevel":
                            {
                                nextLevel = reader.ReadElementContentAsString();
                                break;
                            }
                        case "description":
                            {
                                description = reader.ReadElementContentAsString();
                                break;
                            }
                        case "tileset":
                            {
                                var texfilelocation = reader.ReadElementContentAsString();
                                LoadTile(texfilelocation, content);
                                break;
                            }
                    }

                }

                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (aCurrentElement == "row")
                    {
                        aPositionY += 1;
                        aPositionX = 0;
                    }
                }

                else if (reader.NodeType == XmlNodeType.Text)
                {
                    if (aCurrentElement == "row")
                    {
                        string aRow = reader.Value;
                        nrOfRows += 1;

                        for (int counter = 0; counter < aRow.Length; counter++)
                        {
                            var tempChar = aRow[counter].ToString().ToCharArray()[0];

                            mapList.Add(new Tile(new Vector2(aPositionX, aPositionY), tempChar));
                            aPositionX += 1;
                        }
                    }
                    else if (aCurrentElement == "positionX")
                    {
                        aSpawnPosX = reader.ReadContentAsFloat();
                        aSpawnPosX *= tilesize;
                    }
                    else if (aCurrentElement == "positionY")
                    {
                        aSpawnPosY = reader.ReadContentAsFloat();
                        aSpawnPosY *= tilesize;
                        aSpawnPosY = -aSpawnPosY;
                    }
                    else if (aCurrentElement == "formation")
                    {
                        formation = reader.Value;
                    }
                    else if (aCurrentElement == "mirrored")
                    {
                        mirrored = reader.ReadContentAsBoolean();
                        mapSpawnList.Add(new LevelSpawnObj(new Vector2(aSpawnPosX, aSpawnPosY), formation, mirrored));
                    }

                }
            }
            StartingCameraPos();
//.........这里部分代码省略.........
开发者ID:Hoobler,项目名称:Projekt1,代码行数:101,代码来源:LevelLoader.cs

示例3: DeserializeNode

    /// <summary>
    /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
    /// to read the contents of the <see cref="SlideshowTreeNode"/> that 
    /// are exposed in this override.
    /// It deserializes recursively.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
    /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
    public override void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
    {
      var slideSerializer = new XmlSerializer(typeof(Slide));
      var dictionarySerializer = new XmlSerializer(typeof(XMLSerializableDictionary<string, int>));
      var browserTreeNode = node as BrowserTreeNode;

      reader.ReadStartElement("BrowserTreeNode");
      reader.ReadStartElement("Name");
      browserTreeNode.Name = reader.ReadString();
      reader.ReadEndElement();
      if (reader.Name == "XMLSerializableDictionaryOfStringInt32")
      {
        browserTreeNode.UrlToID = (XMLSerializableDictionary<string, int>)dictionarySerializer.Deserialize(reader);
      }

      reader.ReadStartElement("OriginURL");
      browserTreeNode.OriginURL = reader.ReadString();
      reader.ReadEndElement();
      reader.ReadStartElement("Category");
      browserTreeNode.Category = reader.ReadString();
      reader.ReadEndElement();
      reader.ReadStartElement("BrowseDepth");
      browserTreeNode.BrowseDepth = reader.ReadContentAsInt();
      reader.ReadEndElement();
      reader.ReadStartElement("Randomize");
      browserTreeNode.Randomize = reader.ReadContentAsBoolean();
      reader.ReadEndElement();
      reader.ReadStartElement("NumberOfItemsToUse");
      browserTreeNode.NumberOfItemsToUse = reader.ReadContentAsInt();
      reader.ReadEndElement();

      if (reader.Name == "Slide")
      {
        browserTreeNode.Slide = (Slide)slideSerializer.Deserialize(reader);
      }

      reader.ReadStartElement("Tag");
      if (reader.Value != string.Empty)
      {
        browserTreeNode.Tag = reader.ReadContentAsString();
        reader.ReadEndElement();
      }

      reader.ReadStartElement("Text");
      node.Text = reader.ReadContentAsString();
      reader.ReadEndElement();
      while (reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element)
      {
        SlideshowTreeNode newNode = new SlideshowTreeNode();
        base.DeserializeNode(reader, newNode);
        this.SetTreeNodeImageKey(newNode);
        node.Nodes.Add(newNode);
      }

      reader.ReadEndElement();

      reader.MoveToContent();
    }
开发者ID:DeSciL,项目名称:Ogama,代码行数:66,代码来源:BrowserTreeNode.cs

示例4: Load

        public void Load(XmlReader x)
        {
            while (x.Read())
            {
                switch (x.LocalName)
                {
                    case "BracketHightlighting":
                        if (x.MoveToAttribute("value"))
                            EnableMatchingBracketHighlighting = x.ReadContentAsBoolean();
                        break;

                    case "UseMethodInsight":
                        if (x.MoveToAttribute("value"))
                            UseMethodInsight = x.ReadContentAsBoolean();
                        break;

                    case "UseCodeCompletion":
                        if (x.MoveToAttribute("value"))
                            UseCodeCompletion = x.ReadContentAsBoolean();
                        break;

                    case "ForceCodeCompetionPopupCommit":
                        if (x.MoveToAttribute("value"))
                            ForceCodeCompetionPopupCommit = x.ReadContentAsBoolean();
                        break;

                    case "UseSemanticErrorHighlighting":
                        if (x.MoveToAttribute("value"))
                            UseSemanticErrorHighlighting = x.ReadContentAsBoolean();
                        break;

                    case "UseSemanticHighlighting":
                        if (x.MoveToAttribute("value"))
                            UseSemanticHighlighting = x.ReadContentAsBoolean();
                        break;

                    case "SmartIndentation":
                        if (x.MoveToAttribute("value"))
                            EnableSmartIndentation = x.ReadContentAsBoolean();
                        break;

                    case "CompletionOptions":
                        CompletionOptions.Instance.Load(x.ReadSubtree());
                        break;

                    case "cv2pdb":
                        cv2pdb_exe = x.ReadString();
                        break;

                    case "dmd":
                        var config = new DMDConfig();
                        config.Load(x);

                        if (config.Version == DVersion.D1)
                            dmd1 = config;
                        else
                            dmd2 = config;
                        break;
                }
            }
        }
开发者ID:ephe-meral,项目名称:D-IDE,代码行数:61,代码来源:DSettings.cs

示例5: ReadPlanet

 /// <summary>
 /// Metodo che legge il pianeta da XML
 /// </summary>
 /// <param name="xr">Istanza XML reader</param>
 /// <param name="StarPosition">Posizione della stella cui si riferisce</param>
 /// <returns></returns>
 static Planet ReadPlanet(XmlReader xr, Vector3 StarPosition)
 {
     //PLANET NAME="Ghipisu" POSITION="{X:173,6179 Y:0 Z:366,2257}" TYPE="Gas6" HABITABLE="False" TERRASCORE="0" RESOURCES="2504679350"
     string name = "", type = "";
     bool habitable = false;
     int terrascore = 0;
     uint resources = 0;
     Vector3 position = new Vector3();
     while (xr.MoveToNextAttribute())
     {
         switch(xr.Name)
         {
             case "NAME":
                 name = xr.Value;
                 break;
             case "POSITION":
                 position = NewVector3FromString(xr.Value);
                 break;
             case "TYPE":
                 type = xr.Value;
                 break;
             case "HABITABLE":
                 habitable = xr.ReadContentAsBoolean();
                 break;
             case "TERRASCORE":
                 terrascore = xr.ReadContentAsInt();
                 break;
             case "RESOURCES":
                 resources = Convert.ToUInt32(xr.Value);
                 break;
         }
     }
     return new Planet(name, position, StarPosition, type, habitable, terrascore, resources);
 }
开发者ID:lukemols,项目名称:GalacticEmpireDesktop,代码行数:40,代码来源:LoadGameClass.cs

示例6: ReadSystem

        /// <summary>
        /// Metodo che legge il sistema solare da XML
        /// </summary>
        /// <param name="xr">Lettore XML</param>
        /// <returns>Istanza del SistemaSolare</returns>
        static SolarSystem ReadSystem(XmlReader xr)
        {
            List<Planet> planets = new List<Planet>();
            Planet actualPlanet = null;

            //Attributi del sistema
            string name = "", starType = "";
            bool discovered = false, inhabited = false;
            Vector3 position = new Vector3();

            while(xr.MoveToNextAttribute())
            {
                switch(xr.Name)
                {//NAME="Mestu" POSITION="{X:-64 Y:0 Z:-32}" TYPE="Red" DISCOVERED="True" INHABITED="True"
                    case "NAME":
                        name = xr.Value;
                        break;
                    case "POSITION":
                        position = NewVector3FromString(xr.Value);
                        break;
                    case "TYPE":
                        starType = xr.Value;
                        break;
                    case "DISCOVERED":
                        discovered = xr.ReadContentAsBoolean();
                        break;
                    case "INHABITED":
                        inhabited = xr.ReadContentAsBoolean();
                        break;
                }
            }

            while (xr.Read() && !(xr.Name == "SYSTEM" && xr.NodeType == XmlNodeType.EndElement))
            {
                if (xr.NodeType == XmlNodeType.EndElement)
                    continue;
                switch (xr.Name)
                {
                    case "PLANET":
                        actualPlanet = ReadPlanet(xr, position);
                        planets.Add(actualPlanet);
                        break;
                    case "SETTLEMENT":
                        actualPlanet.CreateSettlement(ReadSettlement(xr));
                        break;
                    case "PRODUCTS":
                        actualPlanet.PlanetSettlement.SetProducts(ReadProducts(xr));
                        break;
                }
            }

            SolarSystem ss = new SolarSystem(name, position, starType, discovered, inhabited, planets);
            return ss;
        }
开发者ID:lukemols,项目名称:GalacticEmpireDesktop,代码行数:59,代码来源:LoadGameClass.cs

示例7: GetBool

        public static bool GetBool(Schema schema, XmlReader reader, out bool value)
        {
            DebugCheck.NotNull(schema);
            DebugCheck.NotNull(reader);

            if (reader.SchemaInfo.Validity
                == XmlSchemaValidity.Invalid)
            {
                value = true; // we have to set the value to something before returning.
                return false;
            }

            // do this in a try catch, just in case the attribute wasn't validated against an xsd:boolean
            try
            {
                value = reader.ReadContentAsBoolean();
                return true;
            }
            catch (XmlException)
            {
                // we already handled the valid and invalid cases, so it must be NotKnown now.
                Debug.Assert(reader.SchemaInfo.Validity == XmlSchemaValidity.NotKnown, "The schema validity must be NotKnown at this point");
                schema.AddError(
                    ErrorCode.BoolValueExpected, EdmSchemaErrorSeverity.Error, reader,
                    Strings.ValueNotUnderstood(reader.Value, reader.Name));
            }

            value = true; // we have to set the value to something before returning.
            return false;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:30,代码来源:Utils.cs

示例8: load

 public static Computer load(XmlReader reader, OS os)
 {
     while (reader.Name != "computer")
         reader.Read();
     reader.MoveToAttribute("name");
     var compName = reader.ReadContentAsString();
     reader.MoveToAttribute("ip");
     var compIP = reader.ReadContentAsString();
     reader.MoveToAttribute("type");
     var compType = (byte) reader.ReadContentAsInt();
     reader.MoveToAttribute("spec");
     var str1 = reader.ReadContentAsString();
     reader.MoveToAttribute("id");
     var str2 = reader.ReadContentAsString();
     string str3 = null;
     if (reader.MoveToAttribute("devices"))
         str3 = reader.ReadContentAsString();
     string str4 = null;
     if (reader.MoveToAttribute("icon"))
         str4 = reader.ReadContentAsString();
     while (reader.Name != "location")
         reader.Read();
     reader.MoveToAttribute("x");
     var x = reader.ReadContentAsFloat();
     reader.MoveToAttribute("y");
     var y = reader.ReadContentAsFloat();
     while (reader.Name != "security")
         reader.Read();
     reader.MoveToAttribute("level");
     var seclevel = reader.ReadContentAsInt();
     reader.MoveToAttribute("traceTime");
     var num1 = reader.ReadContentAsFloat();
     reader.MoveToAttribute("portsToCrack");
     var num2 = reader.ReadContentAsInt();
     reader.MoveToAttribute("adminIP");
     var str5 = reader.ReadContentAsString();
     var time = -1f;
     if (reader.MoveToAttribute("proxyTime"))
         time = reader.ReadContentAsFloat();
     while (reader.Name != "admin")
         reader.Read();
     reader.MoveToAttribute("type");
     var str6 = reader.ReadContentAsString();
     reader.MoveToAttribute("resetPass");
     var flag1 = reader.ReadContentAsBoolean();
     reader.MoveToAttribute("isSuper");
     var flag2 = reader.ReadContentAsBoolean();
     Administrator administrator = null;
     switch (str6)
     {
         case "fast":
             administrator = new FastBasicAdministrator();
             break;
         case "basic":
             administrator = new BasicAdministrator();
             break;
     }
     if (administrator != null)
         administrator.ResetsPassword = flag1;
     if (administrator != null)
         administrator.IsSuper = flag2;
     while (reader.Name != "links")
         reader.Read();
     var strArray = reader.ReadElementContentAsString().Split();
     Firewall firewall = null;
     while (reader.Name != "portsOpen" && reader.Name != "firewall")
         reader.Read();
     if (reader.Name == "firewall")
         firewall = Firewall.load(reader);
     while (reader.Name != "portsOpen")
         reader.Read();
     var portsList = reader.ReadElementContentAsString();
     var computer = new Computer(compName, compIP, new Vector2(x, y), seclevel, compType, os);
     computer.firewall = firewall;
     computer.admin = administrator;
     if (time > 0.0)
     {
         computer.addProxy(time);
     }
     else
     {
         computer.hasProxy = false;
         computer.proxyActive = false;
     }
     while (reader.Name != "users")
         reader.Read();
     computer.users.Clear();
     while (!(reader.Name == "users") || reader.NodeType != XmlNodeType.EndElement)
     {
         if (reader.Name == "user")
         {
             var userDetail = UserDetail.loadUserDetail(reader);
             if (userDetail.name.ToLower() == "admin")
                 computer.adminPass = userDetail.pass;
             computer.users.Add(userDetail);
         }
         reader.Read();
     }
     while (reader.Name != "daemons")
         reader.Read();
//.........这里部分代码省略.........
开发者ID:strangea,项目名称:OpenHacknet,代码行数:101,代码来源:Computer.cs

示例9: PolicyProperties

 void PolicyProperties(XmlReader reader)
 {
     reader.Read();
     //Set the Security Assertion XML attributes onto the binding properties
     while (reader.MoveToNextAttribute())
     {
         if (reader.Name == "establishSecurityContext")
             EstablishSecurityContext = reader.ReadContentAsBoolean();
         if (reader.Name == "requireSignatureConfirmation")
             RequireSignatureConfirmation = reader.ReadContentAsBoolean();
         if (reader.Name == "requireDerivedKeys")
             RequireDerivedKeys = reader.ReadContentAsBoolean();
         if (reader.Name == "messageProtectionOrder")
         {
             String protectionOrder = reader.Value;
             switch (protectionOrder)
             {
                 case "SignBeforeEncrypt":
                     MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
                     break;
                 case "EncryptBeforeSign":
                     MessageProtectionOrder = MessageProtectionOrder.EncryptBeforeSign;
                     break;
                 case "SignBeforeEncryptAndEncryptSignature":
                     MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature;
                     break;
             }
         }
     }
 }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:30,代码来源:WseHttpBinding.cs

示例10: ReadXml

        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"></see> stream from which the object is deserialized.</param>
        /// <remarks>Documented by Dev05, 2007-08-08</remarks>
        public void ReadXml(XmlReader reader)
        {
            bool wasEmpty = reader.IsEmptyElement;
            reader.Read();

            if (wasEmpty)
            {
                return;
            }

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                switch (reader.Name)
                {
                    case "ForeColor":
                        reader.ReadStartElement("ForeColor");
                        ForeColor = (Color)GetValue(typeof(Color), reader.ReadContentAsString());
                        reader.ReadEndElement();
                        break;
                    case "BackColor":
                        reader.ReadStartElement("BackColor");
                        BackColor = (Color)GetValue(typeof(Color), reader.ReadContentAsString());
                        reader.ReadEndElement();
                        break;
                    case "Font":
                        reader.ReadStartElement("Font");
                        Font = (Font)GetValue(typeof(Font), reader.ReadContentAsString());
                        reader.ReadEndElement();
                        break;
                    default:
                        string propertyname = reader.Name;
                        string typestring = reader.GetAttribute("Type");
                        reader.ReadStartElement(propertyname);
                        if (!string.IsNullOrEmpty(typestring))
                        {
                            object value = null;
                            try
                            {
                                if (typestring == "Font")
                                {
                                    string valuestring = reader.ReadContentAsString();
                                    value = (Font)GetValue(typeof(Font), valuestring);
                                }
                                else if (typestring == "Color")
                                {
                                    string valuestring = reader.ReadContentAsString();
                                    value = (Color)GetValue(typeof(Color), valuestring);
                                }
                                else if (typestring == "Gradient")
                                {
                                    XmlSerializer gradientSerializer = new XmlSerializer(typeof(PanelGradient));
                                    value = (PanelGradient)gradientSerializer.Deserialize(reader);
                                }
                                else if (typestring == "BorderStyle")
                                {
                                    try
                                    {
                                        value = Enum.Parse(typeof(BorderStyle), reader.ReadContentAsString());
                                    }
                                    catch (Exception e) { Trace.WriteLine(e.ToString()); }
                                }
                                else if (typestring == "String")
                                {
                                    value = reader.ReadContentAsString();
                                }
                                else if (typestring == "Boolean")
                                {
                                    value = reader.ReadContentAsBoolean();
                                }
                                else if (typestring == "SpecialSymbols")
                                {
                                    try
                                    {
                                        value = Enum.Parse(typeof(MLifter.Components.GlassButton.SpecialSymbols), reader.ReadContentAsString());
                                    }
                                    catch (Exception e) { Trace.WriteLine(e.ToString()); }
                                }
                                else if (typestring == "Image")
                                {
                                    try
                                    {
                                        string filePath = Path.Combine(Directory.GetCurrentDirectory(), reader.ReadContentAsString());
                                        value = Image.FromFile(filePath) as Image;
                                    }
                                    catch (Exception e) { Trace.WriteLine(e.ToString()); }
                                }
                                else if (typestring == "ImageLayout")
                                {
                                    try
                                    {
                                        value = Enum.Parse(typeof(ImageLayout), reader.ReadContentAsString());
                                    }
                                    catch (Exception e) { Trace.WriteLine(e.ToString()); }
                                }
                            }
//.........这里部分代码省略.........
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:101,代码来源:Styles.cs

示例11: DeserializeNode

    /// <summary>
    /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
    /// to read the contents of the <see cref="Slideshow"/> that 
    /// are exposed in this override. It deserializes recursively.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
    /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
    public override void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
    {
      var shuffleSerializer = new XmlSerializer(typeof(CustomShuffling));

      // Check for Versions < Ogama 4.3
      if (reader.Name == "SlideshowTreeNode")
      {
        base.DeserializeNode(reader, node);
        return;
      }

      reader.ReadStartElement("IsModified");
      this.IsModified = reader.ReadContentAsBoolean();
      reader.ReadEndElement();

      if (reader.Name == "CustomShuffling")
      {
        this.shuffling = (CustomShuffling)shuffleSerializer.Deserialize(reader);
      }


      while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
        (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
      {
        if (reader.Name == "SlideshowTreeNode")
        {
          var newNode = new SlideshowTreeNode();
          newNode.DeserializeNode(reader, newNode);
          this.SetTreeNodeImageKey(newNode);
          node.Nodes.Add(newNode);
        }
        else if (reader.Name == "BrowserTreeNode")
        {
          var newNode = new BrowserTreeNode();
          newNode.DeserializeNode(reader, newNode);
          this.SetTreeNodeImageKey(newNode);
          node.Nodes.Add(newNode);
        }
      }
    }
开发者ID:DeSciL,项目名称:Ogama,代码行数:47,代码来源:Slideshow.cs

示例12: DeserializeNode

    /// <summary>
    /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
    /// to read the contents of the <see cref="SlideshowTreeNode"/> that 
    /// are exposed in this override.
    /// It deserializes recursively.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
    /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
    public virtual void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
    {
      var slideSerializer = new XmlSerializer(typeof(Slide));

      // Check for older versions of Ogama 1.X 
      if (reader.Name == "Slides")
      {
        // A List<Slide> instead of SlideshowTreeNodes
        // in the slideshow node
        reader.ReadStartElement("Slides");
        this.ParseOgamaV1Slideshow(reader, slideSerializer);
        reader.ReadEndElement();
      }
      else if (reader.Name == "Slide")
      {
        // Directly the slides in the slideshow node
        this.ParseOgamaV1Slideshow(reader, slideSerializer);
      }
      else
      {
        // Ogama V2 format
        reader.ReadStartElement("SlideshowTreeNode");
        reader.ReadStartElement("Name");
        node.Name = reader.ReadString();
        reader.ReadEndElement();
        reader.ReadStartElement("Randomize");
        node.Randomize = reader.ReadContentAsBoolean();
        reader.ReadEndElement();
        reader.ReadStartElement("NumberOfItemsToUse");
        node.NumberOfItemsToUse = reader.ReadContentAsInt();
        reader.ReadEndElement();

        if (reader.Name == "Slide")
        {
          node.Slide = (Slide)slideSerializer.Deserialize(reader);
        }

        reader.ReadStartElement("Tag");
        if (reader.Value != string.Empty)
        {
          node.Tag = reader.ReadContentAsString();
          reader.ReadEndElement();
        }

        reader.ReadStartElement("Text");
        node.Text = reader.ReadContentAsString();
        reader.ReadEndElement();
        while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
          (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
        {
          if (reader.Name == "SlideshowTreeNode")
          {
            var newNode = new SlideshowTreeNode();
            newNode.DeserializeNode(reader, newNode);
            this.SetTreeNodeImageKey(newNode);
            node.Nodes.Add(newNode);
          }
          else if (reader.Name == "BrowserTreeNode")
          {
            var newNode = new BrowserTreeNode();
            newNode.DeserializeNode(reader, newNode);
            this.SetTreeNodeImageKey(newNode);
            node.Nodes.Add(newNode);
          }
        }

        reader.ReadEndElement();

        reader.MoveToContent();
      }
    }
开发者ID:DeSciL,项目名称:Ogama,代码行数:79,代码来源:SlideshowTreeNode.cs

示例13: ToObject

        private static TableStorageField ToObject(XmlReader reader, string edmType, bool isNull, string propertyName)
        {
            object value;
            Type dataType;
            string formatString;

            if(edmType == TableStorageConstants.Edm.TYPE_BINARY)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    using(Stream stream = new MemoryStream())
                    {
                        const int size = 256;
                        byte[] buffer = new byte[size];
                        int count;

                        while((count = reader.ReadContentAsBase64(buffer, 0, size)) > 0)
                        {
                            stream.Write(buffer, 0, count);
                        }

                        stream.Seek(0, SeekOrigin.Begin);

                        value = stream;
                    }
                }

                dataType = typeof(byte[]);
                formatString = "{0}";
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_BOOLEAN)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = reader.ReadContentAsBoolean();
                }

                dataType = typeof(bool);
                formatString = "{0}";
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_DATETIME)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = reader.ReadContentAsDateTime();
                }

                dataType = typeof(DateTime);
                formatString = TableStorageConstants.Edm.DATE_TIME_FORMAT;
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_DOUBLE)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = reader.ReadContentAsDouble();
                }

                dataType = typeof(double);
                formatString = "{0}";
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_GUID)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = Guid.Parse(reader.ReadContentAsString());
                }

                dataType = typeof(Guid);
                formatString = "{0:D}";
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_INT)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = reader.ReadContentAsInt();
                }
//.........这里部分代码省略.........
开发者ID:heymagurany,项目名称:TableStorageDataProvider,代码行数:101,代码来源:TableStorageDataReader.cs


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