ReadString() public method

public ReadString ( ) : string
return string
示例#1
0
        internal static void LoadConfig(this DatabaseConfig config)
        {
            CheckForConfigFile();

              using (var xmlReader = new XmlTextReader(FilePath))
              {
            while (xmlReader.Read())
            {
              if (xmlReader.NodeType == XmlNodeType.Element)
              {
            switch (xmlReader.Name)
            {
              case "ConnectionString":
                config.ConnectionString = xmlReader.ReadString();
                break;
              case "DatabaseEngine":
                xmlReader.MoveToContent();
                ServiceLocator.DatabaseEngine value;
                Enum.TryParse(xmlReader.ReadString(), out value);
                config.DatabaseEngine = value;
                break;
            }
              }
            }
              }
        }
 public static SensorData ReadSensorData(string soap) {
      SensorData sd;
      XmlTextReader xmread;
      sd = null;
      try {
           sd = new SensorData();
           using (System.IO.StringReader read = new System.IO.StringReader(soap)) {
                xmread = new XmlTextReader(read);
                xmread.ReadStartElement("SensorDataContainer");
                xmread.ReadStartElement("Sensor");
                xmread.ReadStartElement("HasMotion");
                sd.HasMotion = bool.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("NodeId");
                sd.NodeId = int.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("PowerLevel");
                sd.PowerLevel = int.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("TimeStamp");
                sd.TimeStamp = DateTime.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadEndElement();
                xmread.ReadEndElement();
           }
      } catch (Exception) {
           throw;
      }
      return (sd);
 }
示例#3
0
文件: HoTro.cs 项目: hamalawy/ssmp
 public HoTro()
 {
     try
     {
         string TepCauHinh = Application.StartupPath + "\\cauhinh.xml";
         XmlTextReader rd = new XmlTextReader(TepCauHinh);
         while (rd.Read())
             if (rd.NodeType == XmlNodeType.Element)
             {
                 if (rd.LocalName.Equals("TenMayChu"))
                     TenMayChu = rd.ReadString();
                 if (rd.LocalName.Equals("TenCoSoDuLieu"))
                     TenCoSoDuLieu = rd.ReadString();
                 if (rd.LocalName.Equals("TenDangNhap"))
                     TenDangNhap = rd.ReadString();
                 if (rd.LocalName.Equals("MatKhau"))
                     MatKhau = rd.ReadString();
             }
         if (rd != null) rd.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#4
0
        public static void getVars()
        {
            //System.Web.HttpContext.Current.Server.MapPath("../Persist/DATASOURCE.xml");

            XmlTextReader reader = new XmlTextReader(System.Web.HttpContext.Current.Server.MapPath("../Persist/DATASOURCE.xml"));

            reader.Read();

            while (reader.Read())
            {
                if (reader.Name == "Server")
                {
                    server = reader.ReadString();
                }

                if (reader.Name == "Database")
                {
                    Database = reader.ReadString();
                }

                if (reader.Name == "User")
                {
                    User = reader.ReadString();
                }

                if (reader.Name == "Password")
                {
                    Password = reader.ReadString();
                }
            }
        }
 public string SettingsRead(string name)
 {
     XmlTextReader xmlRead = new XmlTextReader(AppDomain.CurrentDomain.BaseDirectory + "\\inc\\settings.xml");
     try
     {
         while (xmlRead.Read())
         {
             if (xmlRead.NodeType == XmlNodeType.Element)
             {
                 switch (xmlRead.Name)
                 {
                     case "server":
                         server = xmlRead.ReadString();
                         break;
                     case "cache":
                         cache = xmlRead.ReadString();
                         break;
                 }
             }
         }
         xmlRead.Close();
     }
     catch (Exception ex)
     {
         Console.WriteLine("XML Error: " + ex.Message);
     }
     if (name == "server") return server;
     else return cache;
 }
示例#6
0
        /// <summary>
        /// Leser navn og beskrivelser av funksjonen og alle dens variable, fra en C# xml fil.
        /// Dobbelarrayen har to kolonner. Første kolonne er navn, mens andre kolonne er beskrivelser. Rad en inneholder info om funksjonen, mens resten av radene er info om variablene.
        /// </summary>
        /// <param name="funkNavn">Navnet på funksjonen man vil ha info om.</param>
        /// <param name="fil">Full path med filnavn til xml filen.</param>
        /// <returns>Dobbelarrayen har to kolonner. Første kolonne er navn, mens andre kolonne er beskrivelser. Rad en inneholder info om funksjonen, mens resten av radene er info om variablene.</returns>
        public static string[,] XmlLesVarBeskFraFunk(string funkNavn, string fil)
        {
            Xml.XmlTextReader rd = new Xml.XmlTextReader(fil);
            System.Collections.Generic.List <string> funkVarBeskLi = new System.Collections.Generic.List <string>();
            System.Collections.Generic.List <string> funkVarNavnLi = new System.Collections.Generic.List <string>();
            bool   iFunk = false;
            string reg   = "([.]" + funkNavn + "+([(]))"; //matcher punktum, etterfulgt av funksjonsnavnet, etterfulgt av parentesstart.

            while (rd.Read())
            {
                if (rd.Name == "member")
                { //Funksjonsnavn
                    if (iFunk)
                    {
                        break;        //Ferdig med funksjonen.
                    }
                    string attr = "";
                    for (int j = 0; j < rd.AttributeCount; j++)
                    {
                        attr = rd.GetAttribute(0);                                         //Hvis jeg ikke har med for-løkken, så får jeg en feilmelding.
                    }
                    if (RegExp.Regex.Match(attr, reg).Success)
                    {
                        iFunk = true;
                        funkVarNavnLi.Add(funkNavn);
                    }
                }
                else if (iFunk && rd.Name == "param")
                { //Variabelnavn og beskrivelse
                    funkVarNavnLi.Add(rd.GetAttribute(0).Trim());
                    funkVarBeskLi.Add(rd.ReadString().Trim());
                }
                else if (iFunk && rd.Name == "summary")
                { //Funksjonsbeskrivelse
                    string        attr       = rd.ReadString();
                    Parser.Parser p          = new Parser.Parser(attr);
                    string[]      funkBeskLi = p.ReadStrings('\n'); //Kvitter meg med whitespace etter linjeskift.
                    attr = "";
                    foreach (string s in funkBeskLi)
                    {
                        attr += s.Trim() + " ";                              //Erstatter linjeskift+whitespace med et mellomrom. Kan alternativt erstatte det med et linjeskift uten whitespace.
                    }
                    funkVarBeskLi.Add(attr.Trim());
                }
            }
            rd.Close();
            if (!iFunk)
            {
                Console.WriteLine("Fant ikke funksjonen " + funkVarNavnLi[0] + " i xmlfilen.");
                return(null);
            }
            string[,] funkVarNavnBeskLi = new string[funkVarBeskLi.Count, 2];
            for (int i = 0; i < funkVarNavnBeskLi.GetLength(0); i++)
            {
                funkVarNavnBeskLi[i, 0] = funkVarNavnLi[i];
                funkVarNavnBeskLi[i, 1] = funkVarBeskLi[i];
            }
            return(funkVarNavnBeskLi);
        }
示例#7
0
        public TriviaServer(int port)
        {
            IPAddress ipAddress = Dns.Resolve(Dns.GetHostName()).AddressList[0];
            this.port = port;

            this.connector = new TCPIPconnectorServer(port, ipAddress);

            this.dbConnected = true;

            string login = "";
            string password = "";
            string dbName = "";
            XmlTextReader reader;
            try
            {
                reader = new XmlTextReader("config.xml");
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        if (reader.Name == "login")
                        {
                            login = reader.ReadString();
                        }

                        if (reader.Name == "password")
                        {
                            password = reader.ReadString();
                        }

                        if (reader.Name == "dbName")
                        {
                            dbName = reader.ReadString();
                        }
                    }
                }
                reader.Close();
            }
            catch (Exception e)
            {
                Logging.LogEvent("Constructor|XmlTextReader", e.Message);
            }

            try
            {
                this.DBConnector = new DatabaseConnector("localhost", login, password, dbName);
                TriviaServer.answerID = this.DBConnector.GetNumberOfUserAnswer() + 1;
            }
            catch (Exception e)
            {
                Logging.LogEvent("Constructor|DatabaseConnector", e.Message + " " + login + " " + password + " " + dbName);
                this.dbConnected = false;
            }

            this.userList = new List<User>();
            this.userThread = new List<Thread>();

            this.mutex = new ManualResetEvent(true);
        }
