Close() public method

public Close ( ) : void
return void
Esempio n. 1
0
 public static SvgDocument CreateDocumentFromFile(string filename)
 {
     Stream stream1 = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
     SvgDocument document1 = new SvgDocument();
     XmlTextReader reader1 = new XmlTextReader(stream1, XmlNodeType.Document, document1.XmlParserContext);
     try
     {
         reader1.XmlResolver = null;
         document1.PreserveWhitespace = true;
         document1.XmlResolver = null;
         document1.FilePath = filename;
         document1.Load(reader1);
         //document1.DealLast();
         reader1.Close();
         stream1.Close();
         document1.FileName = Path.GetFileNameWithoutExtension(filename);
         document1.Update = true;
         return document1;
     }
     catch (Exception exception1)
     {
         reader1.Close();
         stream1.Close();
         MessageBox.Show("���Ϸ��ĵ���" + exception1.Message);
     }
     return null;
 }
Esempio n. 2
0
 public void LoadSounds()
 {
     if (File.Exists(soundsFile))
     {
         XmlTextReader textReader = null;
         try
         {
             XmlSerializer deserializer = new XmlSerializer(typeof(IceChatSounds));
             textReader = new XmlTextReader(soundsFile);
             iceChatSounds = (IceChatSounds)deserializer.Deserialize(textReader);
             textReader.Close();
         }
         catch (Exception)
         {
             textReader.Close();
             errorMessages.Add("There was a problem loading IceChatSounds.xml. Default sounds loaded");
             iceChatSounds = new IceChatSounds();
             iceChatSounds.AddDefaultSounds();
         }
     }
     else
     {
         iceChatSounds = new IceChatSounds();
         iceChatSounds.AddDefaultSounds();
     }
 }
Esempio n. 3
0
        public string getEntry(string pathToXML, string entryToLook)
        {
            XmlTextReader reader = new XmlTextReader (pathToXML);
            string tmpStr = "";

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        tmpStr = reader.Name;
                        break;
                    case XmlNodeType.Text:      /* Display the text in each element. */
                        if (tmpStr == entryToLook)
                        {
                            tmpStr = reader.Value;
                            reader.Close();
                            return tmpStr;
                        }
                        break;
                    /* No needed, just example */
                    /* case XmlNodeType.EndElement: //Display the end of the element.
                     *   Console.Write("</" + reader.Name);
                     *   Console.WriteLine(">");
                     *   break;
                     */
                }
            }
            reader.Close();
            return null;
            /* Console.ReadLine(); */
        }
