當前位置: 首頁>>代碼示例>>C#>>正文


C# Xml.XmlReader類代碼示例

本文整理匯總了C#中System.Xml.XmlReader的典型用法代碼示例。如果您正苦於以下問題:C# XmlReader類的具體用法?C# XmlReader怎麽用?C# XmlReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlReader類屬於System.Xml命名空間,在下文中一共展示了XmlReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Transform

    /// <summary>
    /// Applies the transformation from the reader to the writer
    /// </summary>
    /// <param name="reader"></param>
    /// <param name="writer"></param>
    public void Transform(XmlReader reader, XmlWriter writer) {
      Contract.Requires(reader != null);
      Contract.Requires(writer != null);

      while (reader.Read())
        this.WriteNodeSingle(reader, writer);
    }
開發者ID:asvishnyakov,項目名稱:CodeContracts,代碼行數:12,代碼來源:XmlTraverserBase.cs

示例2: while

 void IFlickrParsable.Load(XmlReader reader)
 {
     while (reader.MoveToNextAttribute())
     {
         switch (reader.LocalName)
         {
             case "id":
                 PhotoId = reader.Value;
                 break;
             case "ispublic":
                 IsPublic = reader.Value == "1";
                 break;
             case "iscontact":
                 IsContact = reader.Value == "1";
                 break;
             case "isfamily":
                 IsFamily = reader.Value == "1";
                 break;
             case "isfriend":
                 IsFriend = reader.Value == "1";
                 break;
         }
     }
     reader.Read();
 }
開發者ID:ghostnguyen,項目名稱:f503cd14-7a08-48cb-a2b6-d607c618743e,代碼行數:25,代碼來源:GeoPermissions.cs

示例3: DeserializeNetwork

        public override void DeserializeNetwork(XmlReader xmlReader)
        {
            base.DeserializeNetwork(xmlReader);

            var expander = ControlElements[0] as SliderExpanderDouble;
            if (expander == null) return;

            var attribute = xmlReader.GetAttribute("SliderMax");
            if (attribute != null)
                expander.SliderMax = Convert.ToDouble(attribute.Replace(".", ","));

            var attribute1 = xmlReader.GetAttribute("SliderMin");
            if (attribute1 != null)
                expander.SliderMin  = Convert.ToDouble(attribute1.Replace(".", ","));

            var attribute2 = xmlReader.GetAttribute("SliderValue");
            if (attribute2 != null)
                expander.SliderValue = Convert.ToDouble(attribute2.Replace(".", ","));

            var attribute3 = xmlReader.GetAttribute("SliderStep");
            if (attribute3 != null)
                expander.SliderStep = Convert.ToDouble(attribute3.Replace(".", ","));

            var attribute4 = xmlReader.GetAttribute("IsExpanded");
            if (attribute4 != null)
                expander.IsExpanded = Convert.ToBoolean(attribute4.Replace(".", ","));
        }
開發者ID:aquarius20th,項目名稱:CSharp_TUM.CMS.VPLControl,代碼行數:27,代碼來源:DoubleSlider.cs

示例4: TokenizeFromXml

 public object TokenizeFromXml(XmlReader reader)
 {
     reader.ReadStartElement();
     Geometry geometry = GmlFormatter.Create().Read<Geometry>(reader);
     reader.SkipInsignificantNodes();
     return geometry;
 }
開發者ID:nickchal,項目名稱:pash,代碼行數:7,代碼來源:GeometryTypeConverter.cs

示例5: ReadTokenCore

        protected override System.IdentityModel.Tokens.SecurityToken ReadTokenCore( XmlReader reader, SecurityTokenResolver tokenResolver )
        {
            if ( reader == null )
                throw new ArgumentNullException( "reader" );

            if ( reader.IsStartElement( Constants.UsernameTokenName, Constants.UsernameTokenNamespace ) )
            {
                //string id = reader.GetAttribute( Constants.IdAttributeName, Constants.WsUtilityNamespace );

                reader.ReadStartElement();

                // read the user name
                string userName = reader.ReadElementString( Constants.UsernameElementName, Constants.UsernameTokenNamespace );

                // read the password hash
                string password = reader.ReadElementString( Constants.PasswordElementName, Constants.UsernameTokenNamespace );

                // read nonce
                string nonce = reader.ReadElementString( Constants.NonceElementName, Constants.UsernameTokenNamespace );

                // read created
                string created = reader.ReadElementString( Constants.CreatedElementName, Constants.WsUtilityNamespace );

                reader.ReadEndElement();

                var info = new Info( userName, password );

                return new SecurityToken( info, nonce, created );
            }

            return DefaultInstance.ReadToken( reader, tokenResolver );
        }