示例#8
0
        public DataTable readXML(string qID, string xmlPath)
        {
            DataTable dt = new DataTable();
            string quest = "";
            string part = "";
            dt.Columns.Add("name");
            dt.Columns.Add("id");
            try
            {
                XmlTextReader reader = new XmlTextReader(xmlPath);
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                        case "question":

                            if (reader.AttributeCount > 0 && qID.ToUpper() == reader.GetAttribute("value").ToUpper())//OM DETR FINN 
                            {
                                part = reader.GetAttribute("part").ToUpper();
                            }
                            else
                            {
                                reader.Skip();
                            }
                            break;
                        case "txt":
                            quest = reader.ReadString(); //Frågan sparas till en string behöver ha en tupple
                            break;
                        case "qone": 
                            dt.Rows.Add();//Nedan är svarsalternativen 
                            dt.Rows[dt.Rows.Count - 1]["id"] = reader.GetAttribute("id").ToUpper();
                            dt.Rows[dt.Rows.Count - 1]["name"] = reader.ReadString();
                            break;
                        case "qtwo":
                            dt.Rows.Add();
                            dt.Rows[dt.Rows.Count - 1]["id"] = reader.GetAttribute("id").ToUpper();
                            dt.Rows[dt.Rows.Count - 1]["name"] = reader.ReadString();                           
                            break;
                        case "qthree":
                            dt.Rows.Add();
                            dt.Rows[dt.Rows.Count - 1]["id"] = reader.GetAttribute("id").ToUpper();
                            dt.Rows[dt.Rows.Count - 1]["name"] = reader.ReadString();                           
                            break;
                        case "qfour":
                            dt.Rows.Add();
                            dt.Rows[dt.Rows.Count - 1]["id"] = reader.GetAttribute("id").ToUpper();
                            dt.Rows[dt.Rows.Count - 1]["name"] = reader.ReadString();                            
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                return null;
            }
            return dt;
        }
示例#9
0
        /// <summary>
        /// Read the specified xml and uri.
        /// </summary>
        /// <description>XML is the raw Note XML for each note in the system.</description>
        /// <description>uri is in the format of //tomboy:NoteHash</description>
        /// <param name='xml'>
        /// Xml.
        /// </param>
        /// <param name='uri'>
        /// URI.
        /// </param>
        public static Note Read(XmlTextReader xml, string uri)
        {
            Note note = new Note (uri);
            DateTime date;
            int num;
            string version = String.Empty;

            while (xml.Read ()) {
                switch (xml.NodeType) {
                case XmlNodeType.Element:
                    switch (xml.Name) {
                    case "note":
                        version = xml.GetAttribute ("version");
                        break;
                    case "title":
                        note.Title = xml.ReadString ();
                        break;
                    case "text":
                        // <text> is just a wrapper around <note-content>
                        // NOTE: Use .text here to avoid triggering a save.
                        note.Text = xml.ReadInnerXml ();
                        break;
                    case "last-change-date":
                        if (DateTime.TryParse (xml.ReadString (), out date))
                            note.ChangeDate = date;
                        else
                            note.ChangeDate = DateTime.Now;
                        break;
                    case "last-metadata-change-date":
                        if (DateTime.TryParse (xml.ReadString (), out date))
                            note.MetadataChangeDate = date;
                        else
                            note.MetadataChangeDate = DateTime.Now;
                        break;
                    case "create-date":
                        if (DateTime.TryParse (xml.ReadString (), out date))
                            note.CreateDate = date;
                        else
                            note.CreateDate = DateTime.Now;
                        break;
                    case "x":
                        if (int.TryParse (xml.ReadString (), out num))
                            note.X = num;
                        break;
                    case "y":
                        if (int.TryParse (xml.ReadString (), out num))
                            note.Y = num;
                        break;
                    }
                    break;
                }
            }

            return note;
        }
