Inheritance: XmlReader, IXmlNamespaceResolver
コード例 #1
1
ファイル: MySQL.cs プロジェクト: benapetr/wikimedia-bot
 public WMIBMySQL()
 {
     string file = Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "unwrittensql.xml";
     Core.RecoverFile(file);
     if (File.Exists(file))
     {
         Syslog.WarningLog("There is a mysql dump file from previous run containing mysql rows that were never successfuly inserted, trying to recover them");
         XmlDocument document = new XmlDocument();
         using (TextReader sr = new StreamReader(file))
         {
             document.Load(sr);
             using (XmlNodeReader reader = new XmlNodeReader(document.DocumentElement))
             {
                 XmlSerializer xs = new XmlSerializer(typeof(Unwritten));
                 Unwritten un = (Unwritten)xs.Deserialize(reader);
                 lock (unwritten.PendingRows)
                 {
                     unwritten.PendingRows.AddRange(un.PendingRows);
                 }
             }
         }
     }
     Thread reco = new Thread(Exec) {Name = "MySQL/Recovery"};
     Core.ThreadManager.RegisterThread(reco);
     reco.Start();
 }
コード例 #2
0
        private static XsdNs.DataRecordType XmlNodeToProxy(SXml.XmlNode[] nodes)
        {
            foreach (var n in nodes)
            {
                if (n.NodeType != SXml.XmlNodeType.Element)
                {
                    // Assuming this is an attribute; either namespace-related or xsi:type
                    continue;
                }

                // Assuming this is the desired data record
                try
                {
                    using (var nodeReader = new SXml.XmlNodeReader(n))
                    {
                        var serialiser = new SXml.Serialization.XmlSerializer(typeof(XsdNs.DataRecordType));
                        return((XsdNs.DataRecordType)serialiser.Deserialize(nodeReader));
                    }
                }
                catch (Exception e)
                {
                    throw new XNeut.InvalidMessageException("Failed to read data record from XML data", e);
                }
            }

            throw new XNeut.InvalidMessageException("Cannot read data record because no element was found in node array");
        }
コード例 #3
0
 public object Create(object parent, object configContext, XmlNode section)
 {
     var xRoot = new XmlRootAttribute { ElementName = section.Name, IsNullable = true };
     var ser = new XmlSerializer(GetType(), xRoot);
     var xNodeReader = new XmlNodeReader(section);
     return ser.Deserialize(xNodeReader);
 }
コード例 #4
0
 /// <summary>
 /// Converts XmlDocument to XDocument using load options.
 /// </summary>
 /// <param name="document">
 /// The input document to be converted.
 /// </param>
 /// <param name="options">
 /// The options for the conversion.
 /// </param>
 /// <returns>
 /// Resulting XDocument.
 /// </returns>
 public static XDocument ToXDocument(this XmlDocument document, LoadOptions options)
 {
     using (XmlNodeReader reader = new XmlNodeReader(document))
     {
         return XDocument.Load(reader, options);
     }
 }
コード例 #5
0
ファイル: XslUtils.cs プロジェクト: okyereadugyamfi/softlogik
        public static void TransformNode(XmlNode element, XmlReader xslTemplate)
        {
            XmlReader reader = new XmlNodeReader(element);

              XmlReader transformResultReader = TransformXml(reader, xslTemplate, null);
              element.CreateNavigator().ReplaceSelf(transformResultReader);
        }
コード例 #6
0
ファイル: HBDec.cs プロジェクト: neozhu/Kaifa.B2B.Solution
        public static void Read(XmlDocument xml)
        {
            List<DecModel> list = new List<DecModel>();
            XNamespace ns = "HTTP://CLIS.HB_DEC";

            using (var nodeReader = new XmlNodeReader(xml))
            {
                nodeReader.MoveToContent();
                XDocument xdoc= XDocument.Load(nodeReader);

                var seqNo = xdoc.Descendants(ns + "SEQ_NO").First().Value;
                var entryId = xdoc.Descendants(ns + "ENTRY_ID").First().Value;
                var ieFlag = xdoc.Descendants(ns + "I_E_FLAG").First().Value;

                foreach (var element in xdoc.Descendants(ns + "HB_DEC_LIST"))
                {
                    Console.WriteLine(element.Element(ns + "COP_G_NO").Value, element.Element(ns + "QTY").Value);
                    DecModel item = new DecModel();
                    item.EntryId = entryId;
                    item.SeqNo = seqNo;
                    item.IEFlag = ieFlag;
                    item.GNo = element.Element(ns + "COP_G_NO").Value;
                    item.Qty = Convert.ToDecimal(element.Element(ns + "QTY").Value);
                    list.Add(item);
                }

                if (list.Count > 0)
                {
                    SqlHelper.Insert(list);
                }
               

            }
        }