Esempio n. 4
0
        private static string parseTrainFile(string filename, out string tr_num, out string tr_type)
        {
            string trainnumber = "", traintype ="", description = "", from = "";

            tr_num = trainnumber;
            tr_type = traintype;

            if (System.IO.File.Exists(filename))
            {
                XmlReader reader = new XmlTextReader(filename);
Esempio n. 5
0
        public bool parseXMLAsDelimited(string sSource,
                                        string sDest,
                                        string record_node,
                                        T_Fields[] arr_args,
                                        string filing_file = null,
                                        bool bSort         = false)
        {
            System.Collections.ArrayList filing_values = null;
            string tmpDest = System.IO.Path.GetTempFileName();

            System.IO.FileStream   xmlStream = new System.IO.FileStream(sSource, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            System.IO.StreamWriter writer    = new System.IO.StreamWriter(tmpDest, false, new System.Text.UTF8Encoding(false));
            System.Xml.XmlReader   rd        = new System.Xml.XmlTextReader(xmlStream, System.Xml.XmlNodeType.Document, null);
            string sreturn = "";

            try
            {
                while (rd.Read())
                {
                    if (rd.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        if (rd.LocalName == record_node ||
                            rd.Name == record_node)
                        {
                            sreturn = rd.ReadOuterXml();

                            writer.WriteLine(parseNode(sreturn));
                        }
                    }
                }
                if (rd != null)
                {
                    rd.Close();
                }
                if (writer != null)
                {
                    writer.Close();
                }

                return(processFile2MARC(tmpDest, sDest, arr_args, filing_file, bSort));
            }
            catch (System.Exception pp)
            {
                LastError = "Unable to process XML File.\n\nFull Exception:\n" + pp.ToString();
                if (rd != null)
                {
                    rd.Close();
                }
                if (writer != null)
                {
                    writer.Close();
                }
                return(false);
            }
        }
        public List<object> Table_GetAll()
        {
            var returnValue = new List<object>();
            try
            {
                var allTables = base.GetAllFiles(this._tableDirectoryPath);
                foreach (var table in allTables)
                {
                    var fileStream = base.GetFileReadStream(table.Value);
                    var xmlTextReader = new XmlTextReader(fileStream);

                    returnValue.Add(Serializer.Deserialize(xmlTextReader));

                    fileStream.Close();
                    fileStream.Dispose();

                    xmlTextReader.Close();
                    xmlTextReader.Dispose();
                }
            }
            catch (Exception ex)
            {
                if (this._logger != null)
                {
                    this._logger.Log(ex.Message, Category.Exception, Priority.High);
                }
            }

            return returnValue;
        }
Esempio n. 7
0
        public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode rootNode;

            if (fileName.StartsWith("http:") || File.Exists(fileName))
            {
                XmlTextReader reader = new XmlTextReader(fileName);
                reader.WhitespaceHandling = WhitespaceHandling.None;
                doc.Load(reader);
                reader.Close();
                rootNode = doc.FirstChild;
                foreach (XmlNode aPrimNode in rootNode.ChildNodes)
                {
                    SceneObjectGroup obj = SceneObjectSerializer.FromOriginalXmlFormat(aPrimNode.OuterXml);

                    if (newIDS)
                    {
                        obj.ResetIDs();
                    }
                    //if we want this to be a import method then we need new uuids for the object to avoid any clashes
                    //obj.RegenerateFullIDs();

                    scene.AddNewSceneObject(obj, true);
                }
            }
            else
            {
                throw new Exception("Could not open file " + fileName + " for reading");
            }
        }
Esempio n. 8
0
    /// <summary>
    /// Constructs an XmlStorage class
    /// </summary>
    /// <param name="fileName">Xml file to use</param>
    public XmlStorage(string fileName)
    {
        this.isRoot   = true;
        this.root     = this;
        this.fileName = fileName;
        this.name     = "Root";

        try
        {
            IO.FileStream     stream = new IO.FileStream(fileName, IO.FileMode.Open, IO.FileAccess.Read);
            Xml.XmlTextReader reader = new Xml.XmlTextReader(stream);

            try
            {
                this.ReadElements(reader);
            }
            finally
            {
                reader.Close();
                stream.Close();
            }
        }
        catch (IO.FileNotFoundException)
        {}
    }
Esempio n. 9
0
        /// <summary>
        /// Methode principale permettant de générer une liste de jeux
        /// à partir du fichier XML passé en paramètres
        /// </summary>
        /// <param name="path">Chemin vers le fichier XML</param>
        /// <returns>Liste des jeux à retourner</returns>
        public static List<Game> ReadXML(string path)
        {
            List<Game> games = new List<Game>();

            XmlTextReader textReader = new XmlTextReader(path);
            textReader.WhitespaceHandling = WhitespaceHandling.None;
            Hashtable XML = (Hashtable)ReturnElement(textReader);
            //Console.WriteLine(PrintKeysAndValues(XML, ""));

            try
            {
                XML = (Hashtable)XML["Jeux"];
                List<Object> list = (List<Object>)(XML["Jeu"]);

                foreach (Object o in list) // Pour chaque Jeu
                {
                    Hashtable ht = (Hashtable)o;

                    // On l'ajoute à jeux
                    games.Add(new Game((String)(ht["Nom"]), (String)((ht["Icone"])), (String)(ht["Executable"]), (String)(ht["Description"]), int.Parse((String)(ht["Version"])), InstallState.Installed));
                }

                foreach (Game j in games)
                    Console.WriteLine("{0}", j);
                /*            }
                            catch (Exception e)
                            { Console.WriteLine("Erreur : {0}", e.Message); } // Fichier non trouvé*/
                textReader.Close();
            }
            catch (Exception sarlon)
            { }
            return games;
        }
Esempio n. 10
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 string getIssueDetails(string projid, string issueid)
        {
            System.IO.StringReader   stream = null;
            System.Xml.XmlTextReader reader = null;

            try
            {
                GetIssueDetailsCaller obj = new GetIssueDetailsCaller();

                string result = obj.MRWebServices__getIssueDetails(
                    "WebServices",
                    "fakepassword",
                    "RETURN_MODE => 'xml'",
                    projid,
                    issueid);

                stream = new System.IO.StringReader(result);
                reader = new System.Xml.XmlTextReader(stream);
                return(ParseXml(reader));
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Esempio n. 12
0
        private string ReadTokensFromXML()
        {
            string tokens = String.Empty;

            try
            {
                XmlTextReader tokensXmlReader = new XmlTextReader(String.Format(@"{0}\{1}",
                                                                  System.IO.Directory.GetCurrentDirectory(),
                                                                  xmlName));
                while (tokensXmlReader.Read())
                {
                    if (tokensXmlReader.NodeType == XmlNodeType.Element && tokensXmlReader.Name == "token")
                    {
                        tokens += String.Format("Token \"{0}\"\n \tLine: {1}\n \tPosition: {2}\n \tValue: {3}\n\n",
                                                tokensXmlReader.GetAttribute("type"),
                                                Convert.ToString(Convert.ToInt32(tokensXmlReader.GetAttribute("line")) + 1),
                                                tokensXmlReader.GetAttribute("position"),
                                                tokensXmlReader.GetAttribute("value"));
                    }
                }

                tokensXmlReader.Close();
                return tokens;
            }
            catch
            {
                return "";
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Load matrix from XML file
        /// </summary>
        /// <param name="fileName">file name</param>
        /// <returns>Loaded matrix</returns>
        public Matrix Load(string fileName)
        {
            XmlTextReader textReader = new XmlTextReader(fileName);
            Matrix matrix = new Matrix();
            string fromWord = null;
            string toWord;
            float statisticValue;

            while (textReader.Read())
            {
                if (textReader.NodeType == XmlNodeType.Element)
                {
                    if (textReader.Name == "fromWord")
                    {
                        fromWord = textReader.GetAttribute("name");
                    }
                    else if (textReader.Name == "toWord")
                    {
                        if (fromWord != null)
                        {
                            toWord = textReader.GetAttribute("name");
                            float.TryParse(textReader.GetAttribute("statisticValue"), out statisticValue);
                            matrix.SetStatistics(fromWord, toWord, statisticValue);
                        }
                    }
                }
            }

            textReader.Close();

            return matrix;
        }
        public override WebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            XmlTextReader reader = new XmlTextReader(context.ResponseStream);
            SendMessageResponse response = new SendMessageResponse();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        switch (reader.LocalName)
                        {
                            case MNSConstants.XML_ELEMENT_MESSAGE_ID:
                                response.MessageId = reader.ReadElementContentAsString();
                                break;
                            case MNSConstants.XML_ELEMENT_MESSAGE_BODY_MD5:
                                response.MessageBodyMD5 = reader.ReadElementContentAsString();
                                break;
                        }
                        break;
                }
            }
            reader.Close();
            return response;
        }
Esempio n. 15
0
        private void FillDataSetSingleTable()
        {
            DataSet dsSource = new DataSet();

            dataGrid.DataSource = dsSource;

            System.IO.FileStream myFileStream = new System.IO.FileStream("programes.xsd", System.IO.FileMode.Open);


            System.Xml.XmlTextReader myXmlTextReader = new System.Xml.XmlTextReader(myFileStream);
            dsSource.ReadXmlSchema(myXmlTextReader);
            myXmlTextReader.Close();

            System.IO.FileStream fsReadXml = new System.IO.FileStream
                                                 ("programes.xml", System.IO.FileMode.Open);

            System.Xml.XmlTextReader myXmlReader = new System.Xml.XmlTextReader(fsReadXml);

            dsSource.ReadXml(myXmlReader);
            myXmlReader.Close();

            dataGrid.DataSource = dsSource.Tables["programes"];
            Console.WriteLine("DataSource {0}", dataGrid.DataSource);
            Console.WriteLine("DataMember {0}", dataGrid.DataMember);
            FillTree();
            dataGrid.CurrentCell = new DataGridCell(5, 10);
        }
 public CategoriesInfoRepository()
 {
     XmlReader reader = new XmlTextReader(path);
     List<CategoryInfo> infoFromXml = (List<CategoryInfo>)writers.Deserialize(reader);
     reader.Close();
     this.categoriesInfolList = infoFromXml;
 }
        public object Table_GetByID(Guid tableId)
        {
            object returnValue = null;

            try
            {
                var fileStream = base.GetFileReadStream(Path.Combine(this._tableDirectoryPath, tableId.ToString() + ".xml"));
                var xmlTextReader = new XmlTextReader(fileStream);

                returnValue = Serializer.Deserialize(xmlTextReader);

                fileStream.Close();
                fileStream.Dispose();

                xmlTextReader.Close();
                xmlTextReader.Dispose();
            }
            catch (Exception ex)
            {
                if (this._logger != null)
                {
                    this._logger.Log(ex.Message, Category.Exception, Priority.High);
                }
            }

            return returnValue;
        }
        protected void visualizeDo_Click(object sender, EventArgs e)
        {

            // get xslt file
            string xslt = "";
            if (xsltSelection.Value.Contains("<xsl:stylesheet"))
            {
                xslt = xsltSelection.Value;
            }
            else
            {
                System.IO.StreamReader xsltFile =
                System.IO.File.OpenText(
                    IOHelper.MapPath(SystemDirectories.Umbraco + "/xslt/templates/clean.xslt")
                );

                xslt = xsltFile.ReadToEnd();
                xsltFile.Close();

                // parse xslt
                xslt = xslt.Replace("<!-- start writing XSLT -->", xsltSelection.Value);

                // prepare support for XSLT extensions
                xslt = macro.AddXsltExtensionsToHeader(xslt);

            }

            Dictionary<string, object> parameters = new Dictionary<string, object>(1);
            parameters.Add("currentPage", library.GetXmlNodeById(contentPicker.Value));


            // apply the XSLT transformation
            string xsltResult = "";
            XmlTextReader xslReader = null;
            try
            {
                xslReader = new XmlTextReader(new StringReader(xslt));
                System.Xml.Xsl.XslCompiledTransform xsl = macro.CreateXsltTransform(xslReader, false);
                xsltResult = macro.GetXsltTransformResult(new XmlDocument(), xsl, parameters);
            }
            catch (Exception ee)
            {
                xsltResult = string.Format(
                    "<div class=\"error\"><h3>Error parsing the XSLT:</h3><p>{0}</p></div>",
                    ee.ToString());
            }
            finally
            {
                xslReader.Close();
            }
            visualizeContainer.Visible = true;

            // update output
            visualizeArea.Text = !String.IsNullOrEmpty(xsltResult) ? "<div id=\"result\">" + xsltResult + "</Div>" : "<div class=\"notice\"><p>The XSLT didn't generate any output</p></div>";


            // add cookie with current page
			// zb-00004 #29956 : refactor cookies names & handling
			cookie.SetValue(contentPicker.Value);
        }
Esempio n. 19
0
        public static void Main()
        {
            string filePath = @"emp_10_11_15.xml";
            try
            {
                //Here we open the XML file
                XmlTextReader xmlTextReader = new XmlTextReader(filePath);
                //Does not return any whitespace node
                xmlTextReader.WhitespaceHandling = WhitespaceHandling.None;
                //Here we load the file into memory
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(xmlTextReader);
                //Here we get the document root nodeXmlNode xmlNode=
                XmlNode xmlNode = xmlDocument.DocumentElement;
                //Here we recursively walk through the node tree
                AddChildren(xmlNode, 0);
                //Heer we close the reader
                xmlTextReader.Close();
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(filePath + " was not found!");
            }

            Console.WriteLine("\nPress enter to close...");
            Console.ReadLine();
        }
		List<SyntaxMode> ScanDirectory(string directory)
		{
			string[] files = Directory.GetFiles(directory);
			List<SyntaxMode> modes = new List<SyntaxMode>();
			foreach (string file in files) {
				if (Path.GetExtension(file).Equals(".XSHD", StringComparison.OrdinalIgnoreCase)) {
					XmlTextReader reader = new XmlTextReader(file);
					while (reader.Read()) {
						if (reader.NodeType == XmlNodeType.Element) {
							switch (reader.Name) {
								case "SyntaxDefinition":
									string name       = reader.GetAttribute("name");
									string extensions = reader.GetAttribute("extensions");
									modes.Add(new SyntaxMode(Path.GetFileName(file),
									                         name,
									                         extensions));
									goto bailout;
								default:
									throw new HighlightingDefinitionInvalidException("Unknown root node in syntax highlighting file :" + reader.Name);
							}
						}
					}
				bailout:
					reader.Close();
					
				}
			}
			return modes;
		}
Esempio n. 21
0
    /// <summary>
    /// Constructs an XmlStorage class
    /// </summary>
    /// <param name="fileName">Xml file to use</param>
    public XmlStorage(string fileName)
    {
        this.isRoot = true;
        this.root = this;
        this.fileName = fileName;
        this.name = "Root";

        try
        {
            IO.FileStream stream = new IO.FileStream(fileName, IO.FileMode.Open, IO.FileAccess.Read);
            Xml.XmlTextReader reader = new Xml.XmlTextReader(stream);

            try
            {
                this.ReadElements(reader);
            }
            finally
            {
                reader.Close();
                stream.Close();
            }
        }
        catch (IO.FileNotFoundException)
        {}
    }
Esempio n. 22
0
		public static XmlSchema GetSchema (string path)
		{
			XmlTextReader reader = new XmlTextReader (path);
			XmlSchema schema = XmlSchema.Read (reader, null);
			reader.Close ();
			return schema;
		}
Esempio n. 23
0
 public static Body Load()
 {
     XmlSerializer serializer = new XmlSerializer(typeof(Body));
     Body b = null;
     if (File.Exists("data/data.xml"))
     {
         XmlTextReader xmlReader = new XmlTextReader("data/data.xml");
         b = (Body)serializer.Deserialize(xmlReader);
         xmlReader.Close();
     }
     else
     {
         b = new Body();
     }
     Groesse = b.bodyEntryFaktor.Groesse;
     BodyEntryFaktorStatic = b.bodyEntryFaktor;
     foreach (var b1 in b.bodyList.Liste)
     {
         b1.Parent = b.bodyList;
         b1.OnPropertyChanged("BMI");
         b1.OnPropertyChanged("Punkte");
     }
     b.bodyList.Refresh();
     return b;
 }
Esempio n. 24
0
        //update cd node
        private void button1_Click(object sender, System.EventArgs e)
        {
            // basically the same as remove node
            try
            {
                XmlTextReader reader = new XmlTextReader(FILE_NAME);
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);
                reader.Close();

                //Select the cd node with the matching title
                XmlNode oldCd;
                XmlElement root = doc.DocumentElement;
                oldCd = root.SelectSingleNode("/catalog/cd[title='" + oldTitle + "']");

                XmlElement newCd = doc.CreateElement("cd");
                newCd.SetAttribute("country",country.Text);

                newCd.InnerXml = "<title>" + this.comboBox1.Text + "</title>" +
                    "<artist>" + artist.Text + "</artist>" +
                    "<price>" + price.Text + "</price>";

                root.ReplaceChild(newCd, oldCd);
                //save the output to a file
                doc.Save(FILE_NAME);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Console.WriteLine ("Exception: {0}", ex.ToString());
                this.DialogResult = DialogResult.Cancel;
            }
        }
Esempio n. 25
0
        public DImageList()
        {
            imageData = new SortedDictionary<string, Texture2D>();

                XmlDocument xDocument = new XmlDocument();
                XmlTextReader reader = new XmlTextReader(Dictionary.DictionaryImagesFileName);
                xDocument.Load(reader);
                XmlNodeList objectsList = xDocument.GetElementsByTagName("item");

                foreach (XmlElement node in objectsList) {

                    string name = node.GetAttribute("name");
                    string path = node.GetAttribute("path");

                    Texture2D image = Resources.Load<Texture2D>(path);
            #if UNITY_EDITOR
                    if (image == null)
                        Debug.LogError("[" + name + "] Не удалось загрузить ресурс '" + path + "'!");
            #endif

                    imageData.Add(name, image);

                }

                reader.Close();
                reader = null;
                xDocument = null;
        }
Esempio n. 26
0
        public void LoadFromXmlFile(string sFile)
        {
            Clear();

            XmlTextReader xr = new XmlTextReader(sFile);
            while (xr.Read())
            {
                if (xr.NodeType == XmlNodeType.Element)
                {
                    if (xr.Name == "FontValidatorProject")
                    {
                        m_sComputerName = xr.GetAttribute("MachineName");
                    }
                    else if (xr.Name == "FontFile")
                    {
                        string sPath = xr.GetAttribute("Path");
                        m_sFilesToTest.Add(sPath);
                    }
                    else if (xr.Name == "Test")
                    {
                        string sTableName = xr.GetAttribute("Name");
                        string sValue = xr.GetAttribute("Value");
                        bool bTest = true;
                        if (sValue.ToLower().CompareTo("true") != 0)
                        {
                            bTest = false;
                        }
                        m_hashTestsToPerform[sTableName] = bTest;
                    }
                }
            }
            xr.Close();

            m_sFilename = sFile;
        }
Esempio n. 27
0
		public static List<SyntaxMode> GetSyntaxModes(Stream xmlSyntaxModeStream)
		{
			XmlTextReader reader = new XmlTextReader(xmlSyntaxModeStream);
			List<SyntaxMode> syntaxModes = new List<SyntaxMode>();
			while (reader.Read()) {
				switch (reader.NodeType) {
					case XmlNodeType.Element:
						switch (reader.Name) {
							case "SyntaxModes":
								string version = reader.GetAttribute("version");
								if (version != "1.0") {
									throw new HighlightingDefinitionInvalidException("Unknown syntax mode file defininition with version " + version);
								}
								break;
							case "Mode":
								syntaxModes.Add(new SyntaxMode(reader.GetAttribute("file"), 
								                               reader.GetAttribute("name"),
								                               reader.GetAttribute("extensions")));
								break;
							default:
								throw new HighlightingDefinitionInvalidException("Unknown node in syntax mode file :" + reader.Name);
						}
						break;
				}
			}
			reader.Close();
			return syntaxModes;
		}
 public RepertoireRepository()
 {
     XmlReader reader = new XmlTextReader(path);
     List<TheaterRepertoire> filereprt = (List<TheaterRepertoire>)writers.Deserialize(reader);
     reader.Close();
     this.repertoiresList = filereprt;
 }
Esempio n. 29
0
        public void LoadData()
        {
            lock (this)
            {
                doc = new XmlDocument();
                if (File.Exists(fileName))
                {
                    XmlTextReader reader = new XmlTextReader(fileName);
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    doc.Load(reader);
                    reader.Close();
                }
                else
                {
                    createdFile = true;
                    rootNode = doc.CreateNode(XmlNodeType.Element, "Root", String.Empty);
                    doc.AppendChild(rootNode);
                    configNode = doc.CreateNode(XmlNodeType.Element, "Config", String.Empty);
                    rootNode.AppendChild(configNode);
                }

                LoadDataToClass();

                if (createdFile)
                {
                    Commit();
                }
            }
        }
        public void LeerFile()
        {
            string Ruta = @"F:\Proyecto-Curso\Proyecto-Curso\ArchivoXML\ArchivoXML.xml";

            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Ruta);
            string contents = "";

            while (reader.Read())
            {
                reader.MoveToContent();

                switch (reader.NodeType)
                {
                //case XmlNodeType.Element: // The node is an element.
                //Console.Write("<" + reader.Name);       Console.WriteLine(">");     break;
                case XmlNodeType.Text: //Display the text in each element.
                    Console.WriteLine(reader.Value);
                    break;
                    //case XmlNodeType. EndElement: //Display the end of the element.
                    //Console.Write("</" + reader.Name);
                    //Console.WriteLine(">"); break;
                }
            }
            reader.Close();
        }
Esempio n. 31
0
        public void ReadConfigFile(String settingsFile, ref List<String> dataLocations, ref List<String> providers)
        {
            //clear providers variable from form1 so that we dont havea huge list with duplicates
            providers.Clear();
            XmlTextReader reader = new XmlTextReader(settingsFile);
            String previousNodeName = "";

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element: // this node is an element
                        break;
                    case XmlNodeType.Text: //display the text in each element
                       if (previousNodeName == "MetricsFolder")
                            {
                                dataLocations.Add(reader.Value);
                            }
                            if (previousNodeName == "DashboardFile")
                            {
                                dataLocations.Add(reader.Value);
                            }
                            if (previousNodeName == "Name")
                            {
                                providers.Add(reader.Value);
                            }
                        break;
                    case XmlNodeType.EndElement: //display the end of the element
                        break;
                }
                previousNodeName = reader.Name;

            }
            reader.Close();
        }