示例#10
0
文件: tools.cs 项目: dddns/dddns
        public static void GetXMLSettings()
        {
            string xmlfile = @"settings.xml";
            int xmlfound = 0;

            try
            {
                XmlTextReader reader = new XmlTextReader(AppDomain.CurrentDomain.BaseDirectory + @"\\" + xmlfile);
                while (reader.Read())
                {
                    string n = reader.Name;
                    xmlfound = 1;
                    switch (n)
                    {
                        // logtofile should be the first to be read from the xml
                        // because if it is !=1 we should not log to file
                        case "logtofile":
                            tools.logtofile = reader.ReadString();
                            WriteErrorLog("logtofile ok");
                            break;
                        // logtoeventviewer should be second to load
                        case "logtoeventviewer":
                            tools.logtoEV = reader.ReadString();
                            WriteErrorLog("logtoEV ok");
                            break;
                        case "hash":
                            tools.hash = reader.ReadString();
                            WriteErrorLog("hash ok");
                            break;
                        case "updateinterval":
                            tools.updateinterval = Convert.ToInt32(reader.ReadString());
                            WriteErrorLog("updateinterval ok");
                            break;
                        case "serverurl":
                            tools.serverurl = reader.ReadString();
                            WriteErrorLog("serverurl ok");
                            break;
                        case "publicip":
                            tools.publicip = reader.ReadString();
                            WriteErrorLog("publicip ok");
                            break;
                    }
                }
            }
            catch (Exception exp)
            {
                tools.hash = "";
                WriteErrorLog("XML: " + exp.Message);
            }
            if (0 == xmlfound)
            {
                System.Diagnostics.EventLog.WriteEntry("DecimalDNSService", "ERROR! hash not found.", EventLogEntryType.Error, 19289);
                WriteErrorLog("Error in settings.xml.");
            }
        }
示例#11
0
        private void Conectar()
        {
            Connected = false;
            try
            {
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader("c:\\Terminal.xml");
                IDTerminal = 0;
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                    case "Mensaje":
                        IDTerminal = Convert.ToInt16(reader.ReadString());
                        break;

                    case "IP":
                        IP = reader.ReadString();
                        break;

                    case "PUERTO":
                        Port = Convert.ToInt32(reader.ReadString());
                        break;
                    }
                }
                msj                = new Mensaje();
                Cliente            = new TcpClient(this.IP, this.Port);
                StreamCliente      = Cliente.GetStream();
                msj.NombreTerminal = "Terminal";
                msj.Prioridad      = IDTerminal;
                msj.op             = 4;
                Send s = Send.GetSend();
                s.StreamCliente = this.StreamCliente;
                s.Cliente       = this.Cliente;
                s.EnviarMensaje(serial.SerializarObj(msj));
                Connected = true;
                this.Hilo = new Thread(SubProceso);
                this.Hilo.IsBackground = true;
                this.Hilo.Start();
            }
            catch
            {
                DialogResult dialogResult = MessageBox.Show("Error 100 - Sin conexion al servidor ¿Intentar Reconectar?", "Sin conexion a el servidor", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    Conectar();
                }
                else if (dialogResult == DialogResult.No)
                {
                    Connected = false;
                    Application.Exit();
                }
            }
        }
示例#12
0
        /// <summary>
        /// Loads the chest bonus descriptions from the given XML
        /// file and sets up the internal structures.
        /// </summary>
        static ChestBonusInfo()
        {
            try
            {
                // Get the manifest string
                Stream stream = typeof(ChestBonusInfo).Assembly
                    .GetManifestResourceStream("CuteGod.bonuses.xml");

                // Create an XML reader out of it
                XmlTextReader xml = new XmlTextReader(stream);
                ChestBonusInfo sp = null;
                ChestBonusType type = ChestBonusType.Maximum;

                // Loop through the file
                while (xml.Read())
                {
                    // See if we finished a node
                    if (xml.NodeType == XmlNodeType.EndElement &&
                        xml.LocalName == "bonus")
                    {
                        hash[type] = sp;
                        sp = null;
                    }

                    // Ignore all but start elements
                    if (xml.NodeType != XmlNodeType.Element)
                        continue;

                    // Check for name
                    if (xml.LocalName == "bonus")
                    {
                        sp = new ChestBonusInfo();
                        type = (ChestBonusType) Enum
                            .Parse(typeof(ChestBonusType), xml["type"]);
                        sp.type = type;
                    }
                    else if (xml.LocalName == "title")
                        sp.Title = xml.ReadString();
                    else if (xml.LocalName == "block")
                        sp.BlockKey = xml.ReadString();
                    else if (xml.LocalName == "description")
                        sp.Description = xml.ReadString();
                }
            }
            catch (Exception e)
            {
                Logger.Error(typeof(ChestBonusInfo),
                    "Cannot load penalties: {0}", e.Message);
                throw e;
            }
        }