コード例 #7
0
        // converts the given xml document to an object of the given type.
        public static IBackpackObject ToBackpackObject(this XmlDocument xmlDocument, System.Type objType)
        {
            XmlNodeReader xmlNodeReader = new XmlNodeReader(xmlDocument.DocumentElement);
            XmlSerializer xmlSerializer = new XmlSerializer(objType);

            return (IBackpackObject)xmlSerializer.Deserialize(xmlNodeReader);
        }
コード例 #8
0
ファイル: XMLService.cs プロジェクト: maz0r/jmmserver
        public static AppVersionsResult GetAppVersions()
        {
            try
            {
                AppVersionsResult appVersions = null;

                string uri = string.Format("http://{0}/GetAppVersions.aspx", ServerSettings.WebCache_Address);
                string xml = GetData(uri);

                if (xml.Trim().Length == 0) return null;

                XmlSerializer serializer = new XmlSerializer(typeof(AppVersionsResult));
                XmlDocument docSearchResult = new XmlDocument();
                docSearchResult.LoadXml(xml);

                XmlNodeReader reader = new XmlNodeReader(docSearchResult.DocumentElement);
                object obj = serializer.Deserialize(reader);
                appVersions = (AppVersionsResult)obj;

                return appVersions;
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error in XMLService.GetAppVersions:: {0}", ex);
                return null;
            }
        }
コード例 #9
0
ファイル: Client.cs プロジェクト: chasedm/openscim
 public User getUserFromResponse(XmlNodeReader xmlNodeReader)
 {
     // deserialize the user message
     XmlSerializer deserializer = new XmlSerializer(typeof(User));
     User user = (User)deserializer.Deserialize(xmlNodeReader);
     return user;
 }
コード例 #10
0
        /// <summary>
        /// Executes the command logics.
        /// </summary>
        public override void Invoke()
        {
            //print request xml
            var doc = new XmlDocument();
            var stringWriter = new StringWriter();

            //get your document
            try
            {
                doc.LoadXml(this.document.Text);
            }
            catch (Exception)
            {
                return;
            }

            //create reader and writer
            var xmlReader = new XmlNodeReader(doc);

            //set formatting options
            var xmlWriter = new XmlTextWriter(stringWriter)
                                {
                                    Formatting = Formatting.Indented,
                                    Indentation = 3,
                                    IndentChar = ' '
                                };

            //write the document formatted
            xmlWriter.WriteNode(xmlReader, true);

            this.document.Text = stringWriter.ToString();
        }
コード例 #11
0
 private static void move_to_node( XmlNodeReader nodeReader, string nodeName )
 {
     while (( nodeReader.Read() ) && ( nodeReader.Name.Trim() != nodeName ))
     {
         // Do nothing here...
     }
 }
コード例 #12
0
ファイル: XmlPackage.cs プロジェクト: vbyte/fmq
 /// <summary>
 /// 从序列化的Xml文档中还原对象
 /// </summary>
 public XmlPackage(XmlDocument xmlDoc)
 {
     XmlNodeReader reader = new XmlNodeReader(xmlDoc.DocumentElement);
     XmlSerializer ser = new XmlSerializer(typeof(XmlPackage));
     XmlPackage pkg = (XmlPackage)ser.Deserialize(reader);
     this.SetPackageDictionary(pkg.GetPackageDictionary());
 }
コード例 #13
0
		public object Create(object parent, object configContext, XmlNode section)
		{
			ILog _log = null;
			try
			{
				_log = LogManager.GetLogger(typeof(XmlConfigurator));
			}
			catch{}

			object settings = null;
			if (section == null) 
				return settings;

			XmlSerializer xmlSerializer = new XmlSerializer(typeof(FluorineSettings));
			XmlNodeReader reader = new XmlNodeReader(section);
			try
			{
				settings = xmlSerializer.Deserialize(reader);
			}
			catch(Exception ex)
			{
				if( _log != null && _log.IsErrorEnabled )
					_log.Error(ex.Message, ex);
			}
			finally
			{
				xmlSerializer = null;
			}
			return settings;
		}
コード例 #14
0
        public object Create( object parent, object configContext, XmlNode section )
        {
            XPathNavigator navigator = section.CreateNavigator();
            string typeName = ( string )navigator.Evaluate( "string(@type)" );

            if( string.IsNullOrEmpty( typeName ) )
                throw new ConfigurationErrorsException( string.Format( MISSING_TYPE_MSG, section.Name ), section );

            Type type = Type.GetType( typeName );
            if( type == null )
                throw new ConfigurationErrorsException( string.Format( NULL_TYPE_MSG, typeName, section.Name ), section );

            XmlSerializer serializer = new XmlSerializer( type );
            XmlNodeReader reader = new XmlNodeReader( section );

            try
            {
                return serializer.Deserialize( reader );
            }
            catch( Exception ex )
            {
                throw new ConfigurationErrorsException(
                    string.Format( FAILED_DESERIALIZE_MSG, typeName, section.Name, FormattedInnerExceptions( ex ) ),
                    ex, section );
            }
        }