Esempio n. 32
0
        /// <summary>
        /// Deserializes an xml document back into an object
        /// </summary>
        /// <param name="xml">The xml data to deserialize</param>
        /// <param name="type">The type of the object being deserialized</param>
        /// <returns>A deserialized object</returns>
        public static object Deserialize(XmlDocument xml, Type type)
        {
            XmlSerializer s = new XmlSerializer(type);
            string xmlString = xml.OuterXml.ToString();
            byte[] buffer = ASCIIEncoding.UTF8.GetBytes(xmlString);
            MemoryStream ms = new MemoryStream(buffer);
            XmlReader reader = new XmlTextReader(ms);
            Exception caught = null;

            try
            {
                object o = s.Deserialize(reader);
                return o;
            }

            catch (Exception e)
            {
                caught = e;
            }
            finally
            {
                reader.Close();

                if (caught != null)
                    throw caught;
            }
            return null;
        }
Esempio n. 33
0
        public string search(string projid, string title)
        {
            System.IO.StringReader   stream = null;
            System.Xml.XmlTextReader reader = null;

            try
            {
                SearchCaller search = new SearchCaller();
                string       result = search.MRWebServices__search(
                    "WebServices",
                    "fakepassword",
                    "RETURN_MODE => 'xml'",
                    "select mrID, mrTITLE from MASTER" + projid + " WHERE mrTITLE LIKE '%" + title + "%'");

                stream = new System.IO.StringReader(result);
                reader = new System.Xml.XmlTextReader(stream);

                return(ParseXml(reader));
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
        public override void Initialize(ESRI.ArcLogistics.App.Pages.Page page)
        {
            label1.Content = "Data unavailable.";
            try
            {
                string URLString = @"http://www.weather.gov/xml/current_obs/KRAL.xml";
                XmlTextReader reader = new XmlTextReader(URLString);

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "temperature_string")
                    {
                        if (reader.Read())
                            label1.Content = "Riverside, CA: " + reader.Value;

                        reader.Close();
                        break;
                    }
                }
            }

            finally
            {

            }
        }
        /// <summary> Reads metadata from an existing metadata file and saves to the provided item/package </summary>
        /// <param name="MetadataFilePathName"> Path and name of the metadata file to read </param>
        /// <param name="Return_Package"> Package into which to read the metadata </param>
        /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param>
        /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during reading </param>
        /// <returns>TRUE if successful, otherwise FALSE </returns>
        public bool Read_Metadata(string MetadataFilePathName, SobekCM_Item Return_Package, Dictionary<string, object> Options, out string Error_Message)
        {
            // Set default error outpt message
            Error_Message = String.Empty;

            // Create a stream and XML reader and read the metadata
            Stream reader = null;
            XmlTextReader nodeReader = null;
            bool returnValue = true;

            try
            {
                reader = new FileStream(MetadataFilePathName, FileMode.Open, FileAccess.Read);

                // create the node reader
                nodeReader = new XmlTextReader(reader);

                MarcXML_METS_dmdSec_ReaderWriter.Read_MarcXML_Info(nodeReader, Return_Package.Bib_Info, Return_Package, true, Options );
            }
            catch (Exception ee)
            {
                Error_Message = "Error reading MarcXML from stream: " + ee.Message;
                returnValue = false;
            }
            finally
            {
                if (nodeReader != null)
                    nodeReader.Close();
                if (reader != null)
                    reader.Close();
            }

            return returnValue;
        }
        public static List<Issue> GetIssueListFromXmlStream(Stream stream) {
            List<Issue> issues = new List<Issue>();
            XmlTextReader reader = new XmlTextReader(stream);
            XmlDocument doc = new XmlDocument();
            doc.Load(reader);
            reader.Close();
            XmlNodeList list = doc.DocumentElement.GetElementsByTagName("item");
            XmlSerializer s = new XmlSerializer(typeof(Issue));
            //Create the XmlNamespaceManager.
            NameTable nt = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
            nsmgr.AddNamespace("jc", "urn:jiraconn");

            //Create the XmlParserContext.
            XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

            foreach (XmlNode item in list)
            {
                //Create the reader. 
                XmlTextReader itemReader = new XmlTextReader(item.OuterXml, XmlNodeType.Element, context);
                Issue issue = (Issue)s.Deserialize(itemReader);
                issues.Add(issue);
            }

            return issues;
            
        }
