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


C# XmlTextReader.ReadToNextSibling方法代码示例

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


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

示例1: ReadXml

        public static LocalizationData ReadXml(XmlTextReader xr)
        {
            Dictionary<String, Field[]> res = new Dictionary<string, Field[]>();
            if (xr.ReadToDescendant("localization"))
                if (xr.ReadToDescendant("type"))
                    do
                    {
                        List<Field> fields = new List<Field>();
                        var name = xr.GetAttribute("name");
                        if (xr.ReadToDescendant("field"))
                            do
                            {
                                switch (xr.NodeType)
                                {
                                    case XmlNodeType.Element:
                                        if (xr.Name == "field")
                                            fields.Add(new Field { FieldName = xr.GetAttribute("name"), LocalizedText = xr.ReadElementContentAsString() });
                                        break;
                                }
                            } while (xr.ReadToNextSibling("field"));

                        if (fields.Count > 0)
                            res[name] = fields.ToArray();
                    }
                    while (xr.ReadToNextSibling("type"));
            return new LocalizationData(res);
        }
开发者ID:codaxy,项目名称:common,代码行数:27,代码来源:LocalizationData.cs

示例2: ParseCML

 public static Molecule ParseCML(FileStream file)
 {
     Dictionary<int, BondingAtom> atoms = new Dictionary<int, BondingAtom>();
     XmlTextReader reader = new XmlTextReader(file);
     reader.ReadToFollowing("molecule");
     reader.ReadToDescendant("atomArray");
     reader.ReadToDescendant("atom");
     do
     {
         atoms.Add(int.Parse(reader.GetAttribute("id").Substring(1)) - 1, new BondingAtom(Elements.FromSymbol(reader.GetAttribute("elementType"))));
     } while (reader.ReadToNextSibling("atom"));
     reader.ReadToNextSibling("bondArray");
     reader.ReadToDescendant("bond");
     do
     {
         string[] atomRefs = reader.GetAttribute("atomRefs2").Split(' ');
         int order = 0;
         switch (reader.GetAttribute("order"))
         {
             case "S":
                 order = 1;
                 break;
             case "D":
                 order = 2;
                 break;
             case "T":
                 order = 3;
                 break;
         }
         atoms[int.Parse(atomRefs[0].Substring(1)) - 1].Bond(atoms[int.Parse(atomRefs[1].Substring(1)) - 1], order);
     } while (reader.ReadToNextSibling("bond"));
     return new Molecule(new List<BondingAtom>(atoms.Values));
 }
开发者ID:SSheldon,项目名称:Chemistry,代码行数:33,代码来源:CML.cs

示例3: GetProjectType

 /// <summary>
 /// Parses the input stream and return the associated project type. The stream should point to a project file (csproj or vbproj)
 /// </summary>
 /// <param name="st">The stream</param>
 /// <returns>the project type</returns>
 public static string GetProjectType(Stream st)
 {
     XmlTextReader rd = new XmlTextReader(st);
     using (rd)
     {
         rd.ReadStartElement("Project");
         rd.ReadToNextSibling("PropertyGroup");
         rd.ReadStartElement("PropertyGroup");
         rd.ReadToNextSibling("OutputType");
         return rd.ReadString();
     }
 }
开发者ID:ericlemes,项目名称:MSBuildCodeMetrics,代码行数:17,代码来源:CountProjectsByProjectTypeProvider.cs

