コード例 #1
0
        /// <summary>
        /// Modifies the <see cref="IExtensibleSyndicationObject"/> to match the data source.
        /// </summary>
        /// <param name="entity">The <see cref="IExtensibleSyndicationObject"/> to be filled.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve prefixed syndication elements and attributes.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="entity"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Fill(IExtensibleSyndicationObject entity, XmlNamespaceManager manager)
        {
            Collection <ISyndicationExtension> extensions = new Collection <ISyndicationExtension>();

            Guard.ArgumentNotNull(entity, "entity");
            Guard.ArgumentNotNull(manager, "manager");

            if (this.Settings.AutoDetectExtensions)
            {
                extensions = SyndicationExtensionAdapter.GetExtensions(this.Settings.SupportedExtensions, (Dictionary <string, string>) this.Navigator.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml));
            }
            else
            {
                extensions = SyndicationExtensionAdapter.GetExtensions(this.Settings.SupportedExtensions);
            }

            foreach (ISyndicationExtension extension in extensions)
            {
                if (extension.ExistsInSource(this.Navigator) && extension.GetType() != entity.GetType())
                {
                    ISyndicationExtension instance = (ISyndicationExtension)Activator.CreateInstance(extension.GetType());

                    if (instance.Load(this.Navigator))
                    {
                        ((Collection <ISyndicationExtension>)entity.Extensions).Add(instance);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Modifies the <see cref="IExtensibleSyndicationObject"/> to match the data source.
        /// </summary>
        /// <param name="entity">The <see cref="IExtensibleSyndicationObject"/> to be filled.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve prefixed syndication elements and attributes.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="entity"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Fill(IExtensibleSyndicationObject entity, XmlNamespaceManager manager)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            Collection <ISyndicationExtension> extensions = new Collection <ISyndicationExtension>();

            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(entity, "entity");
            Guard.ArgumentNotNull(manager, "manager");

            //------------------------------------------------------------
            //	Get syndication extensions supported by the load operation
            //------------------------------------------------------------
            if (this.Settings.AutoDetectExtensions)
            {
                //BEGIN PATCH
                //extensions  = SyndicationExtensionAdapter.GetExtensions(this.Settings.SupportedExtensions, (Dictionary<string, string>)this.Navigator.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml));
                extensions = SyndicationExtensionAdapter.GetExtensions(this.Settings.SupportedExtensions, this.Navigator.GetAllNamespaces());
                //END PATCH
            }
            else
            {
                extensions = SyndicationExtensionAdapter.GetExtensions(this.Settings.SupportedExtensions);
            }

            //------------------------------------------------------------
            //	Add syndication extensions to entity if they exist in source
            //------------------------------------------------------------
            foreach (ISyndicationExtension extension in extensions)
            {
                if (extension.ExistsInSource(this.Navigator))
                {
                    ISyndicationExtension instance = (ISyndicationExtension)Activator.CreateInstance(extension.GetType());

                    if (instance.Load(this.Navigator))
                    {
                        ((Collection <ISyndicationExtension>)entity.Extensions).Add(instance);
                    }
                }
            }
        }