Esempio n. 37
0
        static void Main()
        {
            WriteHeader();
            Utils.Log.Debug("XmlReader", "Reading configuration file");
            Xml.XmlReader ConfigurationFileReader = new Xml.XmlTextReader("configuration.xml");
            string        ParentTab = null;

            while (ConfigurationFileReader.Read())
            {
                switch (ConfigurationFileReader.NodeType)
                {
                case Xml.XmlNodeType.Element:
                    ParentTab = ConfigurationFileReader.Name;
                    break;

                case Xml.XmlNodeType.Text:
                    switch (ParentTab)
                    {
                    case "server_id":
                        ServerID = int.Parse(ConfigurationFileReader.Value);
                        break;

                    case "server_address":
                        ServerAddress = ConfigurationFileReader.Value;
                        break;

                    case "server_port":
                        ServerPort = int.Parse(ConfigurationFileReader.Value);
                        break;

                    case "mysql_host":
                        MySQLHost = ConfigurationFileReader.Value;
                        break;

                    case "mysql_port":
                        MySQLPort = int.Parse(ConfigurationFileReader.Value);
                        break;

                    case "mysql_user":
                        MySQLUser = ConfigurationFileReader.Value;
                        break;

                    case "mysql_password":
                        MySQLPassword = ConfigurationFileReader.Value;
                        break;

                    case "debug":
                        Debug = ConfigurationFileReader.Value.ToLower() == "true" ? true : false;
                        break;
                    }
                    break;
                }
            }
            ConfigurationFileReader.Close();
            IServer Server = new IServer(ServerID, ServerAddress, ServerPort, MySQLHost, MySQLPort, new string[] { MySQLUser, MySQLPassword });

            Server.Run();
            System.Console.Read();
        }
