示例#1
0
        /// <summary>Applies properties from the reader to the specified resource.</summary>
        /// <param name="deserializer">Deserializer which is driving the <paramref name="reader"/>.</param>
        /// <param name='reader'>XmlReader to read from.</param>
        /// <param name='resourceType'>Type of resource.</param>
        /// <param name='resource'>Resource to set value on.</param>
        /// <param name="propertiesApplied">Properties already applied based on content</param>
        /// <param name="currentObjectCount">current object count for this operation.</param>
        /// <remarks>
        /// This method will end as soon as it find something that is not an
        /// XML element to process.
        /// </remarks>
        internal static void ApplyContent(Deserializer deserializer, XmlReader reader, ResourceType resourceType, object resource, EpmContentDeSerializer.EpmAppliedPropertyInfo propertiesApplied, int currentObjectCount)
        {
            Debug.Assert(deserializer != null, "deserializer != null");
            Debug.Assert(reader != null, "reader != null");
            using (PlainXmlDeserializer xml = new PlainXmlDeserializer(reader, deserializer, propertiesApplied))
            {
                // Initialize the new deserializer instance with the current object count
                xml.UpdateObjectCount(currentObjectCount);

                // load all the properties
                xml.ApplyContent(xml.xmlReader, resourceType, resource);

                // After all the properties have been loaded, initialize the current deserializer value with the object count
                deserializer.UpdateObjectCount(xml.MaxObjectCount);
            }
        }
        /// <summary>Applies properties from the reader to the specified resource.</summary>
        /// <param name="deserializer">Deserializer which is driving the <paramref name="reader"/>.</param>
        /// <param name='reader'>XmlReader to read from.</param>
        /// <param name='resourceType'>Type of resource.</param>
        /// <param name='resource'>Resource to set value on.</param>
        /// <param name="propertiesApplied">Properties already applied based on content</param>
        /// <param name="currentObjectCount">current object count for this operation.</param>
        /// <remarks>
        /// This method will end as soon as it find something that is not an
        /// XML element to process.
        /// </remarks>
        internal static void ApplyContent(Deserializer deserializer, XmlReader reader, ResourceType resourceType, object resource, EpmContentDeSerializer.EpmAppliedPropertyInfo propertiesApplied, int currentObjectCount)
        {
            Debug.Assert(deserializer != null, "deserializer != null");
            Debug.Assert(reader != null, "reader != null");
            using (PlainXmlDeserializer xml = new PlainXmlDeserializer(reader, deserializer, propertiesApplied))
            {
                // Initialize the new deserializer instance with the current object count
                xml.UpdateObjectCount(currentObjectCount);

                // load all the properties
                xml.ApplyContent(xml.xmlReader, resourceType, resource);

                // After all the properties have been loaded, initialize the current deserializer value with the object count
                deserializer.UpdateObjectCount(xml.MaxObjectCount);
            }
        }