コード例 #15
0
        public static EvaluationEngine Create(XmlDocument policyDoc, IXacmlPolicyRepository ch) {
            Contract.Requires<ArgumentNullException>(policyDoc != null);

            using (XmlReader reader = new XmlNodeReader(policyDoc.DocumentElement)) {
                return EvaluationEngineFactory.Create(reader, ch);
            }
        }
コード例 #16
0
		public void BindData()
        {
            #region 绑定数据
            DataGrid1.AllowCustomPaging = false;
            DataGrid1.DataKeyField = "menuid";
			DataGrid1.TableHeaderName = "我的菜单列表";

            
		    DataSet dsSrc = new DataSet();
			XmlDocumentExtender xmldocument = new XmlDocumentExtender();
			xmldocument.Load(configPath);
			XmlNode node = xmldocument.SelectSingleNode("/menuset");
            if (node == null ||node.ChildNodes.Count == 0)
                return;
			XmlNodeReader rdr = new XmlNodeReader(node);
			dsSrc.ReadXml(rdr);
            dsSrc.Tables[0].Columns.Add("menuid");
            int i = 0;
            foreach (DataRow dr in dsSrc.Tables[0].Rows)
            {
                dr["menuid"] = i.ToString();
                i++;
            }
			DataGrid1.DataSource = dsSrc.Tables[0];
			DataGrid1.DataBind();
            #endregion
        }
コード例 #17
0
        public List<WpPost> GetPosts(WpImportOptions options)
        {
            Item mediaInnerItem = _db.GetItem(_mediaItemId);
            if (mediaInnerItem == null)
            {
                Logger.Error(String.Format("Media item for import could not be found (id: {0}, db: {1})", _mediaItemId, _db.Name));
                return new List<WpPost>(0);
            }
            MediaItem mediaItem = new MediaItem(mediaInnerItem);

            XmlDocument xmdDoc = new XmlDocument();
            var mediaStream = MediaManager.GetMedia(mediaItem).GetStream();
            if (mediaStream == null || mediaStream.MimeType != "text/xml")
            {
                Logger.Error(String.Format("MediaStream for imported item is null or uploaded file has is incorrect format (id: {0}, db: {1})", _mediaItemId, _db.Name));
                return new List<WpPost>(0);
            }

            xmdDoc.Load(mediaStream.Stream);
            using (var nodeReader = new XmlNodeReader(xmdDoc))
            {
                nodeReader.MoveToContent();
                var xDocument = XDocument.Load(nodeReader);

                var posts = (from item in xDocument.Descendants("item")
                             select new WpPost(item, options)).ToList();
                return posts;
            }
        }
コード例 #18
0
		public void BindData()
        {
            #region 绑定轮换图片列表
            DataGrid1.AllowCustomPaging = false;
			DataGrid1.DataKeyField = "rotatepicid";
            DataGrid1.TableHeaderName = "聚合轮换图片列表";

			XmlDocumentExtender xmldocument = new XmlDocumentExtender();
			xmldocument.Load(configPath);
			XmlNode node = xmldocument.SelectSingleNode(targetNode);
            if (node == null || node.ChildNodes.Count == 0)
            {
                DataGrid1.Visible = SaveRotatepic.Visible = false;
                return;
            }
			XmlNodeReader rdr = new XmlNodeReader(node);
			dsSrc.ReadXml(rdr);
            dsSrc.Tables[0].Columns.Add("rowid");
            int i = 0;
            foreach (DataRow dr in dsSrc.Tables[0].Rows)
            {
                dr["rowid"] = i.ToString();
                i++;
            }
			DataGrid1.DataSource = dsSrc.Tables[0];
			DataGrid1.DataBind();
            #endregion
        }
コード例 #19
0
 private static CassandraSharpConfig ReadConfig(XmlDocument xmlDoc)
 {
     XmlSerializer xmlSer = new XmlSerializer(typeof(CassandraSharpConfig));
     //MiniXmlSerializer xmlSer = new MiniXmlSerializer(typeof(CassandraSharpConfig));
     using (XmlReader xmlReader = new XmlNodeReader(xmlDoc))
         return (CassandraSharpConfig)xmlSer.Deserialize(xmlReader);
 }