Esempio n. 38
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);
        }
Esempio n. 39
0
        /// <summary>
        /// Constructor used to read fitness_params out of a XML file
        /// </summary>
        /// <param name="XMLfile">name of the xml file</param>
        public fitness_params(string XMLfile)
        {
            XmlTextReader reader = new System.Xml.XmlTextReader(XMLfile);

            getParamsFromXMLReader(ref reader);

            reader.Close();
        }
Esempio n. 40
0
        /// <summary>
        /// Constructor creating the sensors by reading from the given xml file.
        /// </summary>
        /// <param name="XMLfile"></param>
        /// <param name="myPlant"></param>
        public sensors(string XMLfile, biogas.plant myPlant)
        {
            XmlTextReader reader = new System.Xml.XmlTextReader(XMLfile);

            getParamsFromXMLReader(ref reader, myPlant);

            reader.Close();
        }
Esempio n. 41
0
        /// <summary>
        /// Constructor creating the transportation object by reading from the
        /// given xml file.
        /// </summary>
        /// <param name="XMLfile">xml file</param>
        public transportation(string XMLfile)
        {
            XmlTextReader reader = new System.Xml.XmlTextReader(XMLfile);

            getParamsFromXMLReader(ref reader);

            reader.Close();
        }
Esempio n. 42
0
        /// <summary>
        /// Constructor used to read substrate out of a XML file
        /// </summary>
        /// <param name="XMLfile">name of the xml file</param>
        public substrate(string XMLfile)
        {
            XmlTextReader reader = new System.Xml.XmlTextReader(XMLfile);

            getParamsFromXMLReader(ref reader);

            reader.Close();
        }
Esempio n. 43
0
        /// <summary>
        /// Function that reads in an XML file and returns a dataset
        /// </summary
        ///
        public static DataSet ReadXML(string DataSetName, string XMLFile)
        {
            DataSet ds = new DataSet();

            System.Xml.XmlTextReader sr = new System.Xml.XmlTextReader(XMLFile);
            ds.ReadXml(XMLFile);
            sr.Close();

            return(ds);
        }
Esempio n. 44
0
    public DataTable GetDataTable()
    {
        DataSet ds = new DataSet();

        System.IO.FileStream     fs     = new System.IO.FileStream("programes.xml", System.IO.FileMode.Open);
        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(fs);
        ds.ReadXml(reader);
        reader.Close();
        return(ds.Tables["programes"]);
    }
Esempio n. 45
0
        /// <summary>
        /// Constructor used to read digester out of a XML file
        /// </summary>
        /// <param name="XMLfile">filename of xml file</param>
        public digester(string XMLfile)
        {
            XmlTextReader reader = new System.Xml.XmlTextReader(XMLfile);

            getParamsFromXMLReader(ref reader);

            reader.Close();

            _AD_Model = new ADM(T);
        }