示例#13
0
        private void IniciarServidor()
        {
            int    Port = 0;
            string IP   = "";

            try
            {
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader("c:\\Servidor.xml");
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                    case "IP":
                        IP = reader.ReadString();
                        break;

                    case "PUERTO":
                        Port = Convert.ToInt32(reader.ReadString());
                        break;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Error al cargar configuracion de conexion");
            }
            try
            {
                IPEndPoint ipend = new IPEndPoint(IPAddress.Parse(IP), Port);
                Server = new TcpListener(ipend);
                Server.Start();
            }
            catch
            {
                DialogResult dialogResult = MessageBox.Show("Error al iniciar servidor ¿Intentar denuevo?", "Alerta", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    IniciarServidor();
                }
                else if (dialogResult == DialogResult.No)
                {
                    Application.Exit();
                }
            }
            hs = new Hashtable();
            datos.setTerminales(hs);
            this.Hilo = new Thread(ServerStart);
            this.Hilo.IsBackground = true;
            this.Hilo.Start();
            datos.Online = true;
        }
示例#14
0
 public void LoadData(String filename)
 {
     if (File.Exists(filename))
     {
         XmlTextReader reader = new XmlTextReader(filename);
         while (reader.Read())
         {
             switch (reader.NodeType)
             {
                 case XmlNodeType.Element:
                     {
                         switch (reader.Name)
                         {
                             case "TrackerAddress":
                                 {
                                     this.TrackerAddress = reader.ReadString();
                                     break;
                                 }
                             case "MaxTimeout":
                                 {
                                     this.MaxTimeout = Int32.Parse(reader.ReadString());
                                     break;
                                 }
                             case "Port":
                                 {
                                     this.Port = Int32.Parse(reader.ReadString());
                                     break;
                                 }
                             case "ListenPort":
                                 {
                                     this.ListenPort = Int32.Parse(reader.ReadString());
                                     break;
                                 }
                         }
                         break;
                     }
             }
         }
         reader.Close();
     }
     else
     {
         // default this
         this.TrackerAddress = "127.0.0.1";
         this.MaxTimeout = 30000;
         this.Port = 9351;
         this.ListenPort = 9757;
         this.SaveData(filename);
     }
 }
示例#15
0
        public static NamingRules LoadRules(string xmlPath)
        {
            NamingRules namingRules = new NamingRules();
            namingRules.rules = new List<NamingRule>();

            using (XmlReader reader = new XmlTextReader(xmlPath))
            {
                reader.ReadStartElement("Rules");
                reader.ReadStartElement("GeneralSettings");
                
                reader.ReadStartElement("FilenameRegex");
                namingRules.filenameRegex = reader.ReadString();
                reader.ReadEndElement();
                
                reader.ReadStartElement("ContextDepth");
                namingRules.contextDepth = reader.ReadContentAsInt();
                if (namingRules.ContextDepth < 1 || namingRules.ContextDepth > 4)
                    throw new FormatException("Context Depth must be between 1 and 4");
                reader.ReadEndElement();
                
                reader.ReadStartElement("ContextSeparator");
                namingRules.contextSeparator = reader.ReadString();
                reader.ReadEndElement();
                
                reader.ReadEndElement();
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        System.Diagnostics.Debug.Assert(reader.Name == "Rules");
                        break;
                    }
                    //if (reader.IsStartElement())
                    //    System.Diagnostics.Debug.Assert(reader.Name == "Rule");
                    reader.ReadStartElement("Rule");
                    //reader.Read();

                    reader.ReadStartElement("SearchString");
                    string regex = reader.ReadString();
                    reader.ReadEndElement();
                    reader.ReadStartElement("Replacement");
                    string replacement = reader.ReadString();
                    reader.ReadEndElement();
                    reader.ReadEndElement();
                    namingRules.rules.Add(new NamingRule(regex, replacement));
                }
                reader.ReadEndElement();
            }
            return namingRules;
        }
示例#16
0
        /// <summary>
        /// Loads all the settings from the XML file "settings.xml" which is in the same directory as the executable.
        /// </summary>
        public static void load()
        {
            if (File.Exists("settings.xml"))
            {
                string text = File.ReadAllText("settings.xml");
                XMLChecker checker = new XMLChecker();


                if (checker.checkSafe(text))        //If we're good to go
                {
                    XmlTextReader reader = new XmlTextReader(new StringReader(text));

                    while (reader.Read())       //Parse the settings
                    {
                        if (reader.Name == "notifications")        //Gets the value for notify
                        {
                            bool result;
                            if (Boolean.TryParse(reader.ReadString(), out result))
                            {
                                notify = result;
                            }
                            else      //It isn't a boolean so we just default it, but let the user know
                            {
                                MessageBox.Show("Notification value is non-boolean, defaulted to true.", "Error", MessageBoxButtons.OK);
                                notify = true;
                            }
                        }

                        if (reader.Name == "server")        //Set the server
                        {
                            server = reader.ReadString();
                        }

                    }
                }
                else    //XML was bad, delete the file and try again (so we have a clean file)
                {
                    File.Delete("settings.xml");        
                    Setting.load();
                }

            }
            else   //No settings found, create a default file that is on the localhost for a server
            {
                server = "http://localhost/ticketSystem/webshield.php";
                notify = true;
                Setting.save();         //Create a default settings file
            }
        }
示例#17
0
        public static bool CheckNewVersionAvailable()
        {
            string versionString = "0.5";
            bool newVersion = false;
            string versionFile = "http://www.worxpace.de/uih/version.xml";

            WebRequest requestVersionFile = WebRequest.Create(versionFile);
            WebResponse responseVersionFile = requestVersionFile.GetResponse();

            StreamReader xmlInputStream = new StreamReader(responseVersionFile.GetResponseStream());

            XmlTextReader xmlReader = new XmlTextReader(xmlInputStream);
            while (xmlReader.Read())
            {
                switch (xmlReader.Name)
                {
                    case "fileVersion":
                        Version actualVersion = new Version(versionString);
                        Version currentVersion = new Version(xmlReader.ReadString());
                        if (currentVersion <= actualVersion)
                        {
                            newVersion = false;
                        }
                        else
                        {
                            newVersion = true;
                        }
                        break;
                }
            }
            return newVersion;
        }