開發者ID:Sn3b,項目名稱:Omniture-API,代碼行數:32,代碼來源:SecurityTokenSerializer.cs

示例6: ReadFromXml

        public void ReadFromXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) { reader.Read(); return; }

            num = int.Parse(reader.GetAttribute("number"));

            reader.Read();
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "class")
                    {
                        var sClass = new ScheduleClass();
                        sClass.ReadFromXml(reader);
                        classes.Add(sClass);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                else
                {
                    reader.Read();
                    break;
                }
            }
        }
開發者ID:GorelH,項目名稱:schedule-metro,代碼行數:30,代碼來源:ScheduleWeekday.cs

示例7: DoDeserializeValue

 protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue)
 {
   reader.ReadStartElement(); // Read start of enclosing element
   IFilter result = MediaItemQuery.DeserializeFilter(reader);
   reader.ReadEndElement(); // End of enclosing element
   return result;
 }
開發者ID:joconno4,項目名稱:MediaPortal-2,代碼行數:7,代碼來源:UPnPDtMediaItemsFilter.cs

示例8: HandleTypeAttribute

        protected void HandleTypeAttribute(XmlReader reader)
        {
            DebugCheck.NotNull(reader);

            string type;
            if (!Utils.GetString(Schema, reader, out type))
            {
                return;
            }

            TypeModifier typeModifier;
            Function.RemoveTypeModifier(ref type, out typeModifier, out _isRefType);

            switch (typeModifier)
            {
                case TypeModifier.Array:
                    _collectionKind = CollectionKind.Bag;
                    break;
                default:
                    Debug.Assert(
                        typeModifier == TypeModifier.None,
                        string.Format(
                            CultureInfo.CurrentCulture,
                            "Type is not valid for property {0}: {1}. The modifier for the type cannot be used in this context.", FQName,
                            reader.Value));
                    break;
            }

            if (!Utils.ValidateDottedName(Schema, reader, type))
            {
                return;
            }

            _unresolvedType = type;
        }
開發者ID:Cireson,項目名稱:EntityFramework6,代碼行數:35,代碼來源:RowTypePropertyElement.cs

示例9: DeserializePropertyElement

        protected override void DeserializePropertyElement(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException ("reader");

            if (reader.NamespaceURI == Schemas.UpnpSchema) {
                switch (reader.LocalName) {
                case "producer":
                    producer_list.Add (reader.ReadString ());
                    break;
                default:
                    base.DeserializePropertyElement (reader);
                    break;
                }
            } else if (reader.NamespaceURI == Schemas.DublinCoreSchema) {
                switch (reader.LocalName) {
                case "contributor":
                    contributor_list.Add (reader.ReadString ());
                    break;
                case "date":
                    Date = reader.ReadString ();
                    break;
                default:
                    base.DeserializePropertyElement (reader);
                    break;
                }
            } else {
                base.DeserializePropertyElement (reader);
            }
        }
開發者ID:MustafaUzumcuCom,項目名稱:mono-upnp,代碼行數:29,代碼來源:AudioBook.cs

示例10: XmlDecoder

        /// <summary>
        /// Initializes the object with a XML reader.
        /// </summary>
        public XmlDecoder(System.Type systemType, XmlReader reader, ServiceMessageContext context)
        {
            Initialize();

            m_reader  = reader;
            m_context = context;

            string ns = null;
            string name = null;

            if (systemType != null)
            {
                XmlQualifiedName typeName = EncodeableFactory.GetXmlName(systemType);
                ns = typeName.Namespace;
                name = typeName.Name;
            }

            if (ns == null)
            {
                m_reader.MoveToContent();
                ns = m_reader.NamespaceURI;
                name = m_reader.Name;
            }

            int index = name.IndexOf(':');

            if (index != -1)
            {
                name = name.Substring(index + 1);
            }

            PushNamespace(ns);
            BeginField(name, false);
        }      
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:37,代碼來源:XmlDecoder.cs