Esempio n. 46
0
        private void FillDataSetSeveralTables()
        {
            DataSet dsSource = new DataSet();

            System.IO.FileStream myFileStream = new System.IO.FileStream("factures.xsd", System.IO.FileMode.Open);

            // Create a new XmlTextReader object with the FileStream.
            System.Xml.XmlTextReader myXmlTextReader =
                new System.Xml.XmlTextReader(myFileStream);
            // Read the schema into the DataSet and close the reader.
            dsSource.ReadXmlSchema(myXmlTextReader);
            myXmlTextReader.Close();

            // Read the XML document back in.
            // Create new FileStream to read schema with.
            System.IO.FileStream fsReadXml = new System.IO.FileStream
                                                 ("factures.xml", System.IO.FileMode.Open);

            System.Xml.XmlTextReader myXmlReader = new System.Xml.XmlTextReader(fsReadXml);

            dsSource.ReadXml(myXmlReader);
            myXmlReader.Close();

            myFileStream = new System.IO.FileStream("clients.xsd", System.IO.FileMode.Open);

            // Create a new XmlTextReader object with the FileStream.
            myXmlTextReader =
                new System.Xml.XmlTextReader(myFileStream);
            // Read the schema into the DataSet and close the reader.
            dsSource.ReadXmlSchema(myXmlTextReader);
            myXmlTextReader.Close();

            fsReadXml = new System.IO.FileStream
                            ("clients.xml", System.IO.FileMode.Open);

            myXmlReader = new System.Xml.XmlTextReader(fsReadXml);

            dsSource.ReadXml(myXmlReader);
            myXmlReader.Close();

            DataTable factures = dsSource.Tables["Factures"];
            DataTable clients  = dsSource.Tables["Clients"];

            DataRelation rel = new DataRelation(null,
                                                new DataColumn [] { clients.Columns["Id"] },        // parent
                                                new DataColumn [] { factures.Columns["cliente"] }); // child, consumer

            dsSource.Relations.Add(rel);

            dataGrid.DataSource = dsSource;            //;.Tables["programes"];
            FillTree();
        }
Esempio n. 47
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);
        }
Esempio n. 48
0
        public static bool VerifyFileFormat(string convertedCadFilePath)
        {
            bool isValid       = true;
            var  xmlTextReader = new System.Xml.XmlTextReader(convertedCadFilePath);

            xmlTextReader.MoveToContent();
            if (!String.Equals(xmlTextReader.LocalName, "Model3DGroup", StringComparison.CurrentCultureIgnoreCase))
            {
                isValid = false;
                throw new Exception("Failed...");
            }
            xmlTextReader.Close();

            return(isValid);
        }
Esempio n. 49
0
        private void readDictionaryFile(string filename)
        {
            try
            {
                // Read the XML document back in.
                System.IO.FileStream     fsReadXml   = new System.IO.FileStream(filename, System.IO.FileMode.Open);
                System.Xml.XmlTextReader myXmlReader = new System.Xml.XmlTextReader(fsReadXml);
                dictionaryDataSet.ReadXml(myXmlReader, XmlReadMode.IgnoreSchema);                               // we already have schema
                myXmlReader.Close();

                dictionaryDataSet.AcceptChanges();
            }
            catch
            {
                LibSys.StatusBar.Error("bad dictionary at " + filename);
            }
        }
