コード例 #1
0
        /// <summary>
        /// Causes the configuration system to throw an exception.
        /// </summary>
        /// <returns>
        /// true if the unrecognized element was deserialized successfully; otherwise, false. The default is false.
        /// </returns>
        /// <param name="elementName">The name of the unrecognized element. </param>
        /// <param name="reader">An input stream that reads XML from the configuration file. </param>
        /// <exception cref="T:System.Configuration.ConfigurationErrorsException">The element specified in <paramref name="elementName"/> is the &lt;clear&gt; element.</exception>
        /// <exception cref="T:System.ArgumentException"><paramref name="elementName"/> starts with the reserved prefix "config" or "lock".</exception>
        protected override bool OnDeserializeUnrecognizedElement(string elementName, System.Xml.XmlReader reader)
        {
            var holder = new DeserializedElementHolder();
            var helper = new ValueElementHelper(holder);

            if (helper.DeserializeUnknownElement(elementName, reader))
            {
                this.Add(holder.Value);
                return(true);
            }

            return(base.OnDeserializeUnrecognizedElement(elementName, reader));
        }
コード例 #2
0
 /// <summary>
 /// Gets a value indicating whether an unknown element is encountered during deserialization.
 /// </summary>
 /// <returns>
 /// true when an unknown element is encountered while deserializing; otherwise, false.
 /// </returns>
 /// <param name="elementName">The name of the unknown subelement.
 ///                 </param><param name="reader">The <see cref="T:System.Xml.XmlReader"/> being used for deserialization.
 ///                 </param><exception cref="T:System.Configuration.ConfigurationErrorsException">The element identified by <paramref name="elementName"/> is locked.
 ///                     - or -
 ///                     One or more of the element's attributes is locked.
 ///                     - or -
 ///                 <paramref name="elementName"/> is unrecognized, or the element has an unrecognized attribute.
 ///                     - or -
 ///                     The element has a Boolean attribute with an invalid value.
 ///                     - or -
 ///                     An attempt was made to deserialize a property more than once.
 ///                     - or -
 ///                     An attempt was made to deserialize a property that is not a valid member of the element.
 ///                     - or -
 ///                     The element cannot contain a CDATA or text element.
 ///                 </exception>
 protected override bool OnDeserializeUnrecognizedElement(string elementName, XmlReader reader)
 {
     return(valueElementHelper.DeserializeUnknownElement(elementName, reader) ||
            base.OnDeserializeUnrecognizedElement(elementName, reader));
 }