示例#18
0
文件: Credit.cs 项目: chaipokoi/Ocalm
		public override void draw (SpriteBatch par1)
		{
			Stream file = TitleContainer.OpenStream ("Credits.xml");
			XmlTextReader xml = new XmlTextReader (file);
			int y = 130;
			while (xml.Read ()) {
				bool writable = false;
				float size = 1F;
				int x = 50;
				int _y = 0;
				Color color = Color.Blue;
				if (xml.Name == "title") {
					writable = true;
					size = 1F;
					x = 60;
					color = Color.White;
					_y = 30;
				}
				else if(xml.Name=="people")
				{
					writable = true;
					size = 0.6F;
					x = 90;
					color = Color.LightGray;
					_y = 25;
				}
				if (writable) {
					Core.drawText (par1, xml.ReadString(), x, y, size, color);
					y += _y;
				}

			}
			Core.drawText (par1, ">", (int)(canvas.X / 2 + 170), (int)( + 220), 1F, Color.SlateGray);
			Core.drawText (par1, "<", (int)(+ 30), (int)( + 220), 1F, Color.SlateGray);
		}
示例#19
0
        public bool ExtractBooleanValue(XmlTextReader reader)
        {
            bool result;

            if (ExtractBoolFromOffOnString(reader.ReadString(), out result))
            {
                return result;
            }

            if (!Boolean.TryParse(reader.ReadString(), out result))
            {
                return false;
            }

            return result;
        }
示例#20
0
        public static void loadLevel(ContentManager content, int levelID)
        {
            string gamePath = getGameDirectory(test);

            XmlTextReader reader = new XmlTextReader(gamePath + "\\Levels\\Level" + levelID + ".xml");
            while (reader.Read())
            {

                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:

                        //Console.Out.Write(reader.Name + ": " + reader.Value);//reader.ReadElementContentAsString());//WORKING HERE
                        lastElementString = reader.Name;
                        break;
                    case XmlNodeType.Text:
                        //Console.Out.WriteLine(reader.Value);
                        addVal(reader.ReadString());
                        break;
                    case XmlNodeType.EndElement:
                        buildObject(reader.Name, content);
                        break;
                    default:
                        if(reader.NodeType != XmlNodeType.Whitespace) {Console.WriteLine("Hit a weird XmlNodeType. It was of type: " + reader.NodeType);}
                        break;
                }
            }
        }
示例#21
0
        public String[] GetVersion(List<String> application)
        {
            String[] versionList = new String[5];
            String URLString = "http://www.gamerzzheaven.be/applications.xml";
            
            XmlTextReader reader = new XmlTextReader(URLString);

            while (reader.Read())
            {
                if (reader.NodeType.Equals(XmlNodeType.Element))
                {
                    if (reader.Name.Equals("Application"))
                    {
                        while (reader.MoveToNextAttribute()) // Read the attributes.
                            if (reader.Name == "name")
                            {
                                if (reader.Value.Equals("x264")) //change the z264 string value to the enum once tested
                                {
                                    reader.Read();
                                    if(reader.Name.Equals("Version"))
                                    {
                                        versionList[0] = reader.ReadString();
                                    }
                                }
                            }
                    }
                }
            }
            return versionList; //return curerent application version
        }
示例#22
0
文件: XMLWR.cs 项目: qq5013/Medical
 //通过name获取对应节点的值
 public string getValueByName(string FileName,string name)
 {
     string value = "0";
     XmlTextReader reader = null;
     try
     {
         reader = new XmlTextReader(FileName);
         while (reader.Read())
         {
             if (reader.LocalName.Equals(name))
             {
                 value = reader.ReadString();
                 break;
             }
         }
     }
     catch (Exception exp)
     {
         return value;
     }
     finally
     {
         reader.Close();
     }
     return value;
 }
        public List<Article> MakeList(params string[] searchCriteria)
        {
            List<Article> articles = new List<Article>();

            // TODO: must support other wikis
            if (Variables.Project != ProjectEnum.wikipedia || Variables.LangCode != LangCodeEnum.en)
            {
                MessageBox.Show("This plugin currently supports only English Wikipedia",
                    "TypoScan", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return articles;
            }

            for (int i = 0; i < Iterations; i++)
            {
                using (
                    XmlTextReader reader =
                        new XmlTextReader(new StringReader(Tools.GetHTML(Common.GetUrlFor("displayarticles")))))
                {
                    while (reader.Read())
                    {
                        if (reader.Name.Equals("article"))
                        {
                            reader.MoveToAttribute("id");
                            int id = int.Parse(reader.Value);
                            string title = reader.ReadString();
                            articles.Add(new Article(title));
                            if (!TypoScanAWBPlugin.PageList.ContainsKey(title))
                                TypoScanAWBPlugin.PageList.Add(title, id);
                        }
                    }
                }
            }
            TypoScanAWBPlugin.CheckoutTime = DateTime.Now;
            return articles;
        }
示例#24
0
文件: Program.cs 项目: jdaley/GotToGo
        static List<Toilet> LoadFromXml()
        {
            List<Toilet> list = new List<Toilet>();

            using (XmlTextReader reader =
                new XmlTextReader(@"C:\Users\Joe\GovHack2013\Toiletmap\ToiletmapExport.xml"))
            {
                Toilet toilet = null;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "ToiletDetails" &&
                        !reader.IsEmptyElement)
                    {
                        toilet = new Toilet()
                        {
                            Lat = decimal.Parse(reader.GetAttribute("Latitude")),
                            Lng = decimal.Parse(reader.GetAttribute("Longitude"))
                        };
                    }
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "Name")
                    {
                        toilet.Name = reader.ReadString();
                    }
                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "ToiletDetails")
                    {
                        list.Add(toilet);
                        toilet = null;
                    }
                }
            }

            return list;
        }
