Esempio n. 1
0
        /// <summary>
        /// Modifies the <see cref="IExtensibleSyndicationObject"/> to match the data source.
        /// </summary>
        /// <remarks>
        ///     A default <see cref="XmlNamespaceManager"/> is created against this adapter's <see cref="Navigator"/> property
        ///     when resolving prefixed syndication elements and attributes.
        /// </remarks>
        /// <param name="entity">The <see cref="IExtensibleSyndicationObject"/> to be filled.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="entity"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Fill(IExtensibleSyndicationObject entity)
        {
            Guard.ArgumentNotNull(entity, "entity");
            XmlNamespaceManager manager = new XmlNamespaceManager(this.Navigator.NameTable);

            this.Fill(entity, manager);
        }
Esempio n. 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)
        {
            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);
                    }
                }
            }
        }
Esempio n. 3
0
        //============================================================
        //	STATIC METHODS
        //============================================================
        #region FillExtensionTypes(IExtensibleSyndicationObject entity, Collection<Type> types)
        /// <summary>
        /// Fills the specified collection of <see cref="Type"/> objects using the supplied <see cref="IExtensibleSyndicationObject"/>.
        /// </summary>
        /// <param name="entity">A <see cref="IExtensibleSyndicationObject"/> to extract syndication extensions from.</param>
        /// <param name="types">The <see cref="Collection{T}"/> collection of <see cref="Type"/> objects to be filled.</param>
        /// <remarks>
        ///    This method provides implementers of the <see cref="ISyndicationResource"/> interface with a simple way
        ///    to fill a <see cref="SyndicationResourceSaveSettings.SupportedExtensions"/> collection when implementing the
        ///    <see cref="ISyndicationResource.Save(XmlWriter, SyndicationResourceSaveSettings)"/> abstract method.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="entity"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="types"/> is a null reference (Nothing in Visual Basic).</exception>
        public static void FillExtensionTypes(IExtensibleSyndicationObject entity, Collection <Type> types)
        {
            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(entity, "entity");
            Guard.ArgumentNotNull(types, "types");

            //------------------------------------------------------------
            //	Fill types collection using entity extensions
            //------------------------------------------------------------
            if (entity.HasExtensions)
            {
                foreach (ISyndicationExtension extension in entity.Extensions)
                {
                    if (extension != null)
                    {
                        Type type = extension.GetType();
                        if (!types.Contains(type))
                        {
                            types.Add(type);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        private TimeSpan GetFrequency_(IExtensibleSyndicationObject feed)
        {
            var ext = feed.FindExtension(SiteSummaryUpdateSyndicationExtension.MatchByType) as SiteSummaryUpdateSyndicationExtension;
            int day = 0, hour = 0;

            switch (ext.Context.Period)
            {
            case SiteSummaryUpdatePeriod.Daily: day = ext.Context.Frequency; break;

            case SiteSummaryUpdatePeriod.Hourly: hour = ext.Context.Frequency; break;
            }

            return(new TimeSpan(day, hour, 0, 0));
        }
Esempio n. 5
0
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Fill(IExtensibleSyndicationObject entity)
        /// <summary>
        /// Modifies the <see cref="IExtensibleSyndicationObject"/> to match the data source.
        /// </summary>
        /// <remarks>
        ///     A default <see cref="XmlNamespaceManager"/> is created against this adapter's <see cref="Navigator"/> property
        ///     when resolving prefixed syndication elements and attributes.
        /// </remarks>
        /// <param name="entity">The <see cref="IExtensibleSyndicationObject"/> to be filled.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="entity"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Fill(IExtensibleSyndicationObject entity)
        {
            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(entity, "entity");

            //------------------------------------------------------------
            //	Create namespace resolver
            //------------------------------------------------------------
            XmlNamespaceManager manager = new XmlNamespaceManager(this.Navigator.NameTable);

            //------------------------------------------------------------
            //	Fill syndication extensions
            //------------------------------------------------------------
            this.Fill(entity, manager);
        }
        private static SimpleListSyndicationExtensionContext GetContext(IExtensibleSyndicationObject entry, bool createIfMissing)
        {
            var extension = entry.Extensions.OfType<SimpleListSyndicationExtension>().FirstOrDefault();

            if (extension == null)
            {
                if (!createIfMissing)
                {
                    return null;
                }

                extension = new SimpleListSyndicationExtension();
                entry.AddExtension(extension);
            }

            return extension.Context;
        }
        private static SDataExtensionContext GetContext(IExtensibleSyndicationObject entry, bool createIfMissing)
        {
            Guard.ArgumentNotNull(entry, "entry");
            var extension = entry.Extensions.OfType<SDataExtension>().FirstOrDefault();

            if (extension == null)
            {
                if (!createIfMissing)
                {
                    return null;
                }

                extension = new SDataExtension();
                entry.AddExtension(extension);
            }

            return extension.Context;
        }
        private static OpenSearchExtensionContext GetContext(IExtensibleSyndicationObject entry, bool createIfMissing)
        {
            Guard.ArgumentNotNull(entry, "entry");
            var extension = entry.Extensions.OfType <OpenSearchExtension>().FirstOrDefault();

            if (extension == null)
            {
                if (!createIfMissing)
                {
                    return(null);
                }

                extension = new OpenSearchExtension();
                entry.AddExtension(extension);
            }

            return(extension.Context);
        }
        /// <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);
                    }
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Fills the specified collection of <see cref="Type"/> objects using the supplied <see cref="IExtensibleSyndicationObject"/>.
        /// </summary>
        /// <param name="entity">A <see cref="IExtensibleSyndicationObject"/> to extract syndication extensions from.</param>
        /// <param name="types">The <see cref="Collection{T}"/> collection of <see cref="Type"/> objects to be filled.</param>
        /// <remarks>
        ///    This method provides implementers of the <see cref="ISyndicationResource"/> interface with a simple way
        ///    to fill a <see cref="SyndicationResourceSaveSettings.SupportedExtensions"/> collection when implementing the
        ///    <see cref="ISyndicationResource.Save(XmlWriter, SyndicationResourceSaveSettings)"/> abstract method.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="entity"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="types"/> is a null reference (Nothing in Visual Basic).</exception>
        public static void FillExtensionTypes(IExtensibleSyndicationObject entity, Collection <Type> types)
        {
            Guard.ArgumentNotNull(entity, "entity");
            Guard.ArgumentNotNull(types, "types");

            if (entity.HasExtensions)
            {
                foreach (ISyndicationExtension extension in entity.Extensions)
                {
                    if (extension != null)
                    {
                        Type type = extension.GetType();
                        if (!types.Contains(type))
                        {
                            types.Add(type);
                        }
                    }
                }
            }
        }
        /// <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);
                    }
                }
            }
        }
        /// <summary>
        /// Modifies the <see cref="IExtensibleSyndicationObject"/> to match the data source.
        /// </summary>
        /// <remarks>
        ///     A default <see cref="XmlNamespaceManager"/> is created against this adapter's <see cref="Navigator"/> property 
        ///     when resolving prefixed syndication elements and attributes.
        /// </remarks>
        /// <param name="entity">The <see cref="IExtensibleSyndicationObject"/> to be filled.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="entity"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Fill(IExtensibleSyndicationObject entity)
        {
            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(entity, "entity");

            //------------------------------------------------------------
            //	Create namespace resolver
            //------------------------------------------------------------
            XmlNamespaceManager manager = new XmlNamespaceManager(this.Navigator.NameTable);

            //------------------------------------------------------------
            //	Fill syndication extensions
            //------------------------------------------------------------
            this.Fill(entity, manager);
        }
        /// <summary>
        /// Fills the specified collection of <see cref="Type"/> objects using the supplied <see cref="IExtensibleSyndicationObject"/>.
        /// </summary>
        /// <param name="entity">A <see cref="IExtensibleSyndicationObject"/> to extract syndication extensions from.</param>
        /// <param name="types">The <see cref="Collection{T}"/> collection of <see cref="Type"/> objects to be filled.</param>
        /// <remarks>
        ///    This method provides implementers of the <see cref="ISyndicationResource"/> interface with a simple way 
        ///    to fill a <see cref="SyndicationResourceSaveSettings.SupportedExtensions"/> collection when implementing the 
        ///    <see cref="ISyndicationResource.Save(XmlWriter, SyndicationResourceSaveSettings)"/> abstract method.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="entity"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="types"/> is a null reference (Nothing in Visual Basic).</exception>
        public static void FillExtensionTypes(IExtensibleSyndicationObject entity, Collection<Type> types)
        {
            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(entity, "entity");
            Guard.ArgumentNotNull(types, "types");

            //------------------------------------------------------------
            //	Fill types collection using entity extensions
            //------------------------------------------------------------
            if (entity.HasExtensions)
            {
                foreach (ISyndicationExtension extension in entity.Extensions)
                {
                    if (extension != null)
                    {
                        Type type   = extension.GetType();
                        if (!types.Contains(type))
                        {
                            types.Add(type);
                        }
                    }
                }
            }
        }