示例4: ProcessFile

 public override void ProcessFile(string filePath, Dictionary<string, LocalizableEntity> map)
 {
     Logger.LogFormat("Processing file {0}", filePath);
     XmlTextReader xr = new XmlTextReader(filePath);
     string propertyPath = string.Empty;
     try
     {
         if (xr.ReadToDescendant("localization"))
             if (xr.ReadToDescendant("type"))
                 do
                 {
                     var className = xr.GetAttribute("name");
                     if (xr.ReadToDescendant("field"))
                         do
                         {
                             switch (xr.NodeType)
                             {
                                 case XmlNodeType.Element:
                                     if (xr.Name == "field")
                                     {
                                         String fieldName = xr.GetAttribute("name");
                                         String fieldValue = xr.ReadElementContentAsString();
                                         LocalizableEntity property = GetLocalizableProperty(filePath, className, fieldName, fieldValue);
                                         propertyPath = property.FullEntityPath;
                                         map.Add(propertyPath, property);
                                     }
                                     break;
                             }
                         } while (xr.ReadToNextSibling("field"));
                 } while (xr.ReadToNextSibling("type"));
     }
     catch (Exception ex)
     {
         Logger.LogFormat("Error ({0})", filePath);
         throw new ExtractorException("Error: '{0}'. Property path: '{1}'", ex.Message, propertyPath);
     }
     finally
     {
         xr.Close();
     }
 }
开发者ID:codaxy,项目名称:dextop-localizer,代码行数:41,代码来源:XmlExtractor.cs

示例5: Form3_Load

 private void Form3_Load(object sender, EventArgs e)
 {
     XmlTextReader reader = new XmlTextReader(flrt.DName);
     reader.ReadToFollowing("Name");
     textBox4.Text = (string)reader.ReadElementContentAs(typeof(string), null);
     reader.ReadToNextSibling("Mask");
     textBox4.Text += (string)reader.ReadElementContentAs(typeof(string), null);
     textBox2.Text = Func.FName;
     Funcs.ReadXml(flrt.DName);
     dataGridView1.DataSource = Funcs;
     dataGridView1.DataMember = "function";
 }
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:12,代码来源:Form3.cs

示例6: OrderWizard

 static OrderWizard()
 {
     string conditionsDataPath =
         HttpContext.Current.Server.MapPath(PathToJoesPubSeatingConditions);
     XmlTextReader reader = new XmlTextReader(conditionsDataPath);
     if (!reader.ReadToFollowing("pubSeatingConditions"))
         throw new XmlException("Can't find <pubSeatingConditions> node.");
     if (!reader.ReadToDescendant("section"))
         throw new XmlException("Can't find any <section> nodes.");
     syosSeatingConditions = new Dictionary<int, string>();
     do
     {
         if (!reader.MoveToAttribute("id"))
             throw new XmlException("Can't find \"id\" attribute for <section>.");
         int id = Int32.Parse(reader.Value.Trim());
         reader.MoveToElement();
         string conditions = reader.ReadElementContentAsString();
         syosSeatingConditions.Add(id, conditions);
     }
     while (reader.ReadToNextSibling("section"));
 }
开发者ID:ThePublicTheater,项目名称:NYSF,代码行数:21,代码来源:OrderWizard.ascx.cs

示例7: Import