示例#25
0
        private string procesarFicheroXml(StreamReader sr)
        {
            Vento medida;
            string fichero = "";

            XmlTextReader lectorXml = new XmlTextReader(sr);

            while (lectorXml.Read())
            {

                string v = lectorXml.Name;
                string x = lectorXml.Value;

                if (lectorXml.NodeType == XmlNodeType.Element)
                {
                    switch (lectorXml.Name)
                    {
                        case "Valores Data": medida = new Vento(); ; break;
                        case "Medida": c.Nombre = lectorXml.ReadString(); break;
                       
                    }
                }

            }
            lectorXml.Close();

            return fichero;
        }
        public List<Article> MakeList(params string[] searchCriteria)
        {
            List<Article> articles = new List<Article>();

            using (
                XmlTextReader reader =
                    new XmlTextReader(new StringReader(Tools.GetHTML(Common.GetUrlFor("displayarticles") + "&count=" + Count))))
            {
                while (reader.Read())
                {
                    if (reader.Name.Equals("site"))
                    {
                        reader.MoveToAttribute("address");
                        string site = reader.Value;

                        if (site != Common.GetSite())
                            //Probably shouldnt get this as the wanted site was sent to the server
                        {
                            MessageBox.Show("Wrong Site");
                        }
                    }
                    else if (reader.Name.Equals("article"))
                    {
                        reader.MoveToAttribute("id");
                        int id = int.Parse(reader.Value);
                        string title = reader.ReadString();
                        articles.Add(new Article(title));
                        if (!TypoScanBasePlugin.PageList.ContainsKey(title))
                            TypoScanBasePlugin.PageList.Add(title, id);
                    }
                }
            }
            TypoScanBasePlugin.CheckoutTime = DateTime.Now;
            return articles;
        }