示例11: FromXml

        public bool FromXml(XmlReader reader)
        {
            if (reader == null || reader.Name != "Lib")
            {
                return false;
            }

            if (reader.Name == "Order" || reader.ReadToDescendant("Order"))
            {
                Order = reader.ReadElementContentAsInt();
            }
            if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
            {
                Id = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
            {
                Name = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Text" || reader.ReadToNextSibling("Text"))
            {
                Text = reader.ReadElementContentAsString();
            }
            if (reader.Name == "Memo" || reader.ReadToNextSibling("Memo"))
            {
                Memo = reader.ReadElementContentAsString();
            }
            return true;
        }
開發者ID:burstas,項目名稱:rmps,代碼行數:29,代碼來源:LibHeader.cs

示例12: while

        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "referrer")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "url":
                        Url = reader.Value;
                        break;
                    case "searchterm":
                        SearchTerm = reader.Value;
                        break;
                    case "views":
                        Views = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Skip();
        }
開發者ID:JamieKitson,項目名稱:flickrnet-experimental,代碼行數:26,代碼來源:StatReferrer.cs

示例13: OrnamentsForm

 public OrnamentsForm(XmlReader r, PaletteForm paletteForm, IPaletteFormsHostForm acForm, FormStateFunctions fsf)
 {
     _isLoading = true;
     InitializeOrnamentSettingsForm(r, paletteForm, acForm, fsf);
     _fsf.SetSettingsAreSaved(this, M.HasError(_allTextBoxes), ConfirmButton, RevertToSavedButton);
     _isLoading = false;
 }
開發者ID:suvjunmd,項目名稱:Moritz,代碼行數:7,代碼來源:OrnamentsForm.cs

示例14: PolicyIdReferenceElementReadWrite

		/// <summary>
		/// Creates a new PolicyIdReference using the XmlReader instance provided.
		/// </summary>
		/// <param name="reader">The XmlReader positioned at the PolicyIdReference element.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public PolicyIdReferenceElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
			: base( XacmlSchema.Policy, schemaVersion )
		{
            if (reader == null) throw new ArgumentNullException("reader");
			if( reader.LocalName == PolicySchema1.PolicyIdReferenceElement.PolicyIdReference && 
				ValidateSchema( reader, schemaVersion ) )
			{
				if( reader.HasAttributes )
				{
					// Load all the attributes
					while( reader.MoveToNextAttribute() )
					{
						if( reader.LocalName == PolicyReferenceElement.Version )
						{
							_version = reader.GetAttribute( PolicyReferenceElement.Version );
						}
						else if( reader.LocalName == PolicyReferenceElement.EarliestVersion )
						{
							_earliestVersion = reader.GetAttribute( PolicyReferenceElement.EarliestVersion );
						}
						else if( reader.LocalName == PolicyReferenceElement.LatestVersion )
						{
							_latestVersion = reader.GetAttribute( PolicyReferenceElement.LatestVersion );
						}					
					}
					reader.MoveToElement();
				}
				_policyIdReference = reader.ReadElementString();
			}
			else
			{
				throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
			}
		}
開發者ID:Condeti,項目名稱:XACML.NET,代碼行數:39,代碼來源:PolicyIdReferenceElementReadWrite.cs

示例15: ReadXml

        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);
            if (x.Root == null) return;

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                    case "List":
                        foreach (var ee in e.Elements())
                            _list.Add(Util.DeSerialize<OnlineRegPersonModel>(ee.ToString()));
                        break;
                    case "History":
                        foreach (var ee in e.Elements())
                            _history.Add(ee.Value);
                        break;
                    default:
                        Util.SetPropertyFromText(this, name, e.Value);
                        break;
                }
            }
        }
開發者ID:stevesloka,項目名稱:bvcms,代碼行數:25,代碼來源:ReadWriteXml.cs


注:本文中的System.Xml.XmlReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。