コード例 #20
0
 private static Projects Deserialise(XmlDocument xmlDoc)
 {
     var nodeReader = new XmlNodeReader(xmlDoc);
     nodeReader.ReadToDescendant("Projects");
     var result = Serialiser.Deserialize(nodeReader);
     return (Projects)result;
 }
コード例 #21
0
        public static string PrettyPrint(XmlDocument xmlDoc)
        {
            if (xmlDoc == null)
            {
                return(null);
            }

            try
            {
                using (System.IO.StringWriter sw = new System.IO.StringWriter())
                {
                    System.Xml.XmlNodeReader xmlReader = new System.Xml.XmlNodeReader(xmlDoc);
                    System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(sw);
                    xmlWriter.Formatting  = System.Xml.Formatting.Indented;
                    xmlWriter.Indentation = 4;
                    xmlWriter.IndentChar  = ' ';
                    xmlWriter.WriteNode(xmlReader, true);
                    return(sw.ToString());
                }
            }
            catch (Exception)
            {
                // just return as-is
                return(xmlDoc.OuterXml);
            }
        }
コード例 #22
0
        public static void fillCountry(ComboBox objCmbCountry,String CountryCode)
        {
            //DataTable objDT = new DataTable("Country");
            //DataRow objRow;
            //DataColumn objcol =new DataColumn("ContryName",typeof(System.String));
            //objDT.Columns.Add(objcol);

            //objcol =new DataColumn("ContryId",typeof(System.String));
            //objDT.Columns.Add(objcol);

            XmlNodeReader objXmlReader;
            DataSet ds = new DataSet();
            XmlDocument  objOutXml = new XmlDocument();
            String strInput = "<MS_LISTCOUNTRY_OUTPUT><COUNTRY  COUNTRY_CODE='0' COUNTRY_NAME='Select one'/><COUNTRY  COUNTRY_CODE='BD' COUNTRY_NAME='Bangladesh'/><COUNTRY  COUNTRY_CODE='IN' COUNTRY_NAME='India' /><COUNTRY  COUNTRY_CODE='NP' COUNTRY_NAME='Nepal' /> <COUNTRY  COUNTRY_CODE='LK' COUNTRY_NAME='Srilanka' /><COUNTRY  COUNTRY_CODE='BT' COUNTRY_NAME='Bhutan' /><COUNTRY  COUNTRY_CODE='ML' COUNTRY_NAME='Maldives' /><COUNTRY  COUNTRY_CODE='TB' COUNTRY_NAME='TBA' /> <Errors Status='False'><Error Code='' Description='' /></Errors></MS_LISTCOUNTRY_OUTPUT>";
            objOutXml.LoadXml(strInput);

            objXmlReader = new XmlNodeReader(objOutXml);
            ds.ReadXml(objXmlReader);
            objCmbCountry.DataSource = ds.Tables["COUNTRY"];
            objCmbCountry.DisplayMember = "COUNTRY_NAME";
            objCmbCountry.ValueMember = "COUNTRY_CODE";
            objCmbCountry.SelectedIndex = 0;
            if (CountryCode !="")
            {
                objCmbCountry.SelectedIndex = objCmbCountry.FindString("India");
            }
        }
コード例 #23
0
ファイル: Client.cs プロジェクト: chasedm/openscim
 public Error getErrorFromResponse(XmlNodeReader xmlNodeReader)
 {
     // deserialize the error message
     XmlSerializer deserializer = new XmlSerializer(typeof(Error));
     Error error = (Error)deserializer.Deserialize(xmlNodeReader);
     return error;
 }