示例#27
0
        private void check()
        {
            // Assembly取得
            Assembly asm = Assembly.GetExecutingAssembly();
            Version ver = asm.GetName().Version;

            // label2にバージョン表示
            label2.Text = ver.ToString();

            try
            {
                // xmlを外部から読み込み
                XmlTextReader reader = new XmlTextReader("http://files.iesaba.com/update/kankore.xml");

                // XMLファイルを1ノードずつ読み込む
                // *memo <tag>value</tag>の形式で
                while (reader.Read())
                {
                    reader.MoveToContent();
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.LocalName.Equals("version"))
                        {
                            // バージョンを追加
                            label4.Text = reader.ReadString();
                        }
                        if (reader.LocalName.Equals("date"))
                        {
                            // 日時を追加
                            NewsText.Text = "最終更新日時: " + reader.ReadString();
                        }
                        if (reader.LocalName.Equals("text"))
                        {
                            // 本文を追加
                            // *memo 改行はXML側でacceptsreturn="True"にした上でコード内でリプレースする
                            string line = reader.ReadString().Replace("\n", "\r\n");
                            NewsText.AppendText("\r\n\r\n更新内容: " + line);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("例外が発生しました。\n" + e, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
        }
        public List<Article> MakeList(params string[] searchCriteria)
        {
            List<Article> articles = new List<Article>();

            foreach (string s in searchCriteria)
            {
                int start = 0;
                do
                {
                    string url = string.Format(BaseUrl, s, Variables.URL, NoOfResultsPerRequest, start);

                    using (XmlTextReader reader = new XmlTextReader(new StringReader(Tools.GetHTML(url))))
                    {
                        while (reader.Read())
                        {
                            if (reader.Name.Equals("Error"))
                            {
                                reader.ReadToFollowing("Code");
                                if (string.Compare(reader.ReadString(), "2002", true) == 0)
                                    Tools.MessageBox("Query limit for Bing Exceeded. Please try again later");

                                return articles;
                            }

                            if (reader.Name.Equals("web:Total"))
                            {
                                if (int.Parse(reader.ReadString()) > TotalResults)
                                    start += NoOfResultsPerRequest;
                            }

                            if (reader.Name.Equals("web:Url"))
                            {
                                string title = Tools.GetTitleFromURL(reader.ReadString());

                                if (!string.IsNullOrEmpty(title))
                                    articles.Add(new Article(title));
                            }
                        }
                    }
                } while (articles.Count < TotalResults);
            }

            return articles;
        }
示例#29
0
文件: XML.cs 项目: Raumo0/Labs
 public static Faculty.Faculty LoadFacultyFromXML(FileStream stream)
 {
     try
     {
         var reader = new XmlTextReader(stream);
         string name = string.Empty;
         var path = string.Empty;
         while (reader.Read())
         {
             switch (reader.Name)
             {
                 case "name":
                     name = reader.ReadString();
                     break;
                 case "groups":
                     if (reader.AttributeCount >= 1)
                         path = reader.GetAttribute("path");
                     break;
             }
         }
         var faculty = new Faculty.Faculty(name);
         if (!string.IsNullOrWhiteSpace(path))
         {
             var dir = new DirectoryInfo(path);
             var files = dir.GetFiles(@"*.xml");
             foreach (var file in files)
             {
                 var intream = file.Open(FileMode.Open);
                 LoadGroupFromXML(intream, faculty);
                 intream.Close();
             }
         }
         return faculty;
     }
     catch (ArgumentNullException exception)
     {
         throw new ArgumentNullException(exception.Source);
     }
     catch (XmlException exception)
     {
         throw new XmlException(exception.Source);
     }
     catch (InvalidOperationException exception)
     {
         throw new InvalidOperationException(exception.Source);
     }
     catch (FileNotFoundException exception)
     {
         throw new FileNotFoundException(exception.Source);
     }
     catch (DirectoryNotFoundException exception)
     {
         throw new DirectoryNotFoundException(exception.Source);
     }
 }
 void Load(string fileName)
 {
     // chargement des valeurs des options depuis le fichier Config.xml
     try
     {
         using (XmlTextReader reader = new XmlTextReader(fileName))
         {
             reader.ReadStartElement("Config");
             do
             {
                 if (!reader.IsStartElement()) continue;
                 string value = reader.ReadString();
                 switch (reader.Name)
                 {
                     case "VLCPath": VLCPath = value; break;
                     case "DVDLetter": DVDLetter = value; break;
                     case "VlcPort": VlcPort = value; break;
                     case "SoundExts": SoundExts = value; break;
                     case "PictureExts": PictureExts = value; break;
                     case "VideoExts": VideoExts = value; break;
                     case "AudioLanguage": AudioLanguage = value; break;
                     case "SubLanguage": SubLanguage = value; break;
                     case "ShowVLC": ShowVLC = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "Transcode":
                         switch (value.ToUpper())
                         {
                             case "MPGA": TranscodeAudio = AudioTranscode.MPGA; break;
                             case "A52": TranscodeAudio = AudioTranscode.A52; break;
                             case "PC": TranscodeAudio = AudioTranscode.PC; break;
                             default: TranscodeAudio = AudioTranscode.None; break;
                         }
                         break;
                     case "StartMinimized": StartMinimized = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "MinimizeToTray": MinimizeToTray = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "FFMpegInterlace": FFMpegInterlace = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "HalfScale": HalfScale = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "LIRCActive": LIRCActive = (value == "1") || (value == System.Boolean.TrueString); break;
                     case "TranscodeVB": TranscodeVB = value; break;
                     case "PCControlAllowed": PCControlAllowed = Convert.ToBoolean(value); break;
                     case "LessIconsInExplorer": LessIconsInExplorer = Convert.ToBoolean(value); break;
                     case "BlackBkgnds": BlackBkgnds = Convert.ToBoolean(value); break;
                     case "TranscodeVideo":
                         switch (value.ToUpper())
                         {
                             case "MPG2": TranscodeVideo = VideoTranscode.MPG2; break;
                             default: TranscodeVideo = VideoTranscode.None; break;
                         }
                         break;
                 }
             } while (reader.Read());
         }
     }
     catch (FileNotFoundException) { }
 }
 /// <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();
     }
 }
        /// <summary>
        /// get theme manifest from xml file
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static JsonPackage GetThemeManifest(string id)
        {
            var jp = new JsonPackage { Id = id };
            var themeUrl = string.Format("{0}themes/{1}/theme.xml", Utils.ApplicationRelativeWebRoot, id);
            var themePath = HttpContext.Current.Server.MapPath(themeUrl);
            try
            {
                if(File.Exists(themePath))
                {
                    var textReader = new XmlTextReader(themePath);
                    textReader.Read();

                    while (textReader.Read())
                    {
                        textReader.MoveToElement();

                        if (textReader.Name == "description")
                            jp.Description = textReader.ReadString();

                        if (textReader.Name == "authors")
                            jp.Authors = textReader.ReadString();

                        if (textReader.Name == "website")
                            jp.Website = textReader.ReadString();

                        if (textReader.Name == "version")
                            jp.Version = textReader.ReadString();

                        if (textReader.Name == "iconurl")
                            jp.IconUrl = textReader.ReadString();
                    }
                    return jp;
                }
            }
            catch (Exception ex)
            {
                Utils.Log("Packaging.FileSystem.GetThemeManifest", ex);
            }
            return null;
        }
示例#33
0
        private string procesarFicheroXml(StreamReader sr)
        {
            Vento medida = new Vento();

            string fichero = "";

            XmlTextReader lectorXml = new XmlTextReader(sr);

            while (lectorXml.Read())
            {

                string v = lectorXml.Name;
                string x = lectorXml.Value;

                if (lectorXml.NodeType == XmlNodeType.Element)
                {
                    switch (lectorXml.Name)
                    {
                        case "Contacto": c = new Contacto(); ; break;
                        case "nombre": c.Nombre = lectorXml.ReadString(); break;
                        case "apellido": c.Apellido = lectorXml.ReadString(); ; break;
                        case "direccion": c.Direccion = lectorXml.ReadString(); break;
                        case "telcasa": c.TlfnoCasa = lectorXml.ReadString(); break;
                        case "telmovil": c.TlfnoMovil = lectorXml.ReadString(); break;
                        case "teltrabajo": c.TlfnoTrabajo = lectorXml.ReadString(); agenda.Add(c); break;
                    }
                }

            }
            lectorXml.Close();

            return fichero;
        }
示例#34
0
        /// <summary>
        /// Finner alle funksjoner som en bestemt variabel inngår i, og variabelens tilhørende beskrivelse. Hentes fra en C# xml fil.
        /// Dobbelarrayen har to kolonner. Første kolonne er funksjonsnavn, mens andre kolonne er variabelbeskrivelsen for hver funksjon.
        /// </summary>
        /// <param name="varNavn">Navnet på variabelen man vil ha info om.</param>
        /// <param name="fil">Full path med filnavn til xml filen.</param>
        /// <returns>Dobbelarrayen har to kolonner. Første kolonne er funksjonsnavn, mens andre kolonne er variabelbeskrivelsen for hver funksjon.</returns>
        public static string[,] XmlLesFunkNavnVarBeskFraVar(string varNavn, string fil)
        {
            Xml.XmlTextReader rd = new Xml.XmlTextReader(fil);
            System.Collections.Generic.List <string> varBeskLi  = new System.Collections.Generic.List <string>();
            System.Collections.Generic.List <string> funkNavnLi = new System.Collections.Generic.List <string>();
            string reg = "([.]\\w+([(]))"; //matcher punktum, etterfulgt av et ord, etterfulgt av parentesstart.

            while (rd.Read())
            {
                if (rd.Name == "member")
                { //Funksjonsnavn
                    string attr = "";
                    for (int j = 0; j < rd.AttributeCount; j++)
                    {
                        attr = rd.GetAttribute(0);                                         //Hvis jeg ikke har med for-løkken, så får jeg en feilmelding.
                    }
                    RegExp.Match m = RegExp.Regex.Match(attr, reg);
                    if (m.Success)
                    {
                        attr = m.ToString();
                        funkNavnLi.Add(attr.Remove(attr.Length - 1).Remove(0, 1)); //Fjerner punktum og parentes
                    }
                }
                else if (rd.Name == "param")
                { //Variabelbeskrivelse
                    string attr = "";
                    if (rd.AttributeCount > 0)
                    {
                        attr = rd.GetAttribute(0).Trim();                        //Det hender at rd ikke har noen attributes.
                    }
                    if (attr == varNavn)
                    {
                        varBeskLi.Add(rd.ReadString().Trim());
                    }
                }
            }
            rd.Close();
            if (string.IsNullOrEmpty(funkNavnLi[0]))
            {
                Console.WriteLine("Fant ikke variabelen " + varNavn + " i xmlfilen.");
                return(null);
            }
            string[,] funkNavnVarBeskLi = new string[funkNavnLi.Count, 2];
            for (int i = 0; i < funkNavnVarBeskLi.GetLength(0); i++)
            {
                funkNavnVarBeskLi[i, 0] = funkNavnLi[i];
                funkNavnVarBeskLi[i, 1] = varBeskLi[i];
            }
            return(funkNavnVarBeskLi);
        }
示例#35
0
        /// <summary>
        /// Read config from configuration file.
        /// </summary>
        /// <returns>If no errors occurred true, otherwise false.</returns>
        public Boolean readConfig()
        {
            Boolean result = true;

            try {
                XmlTextReader xtr = new System.Xml.XmlTextReader("radixpro.config");
                while (xtr.Read())
                {
                    if (xtr.NodeType == XmlNodeType.Element)
                    {
                        parseXmlTag(xtr.Name, xtr.ReadString());
                    }
                }
                xtr.Close();
            }
            catch {
                result = false;
                // todo handle exception message
            }
            return(result);
        }
示例#36
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            string XmlFile;

            System.IO.DirectoryInfo directoryInfo;
            System.IO.DirectoryInfo directoryXML;

            //Get the applications startup path
            directoryInfo = System.IO.Directory.GetParent(Application.StartupPath);

            //Set the output path
            if (directoryInfo.Name.ToString() == "bin")
            {
                directoryXML = System.IO.Directory.GetParent(directoryInfo.FullName);
                XmlFile      = directoryXML.FullName + "\\customers.xml";
            }
            else
            {
                XmlFile = directoryInfo.FullName + "\\customers.xml";
            }
            fileName.Text = XmlFile;

            //load the xml file into the XmlTextReader object.

            XmlTextReader XmlRdr = new System.Xml.XmlTextReader(XmlFile);

            //while moving through the xml document.
            while (XmlRdr.Read())
            {
                //check the node type and look for the element type
                //whose Name property is equal to name.
                if (XmlRdr.NodeType == XmlNodeType.Element && XmlRdr.Name == "name")
                {
                    XMLOutput.Text += XmlRdr.ReadString() + "\r\n";
                }
            }
        }