//.........这里部分代码省略.........
                    {
                      if (ch.ExternalId == id)
                      {
                        chan = ch;
                        chan.ExternalId = id;
                      }

                      if (chan == null)
                      {
                        // no mapping found, ignore channel
                        continue;
                      }

                      ChannelPrograms newProgChan = new ChannelPrograms();
                      newProgChan.Name = chan.DisplayName;
                      newProgChan.ExternalId = chan.ExternalId;
                      Programs.Add(newProgChan);

                      Log.WriteFile("  channel#{0} xmlid:{1} name:{2} dbsid:{3}", iChannel, chan.ExternalId,
                                    chan.DisplayName, chan.IdChannel);
                      if (!guideChannels.ContainsKey(chan.IdChannel))
                      {
                        guideChannels.Add(chan.IdChannel, chan);
                        dChannelPrograms.Add(chan.IdChannel, newProgChan);
                      }
                    }

                    _status.Channels++;
                    if (showProgress && ShowProgress != null) ShowProgress(_status);
                  }
                }
                iChannel++;
                // get the next channel
              } while (xmlReader.ReadToNextSibling("channel"));
            }
          }

          //xmlReader.Close();

          #endregion

          SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
          sb.AddOrderByField(true, "externalId");
          sb.AddConstraint("externalId IS NOT null");
          sb.AddConstraint(Operator.NotEquals, "externalId", "");

          SqlStatement stmt = sb.GetStatement(true);
          allChannels = ObjectFactory.GetCollection<Channel>(stmt.Execute());
          if (allChannels.Count == 0)
          {
            _isImporting = false;
            if (xmlReader != null)
            {
              xmlReader.Close();
              xmlReader = null;
            }

            return true;
          }

          ///////////////////////////////////////////////////////////////////////////
          /*  design:
           * 1. create a Dictionary<string,Channel> using the externalid as the key,
           *    add all channels to this Dictionary 
           *    Note: channel -> guidechannel is a one-to-many relationship. 
           * 2. Read all programs from the xml file
开发者ID:hkjensen,项目名称:MediaPortal-1,代码行数:67,代码来源:XMLTVImport.cs

示例8: LoadIdentity

        private void LoadIdentity(IdentityEnum Identity)
        {
            switch (Identity) {
                case IdentityEnum.Quran:

                    if (!isIdentityLoaded[0]) {
                        XmlTextReader xmlReader;

                        /* Read the list of all the available fonts */
                        FontFamily[] ff = FontFamily.Families;
                        for (int i = 0; i < ff.Length; i++) {
                            cmbFontName.Items.Add((string)ff[i].Name);
                        }
                        cmbFontName.Text = Properties.Settings.Default.FontName;
                        cmbFontSize.Text = Properties.Settings.Default.FontSize;

                        /* Read and Load Extensions */
                        xmlReader = new XmlTextReader(PATH_APP_DATA + "extensions.xml");
                        tafseerStruct rstruct;
                        xmlReader.ReadToFollowing("extension");
                        do {
                            ToolStripItem rItem;
                            rstruct = new tafseerStruct();
                            rstruct.dir = xmlReader.GetAttribute("dir");
                            rstruct.id = xmlReader.GetAttribute("id");
                            xmlReader.ReadToFollowing("title");
                            rstruct.title = xmlReader.ReadElementString();
                            xmlReader.ReadToFollowing("location");
                            rstruct.location = xmlReader.ReadElementString();

                            rItem = mextension.Items.Add(rstruct.title);
                            rItem.Tag = rstruct;
                            rItem.Click += new EventHandler(rItem_Click);

                        } while (xmlReader.ReadToFollowing("extension"));
                        xmlReader.Close();

                        /* Read all the available recitors */
                        xmlReader = new XmlTextReader(PATH_APP_DATA + "recitations.xml");
                        xmlReader.ReadToFollowing("recitation");
                        do {
                            dctReciters.Add(xmlReader.GetAttribute("name"),
                                            xmlReader.GetAttribute("url"));
                            cmbrecitors.Items.Add(xmlReader.GetAttribute("name"));
                        } while (xmlReader.ReadToNextSibling("recitation"));
                        xmlReader.Close();
                        cmbrecitors.SelectedIndex = Properties.Settings.Default.quranReciter;

                        /* Read all the sowar names from the xml file */
                        xmlReader = new XmlTextReader(PATH_APP_DATA + "quran.xml");
                        xmlReader.ReadToFollowing("SOURA");
                        do {
                            cmbSoura.Items.Add(xmlReader.GetAttribute("id") + "."
                                            + xmlReader.GetAttribute("name"));
                        } while (xmlReader.ReadToNextSibling("SOURA"));
                        xmlReader.Close();

                        /* Load the quran to the viewer */
                        qv.LoadXmlFile(PATH_APP_DATA + "quran.xml");
                        qv.LoadQuranParts(PATH_APP_DATA + "quran_parts.xml");

                        /* Read other UI elements settings for the quran identity*/
                        cntright.Panel2Collapsed = Properties.Settings.Default.SearchState;
                        chkSearch.Checked = !cntright.Panel2Collapsed;
                        pnla.SelectedText = Properties.Settings.Default.pnlaSelected;
                        pnlb.SelectedText = Properties.Settings.Default.pnlbSelected;
                        QuranVolume.Position = Properties.Settings.Default.VolumeLevel;

                        xmlpnla = new XmlDocument(); xmlpnlb = new XmlDocument();
                        if (!wc.Contains(GettafseerFromTitle(pnla.SelectedText).id))
                            xmlpnla.Load(GettafseerFromTitle(pnla.SelectedText).location);
                        if (!wc.Contains(GettafseerFromTitle(pnlb.SelectedText).id))
                            xmlpnlb.Load(GettafseerFromTitle(pnlb.SelectedText).location);

                        if (Properties.Settings.Default.ViewMode == 0) {
                            qv.ViewMode = qViewer.ViewModeFlags.SingleLine;
                            chkSingleline.Checked = true;
                        }
                        else {
                            qv.ViewMode = qViewer.ViewModeFlags.MultiLine;
                            chkMultiline.Checked = true;
                        }
                        cmbSoura.SelectedIndex = Properties.Settings.Default.CurrentSoura;
                        qv.SelectedIndex = Properties.Settings.Default.CurrentAya;
                        qv.ScrollPosition = Properties.Settings.Default.CurrentScrollValue;

                    }
                    spcHadeeth.Visible = false;
                    spcQuran.Visible = true;
                    pnlQuranTools.Show();
                    pnlHadeethTools.Hide();
                    isIdentityLoaded[0] = true;

                    break;
                case IdentityEnum.Hadeeth:

                    string hadeethSelected = Properties.Settings.Default.hadeethSelected;
                    StringCollection hadeethSearchHistory = Properties.Settings.Default.hadeethSearchHistory;

                    if (!isIdentityLoaded[1]) { /* Identity is loaded for the first time */
//.........这里部分代码省略.........
开发者ID:yehiasalam,项目名称:equran,代码行数:101,代码来源:Form1.cs

示例9: LoadHadeethTree

        /* Read all el 2a7dees al nabawaya and fill the treeview */
        private void LoadHadeethTree()
        {
            /* Check first if the tree was already loaded*/
            if (trvHadeeth.Nodes.Count > 0) return;

            XmlTextReader xmlReader;
            TreeNode rNode, bNode;

            for (int i = 0; i < 6; i++) {

                /* Check if the file exists first*/
                if (!File.Exists(hadeeth_xml[i])) continue;
                xmlReader = new XmlTextReader(hadeeth_xml[i]);
                xmlReader.ReadToFollowing("kotob");
                rNode = new TreeNode(xmlReader.GetAttribute(0));

                xmlReader.ReadToFollowing("katab");
                do {
                    xmlReader.MoveToFirstAttribute();
                    bNode = new TreeNode(xmlReader.ReadContentAsString());
                    xmlReader.MoveToElement();
                    if (xmlReader.ReadToDescendant("bab")) {
                        /* iterate through el babs in el katab if there are any */
                        do {
                            xmlReader.MoveToAttribute(0);
                            bNode.Nodes.Add(xmlReader.ReadContentAsString());
                        } while (xmlReader.ReadToNextSibling("bab"));
                    }
                    rNode.Nodes.Add(bNode);
                } while (xmlReader.ReadToFollowing("katab"));

                trvHadeeth.Nodes.Add(rNode);

            }
        }
开发者ID:yehiasalam,项目名称:equran,代码行数:36,代码来源:Form1.cs

示例10: Import

        public override SceneFileResult Import(string importFile)
        {
            MogitorsRoot mogRoot = MogitorsRoot.Instance;
            MogitorsSystem system = MogitorsSystem.Instance;

            if (importFile == "")
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName = "";
                dlg.DefaultExt = ".mogscene";
                dlg.Filter = "Mogitor Scene File (.mogscene)|*.mogscene";
                Nullable<bool> result = dlg.ShowDialog();
                if (result != true)
                {
                    return SceneFileResult.Cancel;
                }
                importFile = dlg.FileName;
            }

            string filePath = system.ExtractFilePath(importFile);
            string fileName = system.ExtractFileName(importFile);

            XmlTextReader textReader = new XmlTextReader(importFile);

            system.UpdateLoadProgress(5, "Loading scene objects");

            if (!textReader.ReadToFollowing("MogitorScene"))
                return SceneFileResult.ErrParse;

            // Check version
            string fileVersion = textReader.GetAttribute("Version");
            if (fileVersion != null)
            {
                if (int.Parse(fileVersion) != 1)
                    return SceneFileResult.ErrParse;
            }

            // Read project options
            if (textReader.ReadToFollowing("ProjectOptions") == true)
            {
                system.UpdateLoadProgress(15, "Parsing project options");
                mogRoot.LoadProjectOptions(textReader);

                mogRoot.ProjectOptions.ProjectDir = filePath;
                mogRoot.ProjectOptions.ProjectName = fileName;

                mogRoot.PrepareProjectResources();
            }

            //// Moves the reader back to the "MogitorScene" element node.
            //textReader.MoveToElement();

            system.UpdateLoadProgress(30, "Creating scene objects");

            // Load objects
            Mogre.NameValuePairList param = new Mogre.NameValuePairList();
            while (textReader.ReadToNextSibling("Object"))
            {
                string objectType = textReader.GetAttribute("Type");
                if (objectType == "")
                    continue;

                param.Clear();
                while (textReader.MoveToNextAttribute())
                {
                    param.Insert(textReader.Name, textReader.Value);
                }

                BaseEditor result = MogitorsRoot.Instance.CreateEditorObject(null, objectType, param, false, false);
            }

            mogRoot.AfterLoadScene();

            return SceneFileResult.Ok;
        }
