Ejemplo n.º 1
0
        public static AtomLink CreateEditMediaLink(Uri href, string contentType, CultureInfo contentLanguage)
        {
            AtomLink link = AtomMemberResources.CreateEditMediaLink(href, contentType);

            link.ContentLanguage = contentLanguage;
            return(link);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="AtomLink"/> that can be used to modify a media resource associated with an <see cref="AtomEntry"/> using the supplied parameters.
        /// </summary>
        /// <param name="href">A <see cref="Uri"/> that represents an IRI that can be used to modify a media resource associated with an <see cref="AtomEntry"/>.</param>
        /// <param name="contentType">An advisory MIME media type that provides a hint about the type of the representation that is expected to be returned by the Web resource.</param>
        /// <returns>A <see cref="AtomLink"/> object that can be can be used to modify a media resource associated with an <see cref="AtomEntry"/>.</returns>
        /// <remarks>
        ///     <para>
        ///         The <see cref="AtomLink"/> that is returned has a <see cref="AtomLink.Relation"/> of <b>edit-media</b>. The value of <i>edit-media</i> specifies
        ///         that the value of the <paramref name="href"/> attribute is an IRI that can be used to modify a media resource associated with an <see cref="AtomEntry"/>.
        ///     </para>
        ///     <para>
        ///         An <see cref="AtomEntry"/> <i>may</i> contain zero or more <i>edit-media</i> link relations.
        ///         An <see cref="AtomEntry"/> <b>must not</b> contain more than one <see cref="AtomLink"/> with a <see cref="AtomLink.Relation"/> value of <i>edit-media</i>
        ///         that has the same <see cref="AtomLink.ContentType"/> and <see cref="AtomLink.ContentLanguage"/> values.
        ///         All <i>edit-media</i> link relations in the same <see cref="AtomEntry"/> reference the same Resource.
        ///         If a client encounters multiple <i>edit-media</i> link relations in an <see cref="AtomEntry"/> then it <i>should</i> choose a link based on the client
        ///         preferences for <see cref="AtomLink.ContentType"/> and <see cref="AtomLink.ContentLanguage"/>. If a client encounters multiple <i>edit-media</i> link relations
        ///         in an <see cref="AtomEntry"/> and has no preference based on the <see cref="AtomLink.ContentType"/> and <see cref="AtomLink.ContentLanguage"/> then the
        ///         client <i>should</i> pick the first <i>edit-media</i> link relation in document order.
        ///     </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="href"/> is a null reference (Nothing in Visual Basic).</exception>
        public static AtomLink CreateEditMediaLink(Uri href, string contentType)
        {
            AtomLink link = AtomMemberResources.CreateEditMediaLink(href);

            link.ContentType = contentType;
            return(link);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads this <see cref="AtomWorkspace"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomWorkspace"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Initialize XML namespace resolver
            //------------------------------------------------------------
            XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(source.NameTable);

            //------------------------------------------------------------
            //	Attempt to extract common attributes information
            //------------------------------------------------------------
            if (AtomUtility.FillCommonObjectAttributes(this, source))
            {
                wasLoaded = true;
            }

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNavigator    titleNavigator     = source.SelectSingleNode("atom:title", manager);
                XPathNodeIterator collectionIterator = source.Select("app:collection", manager);

                if (titleNavigator != null)
                {
                    this.Title = new AtomTextConstruct();
                    if (this.Title.Load(titleNavigator))
                    {
                        wasLoaded = true;
                    }
                }

                if (collectionIterator != null && collectionIterator.Count > 0)
                {
                    while (collectionIterator.MoveNext())
                    {
                        AtomMemberResources collection = new AtomMemberResources();
                        if (collection.Load(collectionIterator.Current))
                        {
                            this.AddCollection(collection);
                            wasLoaded = true;
                        }
                    }
                }
            }

            return(wasLoaded);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds the supplied <see cref="AtomMemberResources"/> to the <see cref="Collections"/> of the workspace.
        /// </summary>
        /// <param name="collection">The <see cref="AtomMemberResources"/> to be added.</param>
        /// <returns><b>true</b> if the <see cref="AtomMemberResources"/> was added to the <see cref="Collections"/> of the workspace, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool AddCollection(AtomMemberResources collection)
        {
            bool wasAdded = false;

            Guard.ArgumentNotNull(collection, "collection");

            ((Collection <AtomMemberResources>) this.Collections).Add(collection);
            wasAdded = true;

            return(wasAdded);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes the supplied <see cref="AtomMemberResources"/> from the <see cref="Collections"/> of the workspace.
        /// </summary>
        /// <param name="collection">The <see cref="AtomMemberResources"/> to be removed.</param>
        /// <returns><b>true</b> if the <see cref="AtomMemberResources"/> was removed from the <see cref="Collections"/> of the workspace, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     If the <see cref="Collections"/> of the workspace does not contain the specified <see cref="AtomMemberResources"/>, will return <b>false</b>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool RemoveCollection(AtomMemberResources collection)
        {
            bool wasRemoved = false;

            Guard.ArgumentNotNull(collection, "collection");

            if (((Collection <AtomMemberResources>) this.Collections).Contains(collection))
            {
                ((Collection <AtomMemberResources>) this.Collections).Remove(collection);
                wasRemoved = true;
            }

            return(wasRemoved);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads this <see cref="AtomWorkspace"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomWorkspace"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");

            XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(source.NameTable);

            if (AtomUtility.FillCommonObjectAttributes(this, source))
            {
                wasLoaded = true;
            }

            if (source.HasChildren)
            {
                XPathNavigator    titleNavigator     = source.SelectSingleNode("atom:title", manager);
                XPathNodeIterator collectionIterator = source.Select("app:collection", manager);

                if (titleNavigator != null)
                {
                    this.Title = new AtomTextConstruct();
                    if (this.Title.Load(titleNavigator))
                    {
                        wasLoaded = true;
                    }
                }

                if (collectionIterator != null && collectionIterator.Count > 0)
                {
                    while (collectionIterator.MoveNext())
                    {
                        AtomMemberResources collection = new AtomMemberResources();
                        if (collection.Load(collectionIterator.Current))
                        {
                            this.AddCollection(collection);
                            wasLoaded = true;
                        }
                    }
                }
            }

            return(wasLoaded);
        }
Ejemplo n.º 7
0
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region AddCollection(AtomMemberResources collection)
        /// <summary>
        /// Adds the supplied <see cref="AtomMemberResources"/> to the <see cref="Collections"/> of the workspace.
        /// </summary>
        /// <param name="collection">The <see cref="AtomMemberResources"/> to be added.</param>
        /// <returns><b>true</b> if the <see cref="AtomMemberResources"/> was added to the <see cref="Collections"/> of the workspace, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool AddCollection(AtomMemberResources collection)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasAdded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(collection, "collection");

            //------------------------------------------------------------
            //	Add element to collection
            //------------------------------------------------------------
            ((Collection <AtomMemberResources>) this.Collections).Add(collection);
            wasAdded = true;

            return(wasAdded);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception>
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            AtomMemberResources value = obj as AtomMemberResources;

            if (value != null)
            {
                int result = Uri.Compare(this.Uri, value.Uri, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase);
                result = result | this.Title.CompareTo(value.Title);
                result = result | AtomMemberResources.CompareSequence(this.Accepts, value.Accepts);
                result = result | AtomCategoryDocument.CompareSequence(this.Categories, value.Categories);

                return(result);
            }
            else
            {
                throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj");
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Removes the supplied <see cref="AtomMemberResources"/> from the <see cref="Collections"/> of the workspace.
        /// </summary>
        /// <param name="collection">The <see cref="AtomMemberResources"/> to be removed.</param>
        /// <returns><b>true</b> if the <see cref="AtomMemberResources"/> was removed from the <see cref="Collections"/> of the workspace, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     If the <see cref="Collections"/> of the workspace does not contain the specified <see cref="AtomMemberResources"/>, will return <b>false</b>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool RemoveCollection(AtomMemberResources collection)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasRemoved = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(collection, "collection");

            //------------------------------------------------------------
            //	Remove element from collection
            //------------------------------------------------------------
            if (((Collection <AtomMemberResources>) this.Collections).Contains(collection))
            {
                ((Collection <AtomMemberResources>) this.Collections).Remove(collection);
                wasRemoved = true;
            }

            return(wasRemoved);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Removes the supplied <see cref="AtomMemberResources"/> from the <see cref="Collections"/> of the workspace.
        /// </summary>
        /// <param name="collection">The <see cref="AtomMemberResources"/> to be removed.</param>
        /// <returns><b>true</b> if the <see cref="AtomMemberResources"/> was removed from the <see cref="Collections"/> of the workspace, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     If the <see cref="Collections"/> of the workspace does not contain the specified <see cref="AtomMemberResources"/>, will return <b>false</b>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool RemoveCollection(AtomMemberResources collection)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasRemoved = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(collection, "collection");

            //------------------------------------------------------------
            //	Remove element from collection
            //------------------------------------------------------------
            if (((Collection<AtomMemberResources>)this.Collections).Contains(collection))
            {
                ((Collection<AtomMemberResources>)this.Collections).Remove(collection);
                wasRemoved  = true;
            }

            return wasRemoved;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Loads this <see cref="AtomWorkspace"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomWorkspace"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded              = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Initialize XML namespace resolver
            //------------------------------------------------------------
            XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(source.NameTable);

            //------------------------------------------------------------
            //	Attempt to extract common attributes information
            //------------------------------------------------------------
            if (AtomUtility.FillCommonObjectAttributes(this, source))
            {
                wasLoaded = true;
            }

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if(source.HasChildren)
            {
                XPathNavigator titleNavigator           = source.SelectSingleNode("atom:title", manager);
                XPathNodeIterator collectionIterator    = source.Select("app:collection", manager);

                if (titleNavigator != null)
                {
                    this.Title  = new AtomTextConstruct();
                    if (this.Title.Load(titleNavigator))
                    {
                        wasLoaded   = true;
                    }
                }

                if (collectionIterator != null && collectionIterator.Count > 0)
                {
                    while (collectionIterator.MoveNext())
                    {
                        AtomMemberResources collection   = new AtomMemberResources();
                        if (collection.Load(collectionIterator.Current))
                        {
                            this.AddCollection(collection);
                            wasLoaded   = true;
                        }
                    }
                }
            }

            return wasLoaded;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Adds the supplied <see cref="AtomMemberResources"/> to the <see cref="Collections"/> of the workspace.
        /// </summary>
        /// <param name="collection">The <see cref="AtomMemberResources"/> to be added.</param>
        /// <returns><b>true</b> if the <see cref="AtomMemberResources"/> was added to the <see cref="Collections"/> of the workspace, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool AddCollection(AtomMemberResources collection)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasAdded   = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(collection, "collection");

            //------------------------------------------------------------
            //	Add element to collection
            //------------------------------------------------------------
            ((Collection<AtomMemberResources>)this.Collections).Add(collection);
            wasAdded    = true;

            return wasAdded;
        }