コード例 #1
0
        public void PropertySettersNullTest()
        {
            AtomWorkspaceMetadata workspace = new AtomWorkspaceMetadata()
            {
                Title = null,
            };

            this.Assert.IsNull(workspace.Title, "Expected null value for property 'Title'.");
        }
コード例 #2
0
        public void PropertyGettersAndSettersTest()
        {
            AtomTextConstruct title = new AtomTextConstruct();

            AtomWorkspaceMetadata workspace = new AtomWorkspaceMetadata()
            {
                Title = title,
            };

            this.Assert.AreSame(title, workspace.Title, "Expected reference equal values for property 'Title'.");
        }
コード例 #3
0
        /// <summary>Determines an extension method to get the <see cref="T:System.Data.OData.Atom.AtomWorkspaceMetadata" /> for an annotatable serviceDocument.</summary>
        /// <returns>An <see cref="T:Microsoft.OData.Core.Atom.AtomWorkspaceMetadata" /> instance or null if no annotation of that type exists.</returns>
        /// <param name="serviceDocument">The serviceDocument to get the annotation from.</param>
        public static AtomWorkspaceMetadata Atom(this ODataServiceDocument serviceDocument)
        {
            ExceptionUtils.CheckArgumentNotNull(serviceDocument, "serviceDocument");

            AtomWorkspaceMetadata workspaceMetadata = serviceDocument.GetAnnotation<AtomWorkspaceMetadata>();
            if (workspaceMetadata == null)
            {
                workspaceMetadata = new AtomWorkspaceMetadata();
                serviceDocument.SetAnnotation(workspaceMetadata);
            }

            return workspaceMetadata;
        }
        /// <summary>
        /// Reads an atom:title element and adds the new information to <paramref name="workspaceMetadata"/>.
        /// </summary>
        /// <param name="workspaceMetadata">The non-null workspace metadata object to augment.</param>
        /// <remarks>
        /// Pre-Condition:  XmlNodeType.Element - The start of the atom:title element.
        /// Post-Condition: Any                 - The next node after the atom:title element. 
        /// </remarks>
        internal void ReadTitleElementInWorkspace(AtomWorkspaceMetadata workspaceMetadata)
        {
            Debug.Assert(workspaceMetadata != null, "workspaceMetadata != null");
            this.AssertXmlCondition(XmlNodeType.Element);
            Debug.Assert(this.XmlReader.LocalName == AtomConstants.AtomTitleElementName, "Expected element named 'title'.");
            Debug.Assert(this.XmlReader.NamespaceURI == AtomConstants.AtomNamespace, "Element 'title' should be in the atom namespace.");

            if (workspaceMetadata.Title != null)
            {
                throw new ODataException(Strings.ODataAtomServiceDocumentMetadataDeserializer_MultipleTitleElementsFound(AtomConstants.AtomPublishingWorkspaceElementName));
            }

            workspaceMetadata.Title = this.ReadTitleElement();
        }
コード例 #5
0
 public void DefaultValuesTest()
 {
     AtomWorkspaceMetadata workspace = new AtomWorkspaceMetadata();
     this.Assert.IsNull(workspace.Title, "Expected null default value for property 'Title'.");
 }
コード例 #6
0
 /// <summary>
 /// Visits an ATOM serviceDocument metadata.
 /// </summary>
 /// <param name="atomWorkspaceMetadata">The serviceDocument metadata to visit.</param>
 protected virtual void VisitAtomWorkspaceMetadata(AtomWorkspaceMetadata atomWorkspaceMetadata)
 {
     this.VisitAtomMetadata(atomWorkspaceMetadata.Title);
 }