ReadString() public method

public ReadString ( ) : string
return string
		public virtual NvdlValidatorGenerator CreateGenerator (NvdlValidate validate, string schemaType, NvdlConfig config)
		{
			this.validate = validate;
			this.schema_type = schemaType;
			this.config = config;

			XmlReader schema = null;
			// FIXME: we need a bit more strict check.
			if (schemaType.Length < 5 ||
				!schemaType.EndsWith ("xml") ||
				Char.IsLetter (schemaType, schemaType.Length - 4))
				return null;

			string schemaUri = validate.SchemaUri;
			XmlElement schemaBody = validate.SchemaBody;

			if (schemaUri != null) {
				if (schemaBody != null)
					throw new NvdlCompileException ("Both 'schema' attribute and 'schema' element are specified in a 'validate' element.", validate);
				schema = GetSchemaXmlStream (schemaUri, config, validate);
			}
			else if (validate.SchemaBody != null) {
				XmlReader r = new XmlNodeReader (schemaBody);
				r.MoveToContent ();
				r.Read (); // Skip "schema" element
				r.MoveToContent ();
				if (r.NodeType == XmlNodeType.Element)
					schema = r;
				else
					schema = GetSchemaXmlStream (r.ReadString (), config, validate);
			}

			if (schema == null)
				return null;

			return CreateGenerator (schema, config);
		}
        private void MainApplication_OnLoad(object sender, EventArgs e)
        {
            this.SmtpAccountsList.Items.Clear();
            string[] AccountSettings = new string[7];
            FileLocation = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Smtp Client\\";
            ProgramLocation = Environment.CurrentDirectory;
            FileInfo Settings = new FileInfo(FileLocation + "settings.xml");

            SetWorkingSet(750000, 300000);

            #region Loading Settings from Xml file
            FileInfo IfSettingsExist = new FileInfo(FileLocation + "settings.xml");
            if (IfSettingsExist.Exists)
            {
                try
                {
                    XmlDocument DocumentSettings = new XmlDocument();
                    DocumentSettings.Load(FileLocation + "settings.xml");
                    XmlNodeReader ReadSettings = new XmlNodeReader(DocumentSettings);
                    //int current = 1;

                    while (ReadSettings.Read())
                    {
                        switch (ReadSettings.NodeType)
                        {
                            case XmlNodeType.EndElement:
                                if (ReadSettings.Name == "Account")
                                {
                                    this.SmtpAccountsList.Items.Add(AccountSettings[4] + " <" + AccountSettings[5] + ">      --" + AccountSettings[0]);
                                    AccountList.Add(AccountSettings);
                                    AccountSettings = (string[])AccountSettings.Clone();
                                }
                                break;

                            case XmlNodeType.Element:

                                //Get Account Name:
                                switch (ReadSettings.Name)
                                {

                                    case "AccountName":
                                        AccountSettings[0] = ReadSettings.ReadString();
                                        break;

                                    case "Server":
                                        AccountSettings[1] = ReadSettings.ReadString();
                                        break;

                                    case "Port":
                                        AccountSettings[2] = ReadSettings.ReadString();
                                        break;

                                    case "Username":
                                        AccountSettings[3] = ReadSettings.ReadString();
                                        break;

                                    case "Name":
                                        AccountSettings[4] = ReadSettings.ReadString();
                                        break;

                                    case "mailAddress":
                                        AccountSettings[5] = ReadSettings.ReadString();
                                        break;

                                    case "ReplyTo":
                                        AccountSettings[6] = ReadSettings.ReadString();
                                        break;
                                }
                                break;
                        }
                    }
                }
                catch (Exception ErrorMessage)
                {
                    MessageBox.Show("An unexpected error happened while loading settings:\n" + ErrorMessage + "\n\nYou are being allowed to enter this application, but not to send any e-mails until this error has been fixed (needs restarting the application)");
                }
            }
            else
            {
                Directory.CreateDirectory(FileLocation.Remove(FileLocation.Length - 1));
            }

            #endregion
        }
Example #3
0
        public static void ParseXMLFile(String file,System.Windows.Forms.ComboBox cb , String[] server)
        {
            Int32 index = 0;

            StringBuilder sb = new StringBuilder();
            sb.Append(Application.StartupPath + @"\" + file);

            XmlDocument document = new XmlDocument();

            try
            {
                document.Load(sb.ToString());
                XmlNodeReader reader = new XmlNodeReader(document);
                while (reader.Read() && index <= MAX_EMAIL_ACCOUNTS)
                {
                    if (reader.LocalName.Equals("email"))
                    {
                        String s = reader.ReadString().Trim().Replace('"', ' ');
                        cb.Items.Add(s);
                    }
                    if (reader.LocalName.Equals("smtpserver"))
                    {
                        String s = reader.ReadString().Trim().Replace('"', ' ');
                        server[index++] = s;
                    }
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                // MessageBox.Show("The XML file must be in the Start Application Directory", "Ez-Manage", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new System.IO.FileNotFoundException();
            }
            // default email address
            cb.Text = cb.Items[0].ToString();
        }
Example #4
0
        //ReadXml 完成对Proxy的读取
        //FileName 当前xml文件的存放位置////, string ProxyAddress, string ProxyPort
        //ProxyAddress 欲添加Proxy的Address
        //ProxyPort 欲添加Proxy的Port
        public void ReadXML(string FileName)
        {
            //初始化ListView
            this.lvProxy.View = View.Details;
            this.lvProxy.Columns.Clear();

            ColumnHeader columnHeader = new ColumnHeader();
            columnHeader.Text = "Address";
            columnHeader.Width = 150;
            this.lvProxy.Columns.Add(columnHeader);

            columnHeader = new ColumnHeader();
            columnHeader.Text = "Port";
            columnHeader.Width = 50;
            this.lvProxy.Columns.Add(columnHeader);

            //初始化XML文档
            XmlDocument doc = new XmlDocument();
            try
            {
                //加载XML文档
                doc.Load(FileName);

                XmlNodeList nodeList = doc.GetElementsByTagName("Connection");

                ListViewItem listItem;

                foreach (XmlNode xmlNode in nodeList)
                {
                    XmlNodeReader nodeReader = new XmlNodeReader(xmlNode);
                    listItem = new ListViewItem();
                    while (nodeReader.Read())
                    {
                        if (nodeReader.NodeType == XmlNodeType.Element && nodeReader.Name != "Connection")
                        {
                            if (nodeReader.Name.Equals("address"))
                            {
                                listItem.Text = nodeReader.ReadString();
                            }
                            else
                            {
                                listItem.SubItems.Add(nodeReader.ReadString());
                            }
                        }
                    }
                    lvProxy.Items.Add(listItem);
                }
            }
            catch
            {
                CreateXmlFile(FileName);
            }
        }