コード例 #24
0
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ�
 public bool isSuper(FileInfo obFile, FileInfo obExtends)
 {
     string infoPath = m_obFinder.getClassPath(obExtends.Name.Replace(".as", ""));
     if (File.Exists(infoPath))
     {
         XmlDocument xml = new XmlDocument();
         xml.Load(infoPath);
         XmlNodeReader reader = new XmlNodeReader(xml);
         while (reader.Read())
         {
             if (reader.NodeType == XmlNodeType.Element)
             {
                 if (reader.Name == "item")
                 {
                     string className = reader.GetAttribute("name");
                     string superSign = reader.GetAttribute("super");
                     if (className == obFile.Name.Replace(".as", ""))
                     {
                         if (superSign != null)
                         {
                             reader.Close();
                             //ErrorBox.Show(obExtends.Name + " extends " + obFile.Name,"ClassRelationsFinderError");
                             return true;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
コード例 #25
0
ファイル: XMLService.cs プロジェクト: dizzydezz/jmm
		public static AniDB_FileRequest Get_AniDB_File(string hash, long filesize)
		{
			// turn this off for now until the bugs are sorted out
			return null;

			if (!ServerSettings.WebCache_AniDB_File_Get) return null;

			try
			{

				string uri = string.Format("http://{0}/GetAniDB_File.aspx?hash={1}&fsize={2}",
					ServerSettings.WebCache_Address, hash, filesize);
				string xml = GetData(uri);

				if (xml.Trim().Length == 0) return null;

				XmlSerializer serializer = new XmlSerializer(typeof(AniDB_FileRequest));
				XmlDocument docSearchResult = new XmlDocument();
				docSearchResult.LoadXml(xml);

				XmlNodeReader reader = new XmlNodeReader(docSearchResult.DocumentElement);
				object obj = serializer.Deserialize(reader);
				return (AniDB_FileRequest)obj;

			}
			catch (Exception ex)
			{
				logger.ErrorException("Error in XMLService.Get_FileHash:: {0}", ex);
				return null;
			}
		}
コード例 #26
0
        /// <remarks>Internal for testing.</remarks>
        internal static void RetargetWithMetadataConverter(XDocument xdoc, Version targetSchemaVersion, MetadataConverterDriver converter)
        {
            Debug.Assert(xdoc != null, "xdoc != null");
            Debug.Assert(EntityFrameworkVersion.IsValidVersion(targetSchemaVersion), "invalid target schema version");

            var inputXml = new XmlDocument { PreserveWhitespace = true };
            using (var reader = xdoc.CreateReader())
            {
                inputXml.Load(reader);
            }

            var outputXml = converter.Convert(inputXml, targetSchemaVersion);
            if (outputXml != null)
            {
                // Dev10 Bug 550594: There is a bug in XmlEditor that prevents from deleting the root node
                // unless the root node has previous sibling (like a comment or Xml declaration).
                if (xdoc.Root.PreviousNode == null)
                {
                    xdoc.Root.AddBeforeSelf(new XComment(""));
                }

                // update xml document with new root element
                xdoc.Root.Remove();
                using (var reader = new XmlNodeReader(outputXml))
                {
                    var newDoc = XDocument.Load(reader);
                    xdoc.Add(newDoc.Root);
                }

                // Do not reload artifact here
                // Until the transaction is commited, the XLinq representation of the parsed xml tree hasn't been generated yet.
            }
        }
コード例 #27
0
 public static XDocument ToXDocument(this XmlDocument xmlDocument)
 {
     using (var nodeReader = new XmlNodeReader(xmlDocument)) {
         nodeReader.MoveToContent();
         return XDocument.Load(nodeReader);
     }
 }
コード例 #28
0
    private string SerializeXmlNode(XmlNode node)
    {
      string json = JsonConvert.SerializeXmlNode(node, Formatting.Indented);
      XmlNodeReader reader = new XmlNodeReader(node);

#if !NET20
      XObject xNode;
      if (node is XmlDocument)
      {
        xNode = XDocument.Load(reader);
      }
      else if (node is XmlAttribute)
      {
        XmlAttribute attribute = (XmlAttribute) node;
        xNode = new XAttribute(XName.Get(attribute.LocalName, attribute.NamespaceURI), attribute.Value);
      }
      else
      {
        reader.MoveToContent();
        xNode = XNode.ReadFrom(reader);
      }

      string linqJson = JsonConvert.SerializeXNode(xNode, Formatting.Indented);

      Assert.AreEqual(json, linqJson);
#endif

      return json;
    }
コード例 #29
0
    public void PerformXmlRoundTrip(string xml)
    {
      var doc = new XmlDocument();

      using (var str = new StringReader(xml))
      using (var reader = XmlReader.Create(str))
      using (var writer = new XmlNodeWriter(doc))
      {
        writer.WriteNode(reader, false);
      }

      var settings = new XmlWriterSettings()
      {
        Indent = true,
        IndentChars = "  ",
        OmitXmlDeclaration = true
      };

      using (var reader = new XmlNodeReader(doc))
      using (var str = new StringWriter())
      using (var writer = XmlWriter.Create(str, settings))
      {
        writer.WriteNode(reader, false);
        writer.Flush();
        str.Flush();
        Assert.AreEqual(xml, str.ToString());
      }
    }
コード例 #30
0
ファイル: XmlConfigurator.cs プロジェクト: BrianGoff/BITS
		public Object Create(
			Object parent,
			Object configContext,
			System.Xml.XmlNode section)
		{
			Object settings = null;
			if (section == null)
				return settings;

			XPathNavigator nav = section.CreateNavigator();
			String typeName = (String) nav.Evaluate("string(@type)");
			Type sectionType = Type.GetType(typeName);

			XmlSerializer s = new XmlSerializer(sectionType);
			XmlNodeReader r = new XmlNodeReader(section);

			try
			{
				settings = s.Deserialize(r);
			}
			catch (Exception e)
			{

				if ( e.InnerException != null )
					Debug.WriteLine( String.Format("exception:\n{0}\n{1}", e.Message, e.InnerException.Message ) );
				else
					Debug.WriteLine( String.Format("exception:\n{0}", e.Message ) );
			}
			finally
			{
				s = null;
			}

			return settings;
		}
コード例 #31
0
        /// <summary>
        /// Ensures the notification types data have been intialized.
        /// </summary>
        private static void EnsureInitialized()
        {
            if (s_isLoaded)
                return;

            // Read the resource file
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(Properties.Resources.NotificationRefTypeIDs);
            
            // Read the nodes
            using (XmlNodeReader reader = new XmlNodeReader(xmlDoc))
            {
                // Create a memory stream to transform the xml 
                using (MemoryStream stream = new MemoryStream())
                {
                    // Write the xml output to the stream
                    using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8))
                    {
                        // Apply the XSL transform
                        XslCompiledTransform transform = Util.LoadXSLT(Properties.Resources.RowsetsXSLT);
                        writer.Formatting = Formatting.Indented;
                        transform.Transform(reader, writer);
                        writer.Flush();

                        // Deserialize from the given stream
                        stream.Seek(0, SeekOrigin.Begin);
                        XmlSerializer xs = new XmlSerializer(typeof(SerializableNotificationRefTypeIDs));
                        s_notificationTypes = (SerializableNotificationRefTypeIDs)xs.Deserialize(stream);
                    }
                }
            }

            s_isLoaded = true;
        }
コード例 #32
0
        private void process_constants( XmlNodeReader nodeReader, CompleteTemplate ThisCompleteTemplate )
        {
            // Read all the nodes
            while ( nodeReader.Read() )
            {
                // Get the node name, trimmed and to upper
                string nodeName = nodeReader.Name.Trim().ToUpper();

                // If this is the inputs or constant start tag, return
                if (( nodeReader.NodeType == XmlNodeType.EndElement ) && ( nodeName == "CONSTANTS" ))
                {
                    return;
                }

                // If this is the beginning tag for an element, assign the next values accordingly
                if (( nodeReader.NodeType == XmlNodeType.Element ) && ( nodeName == "ELEMENT" ) && ( nodeReader.HasAttributes ))
                {
                    abstract_Element newConstant = process_element( nodeReader, -1 );
                    if (newConstant != null)
                    {
                        newConstant.isConstant = true;
                        ThisCompleteTemplate.Add_Constant(newConstant);
                    }
                }
            }
        }
コード例 #33
0
        /// <summary>
        /// 判断是否为WIN7 以及32或64位
        /// </summary>
        /// <param name="imagex">imagex文件名,默认传imagex字段</param>
        /// <param name="wimfile">WIM文件路径</param>
        /// <returns>不是WIN7系统:0,Windows 7 STARTER(表示为32位系统镜像):1,Windows 7 HOMEBASIC(表示为64位系统镜像):2</returns>
        public static int Iswin7(string imagex, string wimfile)
        {
            ProcessManager.SyncCMD("\"" + WTGModel.applicationFilesPath + "\\" + imagex + "\"" + " /info \"" + wimfile + "\" /xml > " + "\"" + WTGModel.logPath + "\\wiminfo.xml\"");
            XmlDocument xml = new XmlDocument();

            System.Xml.XmlDocument   doc    = new System.Xml.XmlDocument();
            System.Xml.XmlNodeReader reader = null;

            string strFilename = WTGModel.logPath + "\\wiminfo.xml";

            if (!File.Exists(strFilename))
            {
                //MsgManager.getResString("Msg_wiminfoerror")
                //WIM文件信息获取失败\n将按WIN8系统安装
                Log.WriteLog("Iswin7.log", strFilename + "文件不存在");
                //MessageBox.Show(strFilename + MsgManager.getResString("Msg_wiminfoerror", MsgManager.ci));
                return(0);
            }
            try
            {
                doc.Load(strFilename);
                reader = new System.Xml.XmlNodeReader(doc);
                while (reader.Read())
                {
                    if (reader.IsStartElement("NAME"))
                    {
                        //从找到的这个依次往下读取节点
                        System.Xml.XmlNode aa = doc.ReadNode(reader);
                        if (aa.InnerText == "Windows 7 STARTER")
                        {
                            return(1);
                        }
                        else if (aa.InnerText == "Windows 7 HOMEBASIC")
                        {
                            return(2);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Log.WriteLog("Iswin7.log", strFilename + "\n" + ex.ToString());
                //MessageBox.Show(strFilename + MsgManager.getResString("Msg_wiminfoerror", MsgManager.ci) + ex.ToString());
                return(0);
            }



            return(0);
        }
コード例 #34
0
ファイル: Form1.cs プロジェクト: GPiter/C-Sharp-Courses
        private void BtnGetWeather_Click(object sender, EventArgs e)
        {
            try
            {
                // Используем веб сервис для получения погоды
                var weather = new com.cobbnz.weather.clsWebService();
                // Записываем результат запроса в формат xml
                var str_xml = weather.GetCurrentConditionsAsXML("Saint-Petersburg");
                // Отображаем xml-формат в поле textbox
                tbWeatherInfo.Text = str_xml.ToString();

                // Десериализация полученного xml
                // Создаем объкект типа "XmlDocument"
                var document = new System.Xml.XmlDocument();
                document.LoadXml(str_xml);

                // Создаем объект типа "Чтение узлов xml"
                var reader = new System.Xml.XmlNodeReader(document);
                var name   = String.Empty;
                var temp   = String.Empty;

                // Цикл по узлам xml-документа
                while (reader.Read() == true)
                {
                    // Читаем последовательно каждый узел, выясняя тип узла
                    if (reader.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        name = reader.Name;
                    }

                    // Каждый раз запоминаем имя узла
                    if (reader.NodeType != System.Xml.XmlNodeType.Text)
                    {
                        continue;
                    }

                    // Выход из цикла, когда прочитали данные узла TemperatureCurrent
                    if (name == "TemperatureCurrent")
                    {
                        temp = reader.Value;
                        break;
                    }
                }

                lblCurrentTemp.Text = "Температура: " + temp + " С";
            }

            catch
            {
                MessageBox.Show("Ошибка подключения к веб-службе!", "Внимание!");
            }
        }
コード例 #35
0
ファイル: SEI2Helper.cs プロジェクト: openmedicus/SEI2
        private static T DeserializeBody <T>(XmlNode bodyNode) where T : class
        {
            T contract;
            DataContractSerializer serializer = new DataContractSerializer(typeof(T));

            using (XmlNodeReader reader = new System.Xml.XmlNodeReader(bodyNode))
            {
                contract = serializer.ReadObject(reader) as T;
            }
            if (contract == null)
            {
                Console.WriteLine("Could not deserialize as " + typeof(T).ToString());
            }
            return(contract);
        }
コード例 #36
0
 public virtual XmlConfigElt ValueAt(string xPath)
 {
     if (XmlDoc == null)
     {
         return(new XmlConfigElt(xPath, null));
     }
     lock (typeof(XmlConfig)) {
         System.Xml.XmlNode node = XmlDoc.SelectSingleNode(xPath);
         if (node == null)
         {
             return(new XmlConfigElt(xPath, null));
         }
         System.Xml.XmlNodeReader nodeReader = new System.Xml.XmlNodeReader(node);
         nodeReader.Read();
         return(new XmlConfigElt(xPath, nodeReader.ReadElementString()));
     }
 }
コード例 #37
0
        object IConfigurationSectionHandler.Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            // Separa id do servico do tipo do servico
            string[] temp1   = section.Name.Split('-');
            string   tipoStr = temp1[0];

            // Cria o tipo
            Type tipo = null;

            Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly assembly in assemblies)
            {
                tipo = assembly.GetType(tipoStr);
                if (tipo != null)
                {
                    break;
                }
            }

            if (tipo == null)
            {
                logger.Error("Configuration Handler nao encontrado para " + tipoStr);
                return(null);
            }

            // Cria o serializador do tipo
            XmlSerializer serializer =
                new XmlSerializer(tipo);

            // Duplica a estrutura para poder passar para o desserializador
            string nodeName = tipoStr.Replace(tipo.Namespace + ".", "");

            XmlNode node = section.OwnerDocument.CreateElement(nodeName);

            foreach (XmlNode childNode in section.ChildNodes)
            {
                node.AppendChild(childNode.Clone());
            }

            // Desserializa
            System.Xml.XmlNodeReader reader = new System.Xml.XmlNodeReader(node);
            object info = serializer.Deserialize(reader);

            // Retorna
            return(info);
        }
コード例 #38
0
ファイル: FloatElement.cs プロジェクト: scaperow/-V2.0
        public override void DeserializeShapeProps(System.Xml.XmlNodeReader r)
        {
            XmlDocument document = new XmlDocument();

            r.MoveToElement();
            XmlNode       node   = document.ReadNode(r);
            XmlNodeReader reader = new XmlNodeReader(node);

            base.DeserializeShapeProps(r);

            bool flag  = true;
            bool flag1 = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;
            bool flag5 = false;
            bool flag6 = false;

Label_1:
            if (flag)
            {
                if (!reader.Read())
                {
                    return;
                }
            }
            else
            {
                flag = true;
            }
            switch (reader.NodeType)
            {
            case XmlNodeType.Element:
                if (reader.Name.Equals("Name"))
                {
                    flag1 = true;
                }
                else if (reader.Name.Equals("Row"))
                {
                    flag2 = true;
                }
                else if (reader.Name.Equals("Column"))
                {
                    flag3 = true;
                }
                else if (reader.Name.Equals("LeftDistance"))
                {
                    flag4 = true;
                }
                else if (reader.Name.Equals("TopDistance"))
                {
                    flag5 = true;
                }
                else if (reader.Name.Equals("Value"))
                {
                    flag6 = true;
                }
                goto Label_1;

            case XmlNodeType.Text:
                if (flag1)
                {
                    this.name = reader.Value;
                }
                else if (flag2)
                {
                    this.row = Convert.ToInt32(reader.Value);
                }
                else if (flag3)
                {
                    this.column = Convert.ToInt32(reader.Value);
                }
                else if (flag4)
                {
                    this.leftDistance = Convert.ToInt32(reader.Value);
                }
                else if (flag5)
                {
                    this.topDistance = Convert.ToInt32(reader.Value);
                }
                else if (flag6)
                {
                    this.value = BinarySerializer.Deserialize(reader.Value);
                }
                goto Label_1;

            case XmlNodeType.EndElement:
                if (flag1 && reader.Name.Equals("Name"))
                {
                    flag1 = false;
                }
                else if (flag2 && reader.Name.Equals("Row"))
                {
                    flag2 = false;
                }
                else if (flag3 && reader.Name.Equals("Column"))
                {
                    flag3 = false;
                }
                else if (flag4 && reader.Name.Equals("LeftDistance"))
                {
                    flag4 = false;
                }
                else if (flag5 && reader.Name.Equals("TopDistance"))
                {
                    flag5 = false;
                }
                else if (flag6 && reader.Name.Equals("Value"))
                {
                    flag6 = false;
                }
                goto Label_1;
            }
        }
コード例 #39
0
ファイル: Form1.cs プロジェクト: xpoi5010/TimeTable
        //Add:1.0.1.0
        public EventInfo[] LoadXML(string path)
        {
            System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
            SavePath = path;
            xd.Load(SavePath);
            System.Xml.XmlNodeReader xnr = new System.Xml.XmlNodeReader(xd);
            string           Time        = "";
            string           element     = "";
            bool             IsEvent     = false;
            EventInfo        temp        = new EventInfo();
            string           start       = "";
            string           week        = "";
            List <EventInfo> output      = new List <EventInfo>();

            while (xnr.Read())
            {
                switch (xnr.NodeType)
                {
                case (XmlNodeType.Element):
                    element = xnr.Name;
                    switch (element)
                    {
                    case ("Timetable"):
                        start = xnr.GetAttribute("start");
                        string[] split = System.Text.RegularExpressions.Regex.Split(start, ",");
                        dateSelecter1.Year  = Convert.ToInt32(split[0]);
                        dateSelecter1.Month = Convert.ToInt32(split[1]);
                        dateSelecter1.Day   = Convert.ToInt32(split[2]);
                        break;

                    case ("Event"):
                        IsEvent = true;
                        week    = "";
                        start   = "";
                        temp    = new EventInfo();
                        break;

                    case ("Time"):
                        Time = xnr.GetAttribute("time");
                        break;

                    case ("Repeat"):
                        week = xnr.GetAttribute("week");

                        break;
                    }
                    break;

                case (XmlNodeType.Text):
                    if (IsEvent)
                    {
                        if (element == "Name")
                        {
                            temp.starttime = new Time(Time);
                            temp.EventName = xnr.Value;
                        }
                        else if (element == "Repeat")
                        {
                            string[] Split = System.Text.RegularExpressions.Regex.Split(xnr.Value, ":");
                            int[]    w_    = Array.ConvertAll(Split, item => Convert.ToInt32(item));
                            if (week == "" || week == null)
                            {
                                temp.Repeat_OneWeek  = w_;
                                temp.Repeat_Biweekly = temp.Repeat_OneWeek;
                            }
                            if (week == "1")
                            {
                                temp.Repeat_OneWeek = w_;
                            }
                            if (week == "2")
                            {
                                temp.Repeat_Biweekly = w_;
                            }
                        }
                    }
                    break;

                case (XmlNodeType.EndElement):
                    switch (xnr.Name)
                    {
                    case ("Event"):
                        IsEvent = false;
                        output.Add(temp);
                        temp = new EventInfo();
                        break;
                    }
                    break;
                }
            }
            xnr.Close();
            return(output.ToArray());
        }