Ejemplo n.º 1
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 target is a null reference, instance is greater
            //------------------------------------------------------------
            if (obj == null)
            {
                return(1);
            }

            //------------------------------------------------------------
            //	Determine comparison result using property state of objects
            //------------------------------------------------------------
            AtomWorkspace value = obj as AtomWorkspace;

            if (value != null)
            {
                int result = this.Title.CompareTo(value.Title);
                result = result | AtomWorkspace.CompareSequence(((Collection <AtomMemberResources>) this.Collections), ((Collection <AtomMemberResources>)value.Collections));
                result = result | AtomUtility.CompareCommonObjectAttributes(this, value);

                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.º 2
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);
            }

            AtomWorkspace value = obj as AtomWorkspace;

            if (value != null)
            {
                int result = this.Title.CompareTo(value.Title);
                result = result | AtomWorkspace.CompareSequence(((Collection <AtomMemberResources>) this.Collections), ((Collection <AtomMemberResources>)value.Collections));
                result = result | AtomUtility.CompareCommonObjectAttributes(this, value);

                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");
            }
        }
        /// <summary>
        /// Modifies the <see cref="AtomServiceDocument"/> to match the data source.
        /// </summary>
        /// <param name="resource">The <see cref="AtomServiceDocument"/> to be filled.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Fill(AtomServiceDocument resource)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(resource, "resource");

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

            //------------------------------------------------------------
            //	Attempt to fill syndication resource
            //------------------------------------------------------------
            XPathNavigator documentNavigator    = this.Navigator.SelectSingleNode("app:service", manager);
            if (documentNavigator != null)
            {
                AtomUtility.FillCommonObjectAttributes(resource, documentNavigator);

                if (documentNavigator.HasChildren)
                {
                    XPathNodeIterator workspaceIterator = documentNavigator.Select("app:workspace", manager);

                    if (workspaceIterator != null && workspaceIterator.Count > 0)
                    {
                        while (workspaceIterator.MoveNext())
                        {
                            AtomWorkspace workspace = new AtomWorkspace();
                            if (workspace.Load(workspaceIterator.Current, this.Settings))
                            {
                                resource.AddWorkspace(workspace);
                            }
                        }
                    }
                }

                SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(documentNavigator, this.Settings);
                adapter.Fill(resource, manager);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds the supplied <see cref="AtomWorkspace"/> to the document's <see cref="Workspaces"/> collection.
        /// </summary>
        /// <param name="workspace">The <see cref="AtomWorkspace"/> to be added.</param>
        /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was added to the <see cref="Workspaces"/> collection, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="workspace"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool AddWorkspace(AtomWorkspace workspace)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasAdded   = false;

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

            //------------------------------------------------------------
            //	Add element to collection
            //------------------------------------------------------------
            ((Collection<AtomWorkspace>)this.Workspaces).Add(workspace);
            wasAdded    = true;

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

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

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

            return wasRemoved;
        }