开发者ID:andyhebear,项目名称:likeleon,代码行数:75,代码来源:MogitorsSceneSerializer.cs

示例11: LoadGLFont

        public GLFontData LoadGLFont(string a_szFontDataFile)
        {
            // safty checks:
            if (a_szFontDataFile == null)
            {
                return null;
            }
            else if (a_szFontDataFile == "")
            {
                return null;
            }

            // next we see if this string has been gend already:
            GLFontData oFontData;
            if (m_dicGLFonts.TryGetValue(a_szFontDataFile, out oFontData))
            {
                oFontData.m_uiUseCount++;
                return oFontData;
            }
            oFontData = new GLFontData();

            // We have not loaded the font before so, set up new one:
            oFontData.m_szDataFile = a_szFontDataFile;      // Set Data File path.
            oFontData.m_uiUseCount = 1;

            // Create some Working Vars and Buffers:
            string szTextureFile = "";
            string szBuffer;
            char cBuffer = ' ';

            // first load in XML file.
            XmlTextReader oXMLReader = new XmlTextReader(a_szFontDataFile);

            try
            {
                // Get Texture path:
                if (oXMLReader.ReadToNextSibling("Font")) // works on windows.
                {
                    szTextureFile = oXMLReader.GetAttribute("texture");
                }
                else if (oXMLReader.ReadToDescendant("Font")) // works on linux!
                {
                    szTextureFile = oXMLReader.GetAttribute("texture");
                }
                else
                {
#if LOG4NET_ENABLED
                    logger.Error("Couldn't find texture path for " + a_szFontDataFile);
#endif
                }

                // Move to first Charecter element
                oXMLReader.ReadToDescendant("Character");

                // Loop through all Char elements and get out UV coords for each charcter, save them to the Dic.
                do
                {
                    /// <summary>
                    /// All of the System.Globalization stuff is due ot the fact that the default float.TryParse behaves differently on different computers. thanks microsoft.
                    /// </summary>

                    GLFontData.UVCoords oUVCoords = new GLFontData.UVCoords();

                    System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

                    float minX = 0.0f, minY = 0.0f, maxX = 0.0f, maxY = 0.0f;

                    szBuffer = oXMLReader.GetAttribute("Umin");
                    bool r1 = float.TryParse(szBuffer, System.Globalization.NumberStyles.AllowDecimalPoint, culture, out minX);

                    //bool r1 = float.TryParse(szBuffer, out minX);

                    szBuffer = oXMLReader.GetAttribute("Umax");
                    bool r2 = float.TryParse(szBuffer, System.Globalization.NumberStyles.AllowDecimalPoint, culture, out maxX);

                    //bool r2 = float.TryParse(szBuffer, out maxX);


                    szBuffer = oXMLReader.GetAttribute("Vmin");
                    bool r3 = float.TryParse(szBuffer, System.Globalization.NumberStyles.AllowDecimalPoint, culture, out minY);

                    //bool r3 = float.TryParse(szBuffer, out minY);


                    szBuffer = oXMLReader.GetAttribute("Vmax");
                    bool r4 = float.TryParse(szBuffer, System.Globalization.NumberStyles.AllowDecimalPoint, culture, out maxY);

                    //bool r4 = float.TryParse(szBuffer, out maxY);

                    oUVCoords.m_v2UVMin.X = minX;
                    oUVCoords.m_v2UVMax.X = maxX;
                    oUVCoords.m_v2UVMin.Y = minY;
                    oUVCoords.m_v2UVMax.Y = maxY;


                    szBuffer = oXMLReader.GetAttribute("Char");
                    foreach (char c in szBuffer)
                    {
                        cBuffer = c;
                    }
//.........这里部分代码省略.........
开发者ID:EterniaLogic,项目名称:Pulsar4x,代码行数:101,代码来源:ResourceManager.cs

示例12: HandleImportDialog

        private bool HandleImportDialog (ItunesImportDialog dialog, ImportDialogHandler code)
        {
            try {
                if (dialog.Run () == (int)ResponseType.Ok) {
                    if(code != null) {
                        code (dialog);
                    }
                    data.get_ratings = dialog.Ratings;
                    data.get_stats = dialog.Stats;
                    data.get_playlists = dialog.Playliststs;
                } else {
                    return false;
                }
            } finally {
                dialog.Destroy ();
                dialog.Dispose ();
            }

            if (String.IsNullOrEmpty (data.library_uri)) {
                return false;
            }

            // Make sure the library version is supported (version 1.1)
            string message = null;
            bool prompt = false;
            using (var xml_reader = new XmlTextReader (data.library_uri))
            {
                xml_reader.ReadToFollowing ("key");
                do {
                    xml_reader.Read ();
                    string key = xml_reader.ReadContentAsString ();
                    if (key == "Major Version" || key == "Minor Version") {
                        xml_reader.Read ();
                        xml_reader.Read ();
                        if(xml_reader.ReadContentAsString () != "1") {
                            message = Catalog.GetString (
                                "Banshee is not familiar with this version of the iTunes library format." +
                                " Importing may or may not work as expected, or at all. Would you like to attempt to import anyway?");
                            prompt = true;
                            break;
                        }
                    }
                } while (xml_reader.ReadToNextSibling ("key"));
            }

            if (prompt) {
                bool proceed = false;
                using (var message_dialog = new MessageDialog (null, 0, MessageType.Question, ButtonsType.YesNo, message)) {
                    if (message_dialog.Run () == (int)ResponseType.Yes) {
                        proceed = true;
                    }
                    message_dialog.Destroy ();
                }
                if (!proceed) {
                    LogError (data.library_uri, "Unsupported version");
                    return false;
                }
            }

            return true;
        }
开发者ID:allquixotic,项目名称:banshee-gst-sharp-work,代码行数:61,代码来源:ItunesPlayerImportSource.cs

示例13: CountSongs

 private void CountSongs ()
 {
     using (var xml_reader = new XmlTextReader (data.library_uri)) {
         xml_reader.ReadToDescendant("dict");
         xml_reader.ReadToDescendant("dict");
         xml_reader.ReadToDescendant("dict");
         do {
             data.total_songs++;
         } while (xml_reader.ReadToNextSibling ("dict"));
     }
 }
开发者ID:allquixotic,项目名称:banshee-gst-sharp-work,代码行数:11,代码来源:ItunesPlayerImportSource.cs

示例14: okButton_Click

        private void okButton_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(packageInputPath.Text))
            {
                MessageBox.Show("Your input directory does not exist. Please select a different one.", "Convert Project", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!Directory.Exists(outputDirectory.Text))
                Directory.CreateDirectory(outputDirectory.Text);

            // Make sure the user knows we're busy...
            System.Threading.Thread.Sleep(100);
            cvWorking.Visible = true;

            modEditor me = new modEditor();
            Dictionary<string, string> details = Classes.ModParser.parsePackageInfo(packageInfoXMLPath.Text);
            me.generateSQL(outputDirectory.Text, true, details);

            // Update a setting.
            string updatesql = "UPDATE settings SET value = \"false\" WHERE key = \"autoGenerateModID\"";
            SQLiteCommand ucomm = new SQLiteCommand(updatesql, me.conn);
            ucomm.ExecuteNonQuery();

            // Create a readme.txt if the text is inline.
            bool readmeTextInline = (readmeTXTPath.Text == "Inline");

            // Parse the XML.
            #region Read the install.xml, if it exists.
            if (File.Exists(installXmlPath.Text))
            {
                XmlTextReader xmldoc = new XmlTextReader(installXmlPath.Text);
                xmldoc.DtdProcessing = DtdProcessing.Ignore;
                string currfile = "";
                string sql = "INSERT INTO instructions(id, before, after, type, file, optional) VALUES(null, @beforeText, @afterText, @type, @fileEdited, @optional)";

                while (xmldoc.Read())
                {
                    if (xmldoc.NodeType.Equals(XmlNodeType.Element))
                    {
                        switch (xmldoc.LocalName)
                        {
                            case "file":
                                currfile = xmldoc.GetAttribute("name");
                                break;

                            case "operation":
                                SQLiteCommand command = new SQLiteCommand(sql, me.conn);
                                command.Parameters.AddWithValue("@fileEdited", currfile);
                                command.Parameters.AddWithValue("@optional", (xmldoc.GetAttribute("error") == "skip"));

                                xmldoc.ReadToDescendant("search");
                                command.Parameters.AddWithValue("@type", xmldoc.GetAttribute("position"));
                                command.Parameters.AddWithValue("@beforeText", xmldoc.ReadElementContentAsString().Replace("\r", "\n").Replace("\n", "\r\n"));

                                xmldoc.ReadToNextSibling("add");
                                command.Parameters.AddWithValue("@afterText", xmldoc.ReadElementContentAsString().Replace("\r", "\n").Replace("\n", "\r\n"));

                                command.ExecuteNonQuery();
                                break;
                        }
                    }
                }
            }
            #endregion

            // Copy over any remaining files.
            Dictionary<string, string> pfiles = new Dictionary<string, string>();
            Directory.CreateDirectory(outputDirectory.Text + "/Package");
            Directory.CreateDirectory(outputDirectory.Text + "/Source");

            pfiles.Add("Package/package-info.xml", packageInfoXMLPath.Text);
            if (!string.IsNullOrEmpty(readmeTXTPath.Text))
                pfiles.Add("Package/readme.txt", readmeTXTPath.Text);
            if (!string.IsNullOrEmpty(installPHPPath.Text))
                pfiles.Add("Package/install.php", installPHPPath.Text);
            if (!string.IsNullOrEmpty(uninstallPHPPath.Text))
                pfiles.Add("Package/uninstall.php", uninstallPHPPath.Text);
            if (!string.IsNullOrEmpty(installDatabasePHPPath.Text))
                pfiles.Add("Package/installDatabase.php", installDatabasePHPPath.Text);
            if (!string.IsNullOrEmpty(uninstallDatabasePHPPath.Text))
                pfiles.Add("Package/uninstallDatabase.php", uninstallDatabasePHPPath.Text);

            foreach (var pair in pfiles)
            {
                if (!File.Exists(pair.Value))
                    continue;

                if (File.Exists(outputDirectory.Text + "/" + pair.Key))
                    File.Delete(outputDirectory.Text + "/" + pair.Key);

                File.Copy(pair.Value, outputDirectory.Text + "/" + pair.Key);
            }

            #region Read the package.xml, if it exists, for any further information.

            if (File.Exists(packageInfoXMLPath.Text))
            {
                XmlDocument l_document = new XmlDocument();
                l_document.Load(packageInfoXMLPath.Text);
//.........这里部分代码省略.........
开发者ID:Yoshi2889,项目名称:ModManager,代码行数:101,代码来源:convertProject.cs

示例15: LoadPersonalizationState

        public override PersonalizationState LoadPersonalizationState(WebPartManager webPartManager, bool ignoreCurrentUser)
        {
            if (null == webPartManager) throw new ArgumentNullException("webPartManager is null");
            DictionaryPersonalizationState state = new DictionaryPersonalizationState(webPartManager);
            string suid = this.GetScreenUniqueIdentifier();

            Cache cache = HttpRuntime.Cache;
            lock (SyncRoot)
            {
                Dictionary<string, PersonalizationDictionary> cachedstates = cache[suid] as Dictionary<string, PersonalizationDictionary>;
                if ((this.IsEnabled && !state.ReadOnly)  || null == cachedstates)
                {
                    string storage = PersonalizationStorage.Instance.Read(XmlPersonalizationProvider.StorageKey, XmlPersonalizationProvider.StorageTemplate);
                    if (!string.IsNullOrEmpty(storage))
                    {
                        using (XmlTextReader reader = new XmlTextReader(new StringReader(storage)))
                        {
                            reader.MoveToContent();
                            if (reader.MoveToAttribute("readOnly"))
                            {
                                bool isReadOnly = false;
                                bool.TryParse(reader.Value, out isReadOnly);
                                state.ReadOnly = isReadOnly;
                                reader.MoveToElement();
                            }
                            if (reader.ReadToDescendant("part"))
                            {
                                int partDepth = reader.Depth;
                                do
                                {
                                    reader.MoveToElement();
                                    reader.MoveToAttribute("id");
                                    string id = reader.Value;
                                    PersonalizationDictionary dictionary = new PersonalizationDictionary();
                                    reader.MoveToContent();
                                    if (reader.ReadToDescendant("property"))
                                    {
                                        int propertyDepth = reader.Depth;
                                        do
                                        {
                                            reader.MoveToElement();
                                            reader.MoveToAttribute("name");
                                            string name = reader.Value;
                                            reader.MoveToAttribute("sensitive");
                                            bool sensitive = bool.Parse(reader.Value);
                                            reader.MoveToAttribute("scope");
                                            PersonalizationScope scope = (PersonalizationScope)int.Parse(reader.Value);
                                            object value = null;
                                            reader.MoveToContent();
                                            if (reader.ReadToDescendant("value"))
                                            {
                                                reader.MoveToAttribute("type");
                                                if (reader.HasValue)
                                                {
                                                    Type type = Type.GetType(reader.Value);
                                                    if (type == null && name == "Configuration")
                                                    {
                                                        type = Type.GetType("LWAS.Infrastructure.Configuration.Configuration, LWAS");
                                                    }
                                                    reader.MoveToContent();
                                                    value = SerializationServices.Deserialize(type, reader);
                                                }
                                            }
                                            dictionary.Add(name, new PersonalizationEntry(value, scope, sensitive));
                                            reader.MoveToElement();
                                            while (propertyDepth < reader.Depth && reader.Read())
                                            {
                                            }
                                        }
                                        while (reader.ReadToNextSibling("property"));
                                    }
                                    state.States.Add(id, dictionary);
                                    reader.MoveToElement();
                                    while (partDepth < reader.Depth && reader.Read())
                                    {
                                    }
                                }
                                while (reader.ReadToNextSibling("part"));
                            }
                        }
                    }

                    string fileToMonitor = PersonalizationStorage.Instance.BuildPath(StorageKey);
                    if (!PersonalizationStorage.Instance.Agent.HasKey(fileToMonitor))
                        fileToMonitor = PersonalizationStorage.Instance.BuildPath(StorageTemplate);
                    cache.Insert(suid, state.States, new CacheDependency(HttpContext.Current.Server.MapPath(fileToMonitor)));
                }
                else
                    state.States = cachedstates;
            }

            return state;
        }
开发者ID:t1b1c,项目名称:lwas,代码行数:93,代码来源:XmlPersonalizationProvider.cs


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