Exemple #1
0
        private void LoadData()
        {
            hasht = new Hashtable();
#if NET_2_0
            hashtm = new Hashtable();
#endif
            if (fileName != null)
            {
                stream = File.OpenRead(fileName);
            }

            try {
                xmlReader = null;
                if (stream != null)
                {
                    xmlReader = new XmlTextReader(stream);
                }
                else if (reader != null)
                {
                    xmlReader = new XmlTextReader(reader);
                }

                if (xmlReader == null)
                {
                    throw new InvalidOperationException("ResourceReader is closed.");
                }

                xmlReader.WhitespaceHandling = WhitespaceHandling.None;

                ResXHeader header = new ResXHeader();
                try {
                    while (xmlReader.Read())
                    {
                        if (xmlReader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }

                        switch (xmlReader.LocalName)
                        {
                        case "resheader":
                            ParseHeaderNode(header);
                            break;

                        case "data":
                            ParseDataNode(false);
                            break;

#if NET_2_0
                        case "metadata":
                            ParseDataNode(true);
                            break;
#endif
                        }
                    }
#if NET_2_0
                } catch (XmlException ex) {
                    throw new ArgumentException("Invalid ResX input.", ex);
                } catch (Exception ex) {
                    XmlException xex = new XmlException(ex.Message, ex,
                                                        xmlReader.LineNumber, xmlReader.LinePosition);
                    throw new ArgumentException("Invalid ResX input.", xex);
                }
#else
                } catch (Exception ex) {
                    throw new ArgumentException("Invalid ResX input.", ex);
                }
#endif

                header.Verify();
            } finally {
		private void LoadData ()
		{
			hasht = new Hashtable ();
#if NET_2_0
			hashtm = new Hashtable ();
#endif
			if (fileName != null) {
				stream = File.OpenRead (fileName);
			}

			try {
				xmlReader = null;
				if (stream != null) {
					xmlReader = new XmlTextReader (stream);
				} else if (reader != null) {
					xmlReader = new XmlTextReader (reader);
				}

				if (xmlReader == null) {
					throw new InvalidOperationException ("ResourceReader is closed.");
				}

				xmlReader.WhitespaceHandling = WhitespaceHandling.None;

				ResXHeader header = new ResXHeader ();
				try {
					while (xmlReader.Read ()) {
						if (xmlReader.NodeType != XmlNodeType.Element)
							continue;

						switch (xmlReader.LocalName) {
						case "resheader":
							ParseHeaderNode (header);
							break;
						case "data":
							ParseDataNode (false);
							break;
#if NET_2_0
						case "metadata":
							ParseDataNode (true);
							break;
#endif
						}
					}
#if NET_2_0
				} catch (XmlException ex) {
					throw new ArgumentException ("Invalid ResX input.", ex);
				} catch (Exception ex) {
					XmlException xex = new XmlException (ex.Message, ex, 
						xmlReader.LineNumber, xmlReader.LinePosition);
					throw new ArgumentException ("Invalid ResX input.", xex);
				}
#else
				} catch (Exception ex) {
					throw new ArgumentException ("Invalid ResX input.", ex);
				}
#endif
				header.Verify ();
			} finally {
Exemple #3
0
        private void LoadData()
        {
            hasht  = new Hashtable();
            hashtm = new Hashtable();
            if (fileName != null)
            {
                stream = File.OpenRead(fileName);
            }

            try {
                xmlReader = null;
                var settings = new XmlReaderSettings {
                    IgnoreWhitespace = true
                };
                if (stream != null)
                {
                    xmlReader = XmlReader.Create(stream, settings);
                }
                else if (reader != null)
                {
                    xmlReader = XmlReader.Create(reader, settings);
                }

                if (xmlReader == null)
                {
                    throw new InvalidOperationException("ResourceReader is closed.");
                }

                ResXHeader header = new ResXHeader();
                try {
                    while (xmlReader.Read())
                    {
                        if (xmlReader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }

                        switch (xmlReader.LocalName)
                        {
                        case "resheader":
                            ParseHeaderNode(header);
                            break;

                        case "data":
                            ParseDataNode(false);
                            break;

                        case "metadata":
                            ParseDataNode(true);
                            break;
                        }
                    }
                } catch (XmlException ex) {
                    throw new ArgumentException("Invalid ResX input.", ex);
                } catch (SerializationException ex) {
                    throw ex;
                } catch (TargetInvocationException ex) {
                    throw ex;
                } catch (Exception ex) {
                    XmlException xex = new XmlException(ex.Message, ex,
                                                        ((IXmlLineInfo)xmlReader).LineNumber, ((IXmlLineInfo)xmlReader).LinePosition);
                    throw new ArgumentException("Invalid ResX input.", xex);
                }
                header.Verify();
            } finally {
                if (fileName != null)
                {
                    stream.Dispose();
                    stream = null;
                }
                xmlReader = null;
            }
        }