Esempio n. 50
0
        /// <summary>
        /// XML字符转换成DataSet
        /// </summary>
        /// <param name="xmlStr">xml字符串</param>
        /// <returns></returns>
        public DataSet XmlToDataSet(string xmlStr)
        {
            try
            {
                if (!string.IsNullOrEmpty(xmlStr))
                {
                    StringReader             StrStream = null;
                    System.Xml.XmlTextReader Xmlrdr    = null;
                    try
                    {
                        DataSet ds = new DataSet();
                        //读取字符串中的信息
                        StrStream = new StringReader(xmlStr);
                        //获取StrStream中的数据
                        Xmlrdr = new System.Xml.XmlTextReader(StrStream);
                        //ds获取Xmlrdr中的数据
                        ds.ReadXml(Xmlrdr);

                        return(ds);
                    }
                    catch (Exception e)
                    {
                        return(null);
                    }
                    finally
                    {
                        //释放资源
                        if (Xmlrdr != null)
                        {
                            Xmlrdr.Close();
                            StrStream.Close();
                            StrStream.Dispose();
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 51
0
        public string TransformXML(string xml, string xsl)
        {
            System.IO.StringReader          stringReader        = null;
            System.Xml.Xsl.XslTransform     xslTransform        = null;
            System.Xml.XmlTextReader        xmlTextReader       = null;
            System.IO.MemoryStream          xmlTextWriterStream = null;
            System.Xml.XmlTextWriter        xmlTextWriter       = null;
            System.Xml.XmlDocument          xmlDocument         = null;
            System.IO.StreamReader          streamReader        = null;
            System.Security.Policy.Evidence evidence            = null;
            try
            {
                stringReader        = new System.IO.StringReader(xsl);
                xslTransform        = new System.Xml.Xsl.XslTransform();
                xmlTextReader       = new System.Xml.XmlTextReader(stringReader);
                xmlTextWriterStream = new System.IO.MemoryStream();
                xmlTextWriter       = new System.Xml.XmlTextWriter(xmlTextWriterStream, System.Text.Encoding.Default);
                xmlDocument         = new System.Xml.XmlDocument();

                evidence = new System.Security.Policy.Evidence();
                evidence.AddAssembly(this);
                xmlDocument.LoadXml(xml);
                xslTransform.Load(xmlTextReader, null, evidence);
                xslTransform.Transform(xmlDocument, null, xmlTextWriter, null);
                xmlTextWriter.Flush();

                xmlTextWriterStream.Position = 0;
                streamReader = new System.IO.StreamReader(xmlTextWriterStream);
                return(streamReader.ReadToEnd());
            }
            catch (Exception exc)
            {
                LogEvent(exc.Source, "TransformXML()", exc.ToString(), 4);
                return("");
            }
            finally
            {
                streamReader.Close();
                xmlTextWriter.Close();
                xmlTextWriterStream.Close();
                xmlTextReader.Close();
                stringReader.Close();
                GC.Collect();
            }
        }
Esempio n. 52
0
        private bool ReadXMLFile(string fileName)
        {
            try
            {
                Logger.MajorDebug("Reading XML configuration...");
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(fileName);
                reader.WhitespaceHandling = System.Xml.WhitespaceHandling.None;
                reader.MoveToContent();
                reader.Read();

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                doc.Load(reader);

                port                   = Convert.ToInt32(GetParameterValue(doc, "Port"));
                consolePort            = Convert.ToInt32(GetParameterValue(doc, "ConsolePort"));
                maxCons                = Convert.ToInt32(GetParameterValue(doc, "MaxConnections"));
                LMKFile                = Convert.ToString(GetParameterValue(doc, "LMKStorageFile"));
                VBsources              = Convert.ToString(GetParameterValue(doc, "VBSourceDirectory"));
                Logger.CurrentLogLevel = (Log.Logger.LogLevel)(Enum.Parse(typeof(Logger.LogLevel), Convert.ToString(GetParameterValue(doc, "LogLevel")), true));
                CheckLMKParity         = Convert.ToBoolean(GetParameterValue(doc, "CheckLMKParity"));
                HostDefsDir            = Convert.ToString(GetParameterValue(doc, "XMLHostDefinitionsDirectory"));
                DoubleLengthZMKs       = Convert.ToBoolean(GetParameterValue(doc, "DoubleLengthZMKs"));
                LegacyMode             = Convert.ToBoolean(GetParameterValue(doc, "LegacyMode"));
                ExpectTrailers         = Convert.ToBoolean(GetParameterValue(doc, "ExpectTrailers"));
                HeaderLength           = Convert.ToInt32(GetParameterValue(doc, "HeaderLength"));
                EBCDIC                 = Convert.ToBoolean(GetParameterValue(doc, "EBCDIC"));

                StartUpCore(Convert.ToString(GetParameterValue(doc, "FirmwareNumber")), Convert.ToString(GetParameterValue(doc, "DSPFirmwareNumber")),
                            Convert.ToBoolean(GetParameterValue(doc, "StartInAuthorizedState")), Convert.ToInt32(GetParameterValue(doc, "ClearPINLength")));

                reader.Close();
                reader = null;

                return(true);
            }
            catch (Exception ex)
            {
                Logger.MajorError("Error loading the configuration file");
                Logger.MajorError(ex.ToString());
                return(true);
            }
        }
Esempio n. 53
0
        private void PlayEpisode(int episode, AxShockwaveFlashObjects.AxShockwaveFlash FlashControl) //Odtwórz odcinek
        {
            Control[] Cont = { btnPlay, cmbBox, linkLabel1, Stan, menuStrip1, btnToHTML, btnEpisodesList };
            System.Xml.XmlTextReader XMLTxtReader = new System.Xml.XmlTextReader(Friends_from_MegaVideo_player.Properties.Settings.Default.FilePath);
            System.Xml.XmlDocument   XMLDoc       = new System.Xml.XmlDocument();
            XMLDoc.Load(XMLTxtReader);
            XMLTxtReader.Close();
            XmlNodeList nl = XMLDoc.SelectNodes("/Spis/Odcinek/NazwaOdcinka");

            Friends_from_MegaVideo_player.Properties.Settings.Default.Ostatni = episode;
            Friends_from_MegaVideo_player.Properties.Settings.Default.Save();
            this.Focus();
            if ((episode < 239) | (episode > 0))
            {
                foreach (XmlNode n in nl)
                {
                    if (n.NextSibling.NextSibling.NextSibling.InnerText == episode.ToString())                                                     //Szuka odcinka o takiej samej nazwie jak ta wyciągnięta z pliku XML
                    {
                        FlashControl.Movie = (n.NextSibling.NextSibling.NextSibling.NextSibling.InnerText);                                        //Wyciągnięcie linku z pliku
                        this.Text          = "Przyjaciele Player - " + n.InnerText + " (" + n.NextSibling.NextSibling.NextSibling.InnerText + ")"; //Ustawienie nagłówka
                        KontrolkiVisible(false, Cont);
                        this.ClientSize   = new Size(640, 481);
                        FlashControl.Size = new Size(640, 481);
                        frm.Maximize(this);
                        this.Focus();
                        break;
                    }
                }
            }
            if (episode == 239)
            {
                MessageBox.Show("To był już ostatni odcinek!");
                Friends_from_MegaVideo_player.Properties.Settings.Default.Ostatni = 238;
                Friends_from_MegaVideo_player.Properties.Settings.Default.Save();
            }
            if (episode == 0)
            {
                MessageBox.Show("To był pierwszy odcinek!");
                Friends_from_MegaVideo_player.Properties.Settings.Default.Ostatni = 1;
                Friends_from_MegaVideo_player.Properties.Settings.Default.Save();
            }
            this.Focus();
        }
Esempio n. 54
0
    // <Snippet1>
    private void ReadSchemaFromXmlTextReader()
    {
        // Create the DataSet to read the schema into.
        DataSet thisDataSet = new DataSet();

        // Set the file path and name. Modify this for your purposes.
        string filename = "Schema.xml";

        // Create a FileStream object with the file path and name.
        System.IO.FileStream stream = new System.IO.FileStream
                                          (filename, System.IO.FileMode.Open);

        // Create a new XmlTextReader object with the FileStream.
        System.Xml.XmlTextReader xmlReader =
            new System.Xml.XmlTextReader(stream);

        // Read the schema into the DataSet and close the reader.
        thisDataSet.ReadXmlSchema(xmlReader);
        xmlReader.Close();
    }
Esempio n. 55
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);
        }
Esempio n. 56
0
        private void CompareSchemas(DataTable masterTable, DataTable slaveTable)
        {
            XmlReaderSettings validator;

            System.IO.MemoryStream   schemaStream = new System.IO.MemoryStream();
            System.Xml.XmlTextReader schemaReader;
            System.IO.MemoryStream   dataStream = new System.IO.MemoryStream();
            XmlReader dataReader;

            //1) XSD (Esquema)
            masterTable.WriteXmlSchema(schemaStream);
            schemaStream.Position = 0;
            schemaReader          = new System.Xml.XmlTextReader(schemaStream);

            //2) XML (Datos)
            //Provisionalmente igualamos el nombre de la slaveTable
            //con el de la masterTable para evitar error en la validación
            string slaveTableName = slaveTable.TableName;

            slaveTable.TableName = masterTable.TableName;
            slaveTable.WriteXml(dataStream, XmlWriteMode.DiffGram);
            dataStream.Position = 0;

            // 3) Validación (Datos vs. Esquema)
            validator = new XmlReaderSettings();
            //validator.ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema;
            validator.ValidationType = ValidationType.Schema;
            validator.Schemas.Add(null, schemaReader);
            validator.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
            dataReader = XmlReader.Create(dataStream, validator);
            while (dataReader.Read())
            {
                ;
            }
            dataReader.Close();
            schemaReader.Close();
            dataStream.Close();
            schemaStream.Close();
            slaveTable.TableName = slaveTableName;
        }
Esempio n. 57
0
        public static TNfeProc GetTNFeProc(string content)
        {
            TNfeProc nfeProc = null;

            try
            {
                XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
                namespaces.Add("NFe", "http://www.portalfiscal.inf.br/nfe");
                XmlSerializer serializer = new XmlSerializer(typeof(TNfeProc));
                serializer.Serialize(Console.Out, new TNfeProc(), namespaces);
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(new System.IO.StringReader(content));
                reader.Read();
                nfeProc = (TNfeProc)serializer.Deserialize(reader);
                reader.Close();
            }
            catch
            {
                nfeProc = null;
                throw;
            }
            return(nfeProc);
        }
Esempio n. 58
0
        public void WriteXml(string xml)
        {
            this.Clear();

            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(new System.IO.StringReader(xml));
            System.Xml.XmlDocument   doc    = new System.Xml.XmlDocument();
            doc.Load(reader);

            System.Text.StringBuilder sb       = new System.Text.StringBuilder();
            XmlWriterSettings         settings = new XmlWriterSettings();

            settings.Indent          = true;
            settings.IndentChars     = "  ";
            settings.NewLineChars    = "\r\n";
            settings.NewLineHandling = NewLineHandling.Replace;
            using (XmlWriter writer = XmlWriter.Create(sb, settings)) {
                doc.Save(writer);
            }
            AppendText(sb.ToString());

            reader.Close();
        }
Esempio n. 59
0
        /// <summary>
        /// Reads the substrate list out of the xml file
        /// </summary>
        /// <param name="XMLfile">a xml file</param>
        public substrates(string XMLfile)
        {
            XmlTextReader reader = new System.Xml.XmlTextReader(XMLfile);

            string xml_tag      = "";
            string substrate_id = "";

            // go through the file
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case System.Xml.XmlNodeType.Element: // this knot is an element
                    xml_tag = reader.Name;

                    while (reader.MoveToNextAttribute())
                    { // read the attributes, here only the attribute of digester
                      // is of interest, all other attributes are ignored,
                      // actually there usally are no other attributes
                        if (xml_tag == "substrate" && reader.Name == "id")
                        {
                            // found a new substrate
                            substrate_id = reader.Value;

                            addSubstrate(new biogas.substrate(ref reader, substrate_id));

                            break;
                        }
                    }
                    break;
                } // switch
            }     // while

            //

            reader.Close();
        }
Esempio n. 60
0
    public void ReadFromXML(string sFileName)
    {
        m_AnimFrameInfoList.Clear();
        m_AnimFrameInfoList = new List <AnimatedFrameInfo>();

        int iTotalFrames            = 0;
        int iPartialCompletionFrame = 0;
        int iCurrentFrameElement    = 1;

        System.Xml.XmlTextReader XmlReader = new System.Xml.XmlTextReader(sFileName);
        System.Xml.XmlNodeType   XmlType;


        while (XmlReader.Read())
        {
            XmlReader.ReadAttributeValue();
            XmlType = XmlReader.NodeType;


            if (XmlType == System.Xml.XmlNodeType.Element)
            {
                //===========================================
                //          Get Main Info
                //===========================================
                if (XmlReader.Name == "AnimationInfo")
                {
                    iTotalFrames            = Convert.ToInt32(XmlReader.GetAttribute("TotalFrames"));
                    iPartialCompletionFrame = Convert.ToInt32(XmlReader.GetAttribute("PartialAnimationCompletionFrame"));
                    m_bRelativeToScreen     = XmlReader.GetAttribute("RelativeToScreen") == "1";
                }

                //===========================================
                //          Get Frame Info
                //===========================================
                if (XmlReader.Name == "Frame" + iCurrentFrameElement.ToString())
                {
                    AnimatedFrameInfo AFI = new AnimatedFrameInfo();
                    AFI.m_bTintScreen      = XmlReader.GetAttribute("TintScreen") == "1";
                    AFI.m_iTintScreenRed   = Convert.ToInt32(XmlReader.GetAttribute("ScreenTintRed"));
                    AFI.m_iTintScreenGreen = Convert.ToInt32(XmlReader.GetAttribute("ScreenTintGreen"));
                    AFI.m_iTintScreenBlue  = Convert.ToInt32(XmlReader.GetAttribute("ScreenTintBlue"));
                    AFI.m_iTintScreenAlpha = Convert.ToInt32(XmlReader.GetAttribute("ScreenTintAlpha"));

                    AFI.m_bTintCharacter      = XmlReader.GetAttribute("TintCharacter") == "1";
                    AFI.m_iTintCharacterRed   = Convert.ToInt32(XmlReader.GetAttribute("CharacterTintRed"));
                    AFI.m_iTintCharacterGreen = Convert.ToInt32(XmlReader.GetAttribute("CharacterTintGreen"));
                    AFI.m_iTintCharacterBlue  = Convert.ToInt32(XmlReader.GetAttribute("CharacterTintBlue"));

                    AFI.m_iWaitTimeTillNextFrame = Convert.ToInt32(XmlReader.GetAttribute("WaitTillNextFrame"));
                    AFI.m_sSoundFilename         = XmlReader.GetAttribute("SoundFilename");

                    int iTotalSprites = Convert.ToInt32(XmlReader.GetAttribute("TotalSprites"));
                    for (int i = 0; i < iTotalSprites;)
                    {
                        XmlReader.Read();
                        if (XmlReader.Name == "Sprite" + (i + 1).ToString())
                        {
                            SpriteInfo SprInfo = new SpriteInfo();
                            SprInfo.ID          = (uint)AFI.m_SpriteInfoList.Count;
                            SprInfo.TextureName = XmlReader.GetAttribute("TextureName");
                            SprInfo.X           = Convert.ToInt32(XmlReader.GetAttribute("X"));
                            SprInfo.Y           = Convert.ToInt32(XmlReader.GetAttribute("Y"));
                            SprInfo.W           = Convert.ToInt32(XmlReader.GetAttribute("W"));
                            SprInfo.H           = Convert.ToInt32(XmlReader.GetAttribute("H"));

                            // Multiplying By 1000 Because the Game uses a float value of 0-1, whereas this program uses whole pixels.
                            // Therefore it is saved in game format, but when being read back into this program, the float is multiplied
                            // by 1000 to give an integer pass value, which is corrected by a SpriteChecker function outside of this class.
                            int RectX = (int)(Convert.ToDouble(XmlReader.GetAttribute("UVCoordStartX")) * 1000.0);
                            int RectY = (int)(Convert.ToDouble(XmlReader.GetAttribute("UVCoordStartY")) * 1000.0);
                            int RectW = (int)(Convert.ToDouble(XmlReader.GetAttribute("UVCoordEndX")) * 1000.0);
                            int RectH = (int)(Convert.ToDouble(XmlReader.GetAttribute("UVCoordEndY")) * 1000.0);
                            SprInfo.BlitRect = new Rectangle(RectX, RectY, RectW, RectH);

                            AFI.m_SpriteInfoList.Add(SprInfo);
                            i++;
                        }
                    }
                    m_AnimFrameInfoList.Add(AFI);
                    iCurrentFrameElement++;
                }
            }
        }

        //===========================================
        //          Finish Up
        //===========================================
        if ((iPartialCompletionFrame + 1) < m_AnimFrameInfoList.Count)
        {
            m_AnimFrameInfoList.ElementAt(iPartialCompletionFrame - 1).m_bAnimationPartiallyCompleted = true;
        }
        XmlReader.Close();
    }