示例#37
0
 // Read the contents of an element or text node as a string.
 public override String ReadString()
 {
     return(reader.ReadString());
 }
示例#38
0
        //
        private bool ReadSetting()
        {
            #region 注册表
            ////throw new NotImplementedException();
            //RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("software",true);
            //RegistryKey SQpress = softwareKey.OpenSubKey("SQpress", true);
            //if (SQpress==null)
            //{
            //    return false;

            //}
            //RegistryKey selfWindowsKey = SQpress.OpenSubKey("selfWindowsKey", true);

            //if (selfWindowsKey==null)
            //{
            //    return false;

            //}
            //else
            //{
            //    listBoxMessage.Items.Add("添加注册表项成功!!!!!!!!!!!!");
            //    listBoxMessage.Items.Add(selfWindowsKey.ToString());
            //}

            //int redComponent = (int)selfWindowsKey.GetValue("Red");
            //int greenComponent = (int)selfWindowsKey.GetValue("Green");
            //int blueComponent = (int)selfWindowsKey.GetValue("Blue");
            //BackColor = Color.FromArgb(redComponent, greenComponent, blueComponent);
            //listBoxMessage.Items.Add("背景色" + BackColor.Name);

            //int X = (int)selfWindowsKey.GetValue("X");
            //int Y = (int)selfWindowsKey.GetValue("Y");
            //DesktopLocation = new Point(X, Y);

            //listBoxMessage.Items.Add("窗口位置" + DesktopLocation);
            //this.Height = (int)selfWindowsKey.GetValue("Height");
            //this.Width = (int)selfWindowsKey.GetValue("Width");
            //listBoxMessage.Items.Add("窗口大小" + new Size(X, Y));

            //string initialWindowStates = (string)selfWindowsKey.GetValue("WindowState");

            //listBoxMessage.Items.Add("窗口扎状态" + initialWindowStates);
            //this.WindowState = (FormWindowState)FormWindowState.Parse(WindowState.GetType(), initialWindowStates);

            //return true;

            #endregion

            #region ISO
            IsolatedStorageFile iso   = IsolatedStorageFile.GetUserStoreForDomain();
            string[]            files = iso.GetFileNames("SelfPlace.xml");
            foreach (string userFile in files)
            {
                if (userFile == "SelfPlace.xml")
                {
                    listBoxMessage.Items.Add("成功打开文件" + userFile);

                    StreamReader sr = new StreamReader(new IsolatedStorageFileStream("SelfPlace.xml", FileMode.OpenOrCreate, FileAccess.Read));

                    System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sr);

                    int x = 0;
                    int y = 0;

                    while (reader.Read())
                    {
                        switch (reader.Name)
                        {
                        case "X":
                            x = int.Parse(reader.ReadString());
                            break;

                        case "Y":
                            y = int.Parse(reader.ReadString());
                            break;

                        case "Width":
                            this.Width = int.Parse(reader.ReadString());
                            break;

                        case "Height":
                            this.Height = int.Parse(reader.ReadString());
                            break;

                        default:
                            break;
                        }
                    }

                    this.DesktopLocation = new Point(x, y);
                    iso.Close();
                    sr.Close();
                }
            }

            return(true);

            #endregion
        }