internal ODataAtomMetadataDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
        {
            XmlNameTable nameTable = base.XmlReader.NameTable;

            this.EmptyNamespace = nameTable.Add(string.Empty);
            this.AtomNamespace  = nameTable.Add("http://www.w3.org/2005/Atom");
        }
Example #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="entryState">The reader entry state to use for the entry to which the EPM is applied.</param>
 /// <param name="inputContext">The input context currently in use.</param>
 protected EpmReader(
     IODataAtomReaderEntryState entryState,
     ODataAtomInputContext inputContext)
 {
     this.entryState = entryState;
     this.atomInputContext = inputContext;
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomCollectionDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            this.duplicatePropertyNamesChecker = this.CreateDuplicatePropertyNamesChecker();
        }
Example #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        protected ODataAtomDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            Debug.Assert(atomInputContext != null, "atomInputContext != null");

            this.atomInputContext = atomInputContext;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomCollectionDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            this.duplicatePropertyNamesChecker = this.CreateDuplicatePropertyNamesChecker();
        }
Example #6
0
 private IEnumerable<ODataPayloadKind> DetectPayloadKindImplementation(Stream messageStream, bool readingResponse, bool synchronous, ODataPayloadKindDetectionInfo detectionInfo)
 {
     using (ODataAtomInputContext context = new ODataAtomInputContext(this, messageStream, detectionInfo.GetEncoding(), detectionInfo.MessageReaderSettings, ODataVersion.V3, readingResponse, synchronous, detectionInfo.Model, null))
     {
         return context.DetectPayloadKind(detectionInfo);
     }
 }
Example #7
0
 private IEnumerable <ODataPayloadKind> DetectPayloadKindImplementation(Stream messageStream, bool readingResponse, bool synchronous, ODataPayloadKindDetectionInfo detectionInfo)
 {
     using (ODataAtomInputContext context = new ODataAtomInputContext(this, messageStream, detectionInfo.GetEncoding(), detectionInfo.MessageReaderSettings, ODataVersion.V3, readingResponse, synchronous, detectionInfo.Model, null))
     {
         return(context.DetectPayloadKind(detectionInfo));
     }
 }
 internal ODataAtomEntryAndFeedDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     XmlNameTable nameTable = base.XmlReader.NameTable;
     this.AtomNamespace = nameTable.Add("http://www.w3.org/2005/Atom");
     this.AtomEntryElementName = nameTable.Add("entry");
     this.AtomCategoryElementName = nameTable.Add("category");
     this.AtomCategoryTermAttributeName = nameTable.Add("term");
     this.AtomCategorySchemeAttributeName = nameTable.Add("scheme");
     this.AtomContentElementName = nameTable.Add("content");
     this.AtomLinkElementName = nameTable.Add("link");
     this.AtomPropertiesElementName = nameTable.Add("properties");
     this.AtomFeedElementName = nameTable.Add("feed");
     this.AtomIdElementName = nameTable.Add("id");
     this.AtomLinkRelationAttributeName = nameTable.Add("rel");
     this.AtomLinkHrefAttributeName = nameTable.Add("href");
     this.MediaLinkEntryContentSourceAttributeName = nameTable.Add("src");
     this.ODataETagAttributeName = nameTable.Add("etag");
     this.ODataCountElementName = nameTable.Add("count");
     this.ODataInlineElementName = nameTable.Add("inline");
     this.ODataActionElementName = nameTable.Add("action");
     this.ODataFunctionElementName = nameTable.Add("function");
     this.ODataOperationMetadataAttribute = nameTable.Add("metadata");
     this.ODataOperationTitleAttribute = nameTable.Add("title");
     this.ODataOperationTargetAttribute = nameTable.Add("target");
 }
Example #9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="entryState">The reader entry state to use for the entry to which the EPM is applied.</param>
 /// <param name="inputContext">The input context currently in use.</param>
 protected EpmReader(
     IODataAtomReaderEntryState entryState,
     ODataAtomInputContext inputContext)
 {
     this.entryState       = entryState;
     this.atomInputContext = inputContext;
 }
 internal ODataAtomPropertyAndValueDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     XmlNameTable nameTable = base.XmlReader.NameTable;
     this.EmptyNamespace = nameTable.Add(string.Empty);
     this.ODataNullAttributeName = nameTable.Add("null");
     this.ODataCollectionItemElementName = nameTable.Add("element");
     this.AtomTypeAttributeName = nameTable.Add("type");
 }
 internal ODataAtomEntityReferenceLinkDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     XmlNameTable nameTable = base.XmlReader.NameTable;
     this.ODataLinksElementName = nameTable.Add("links");
     this.ODataCountElementName = nameTable.Add("count");
     this.ODataNextElementName = nameTable.Add("next");
     this.ODataUriElementName = nameTable.Add("uri");
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The input to read the payload from.</param>
        /// <param name="expectedItemTypeReference">The expected type reference for the items in the collection.</param>
        internal ODataAtomCollectionReader(ODataAtomInputContext atomInputContext, IEdmTypeReference expectedItemTypeReference)
            : base(atomInputContext, expectedItemTypeReference, null /*listener*/)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(atomInputContext != null, "atomInputContext != null");

            this.atomInputContext = atomInputContext;
            this.atomCollectionDeserializer = new ODataAtomCollectionDeserializer(atomInputContext);
        }
        internal ODataAtomEntityReferenceLinkDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
        {
            XmlNameTable nameTable = base.XmlReader.NameTable;

            this.ODataLinksElementName = nameTable.Add("links");
            this.ODataCountElementName = nameTable.Add("count");
            this.ODataNextElementName  = nameTable.Add("next");
            this.ODataUriElementName   = nameTable.Add("uri");
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomEntryMetadataDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;
            this.EmptyNamespace = nameTable.Add(string.Empty);
            this.AtomNamespace = nameTable.Add(AtomConstants.AtomNamespace);
        }
Example #15
0
        internal ODataAtomPropertyAndValueDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
        {
            XmlNameTable nameTable = base.XmlReader.NameTable;

            this.EmptyNamespace                 = nameTable.Add(string.Empty);
            this.ODataNullAttributeName         = nameTable.Add("null");
            this.ODataCollectionItemElementName = nameTable.Add("element");
            this.AtomTypeAttributeName          = nameTable.Add("type");
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The input to read the payload from.</param>
        /// <param name="expectedItemTypeReference">The expected type reference for the items in the collection.</param>
        internal ODataAtomCollectionReader(ODataAtomInputContext atomInputContext, IEdmTypeReference expectedItemTypeReference)
            : base(atomInputContext, expectedItemTypeReference, null /*listener*/)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(atomInputContext != null, "atomInputContext != null");

            this.atomInputContext           = atomInputContext;
            this.atomCollectionDeserializer = new ODataAtomCollectionDeserializer(atomInputContext);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        /// <param name="inSourceElement">Whether this deserializer is reading feed metadata for a source element (true) or a feed element (false).</param>
        internal ODataAtomFeedMetadataDeserializer(ODataAtomInputContext atomInputContext, bool inSourceElement)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;
            this.EmptyNamespace = nameTable.Add(string.Empty);

            this.InSourceElement = inSourceElement;
        }
Example #18
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomMetadataDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;

            this.EmptyNamespace = nameTable.Add(string.Empty);
            this.AtomNamespace  = nameTable.Add(AtomConstants.AtomNamespace);
        }
Example #19
0
 internal ODataAtomReader(ODataAtomInputContext atomInputContext, IEdmEntityType expectedEntityType, bool readingFeed) : base(atomInputContext, expectedEntityType, readingFeed, null)
 {
     this.atomInputContext = atomInputContext;
     this.atomEntryAndFeedDeserializer = new ODataAtomEntryAndFeedDeserializer(atomInputContext);
     if (this.atomInputContext.MessageReaderSettings.ReaderBehavior.EntryXmlCustomizationCallback != null)
     {
         this.atomInputContext.InitializeReaderCustomization();
         this.atomEntryAndFeedDeserializersStack = new Stack<ODataAtomEntryAndFeedDeserializer>();
         this.atomEntryAndFeedDeserializersStack.Push(this.atomEntryAndFeedDeserializer);
     }
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomEntityReferenceLinkDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;
            this.ODataLinksElementName = nameTable.Add(AtomConstants.ODataLinksElementName);
            this.ODataCountElementName = nameTable.Add(AtomConstants.ODataCountElementName);
            this.ODataNextElementName = nameTable.Add(AtomConstants.ODataNextLinkElementName);
            this.ODataUriElementName = nameTable.Add(AtomConstants.ODataUriElementName);
        }
Example #21
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        /// <param name="inSourceElement">Whether this deserializer is reading feed metadata for a source element (true) or a feed element (false).</param>
        internal ODataAtomFeedMetadataDeserializer(ODataAtomInputContext atomInputContext, bool inSourceElement)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;

            this.EmptyNamespace = nameTable.Add(string.Empty);

            this.InSourceElement = inSourceElement;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomPropertyAndValueDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;
            this.EmptyNamespace = nameTable.Add(string.Empty);
            this.ODataNullAttributeName = nameTable.Add(AtomConstants.ODataNullAttributeName);
            this.ODataCollectionItemElementName = nameTable.Add(AtomConstants.ODataCollectionItemElementName);
            this.AtomTypeAttributeName = nameTable.Add(AtomConstants.AtomTypeAttributeName);
        }
Example #23
0
 internal ODataAtomReader(ODataAtomInputContext atomInputContext, IEdmEntityType expectedEntityType, bool readingFeed) : base(atomInputContext, expectedEntityType, readingFeed, null)
 {
     this.atomInputContext             = atomInputContext;
     this.atomEntryAndFeedDeserializer = new ODataAtomEntryAndFeedDeserializer(atomInputContext);
     if (this.atomInputContext.MessageReaderSettings.ReaderBehavior.EntryXmlCustomizationCallback != null)
     {
         this.atomInputContext.InitializeReaderCustomization();
         this.atomEntryAndFeedDeserializersStack = new Stack <ODataAtomEntryAndFeedDeserializer>();
         this.atomEntryAndFeedDeserializersStack.Push(this.atomEntryAndFeedDeserializer);
     }
 }
Example #24
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomPropertyAndValueDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;

            this.EmptyNamespace                 = nameTable.Add(string.Empty);
            this.ODataNullAttributeName         = nameTable.Add(AtomConstants.ODataNullAttributeName);
            this.ODataCollectionItemElementName = nameTable.Add(AtomConstants.ODataCollectionItemElementName);
            this.AtomTypeAttributeName          = nameTable.Add(AtomConstants.AtomTypeAttributeName);
        }
 internal ODataAtomServiceDocumentMetadataDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     XmlNameTable nameTable = base.XmlReader.NameTable;
     this.AtomNamespace = nameTable.Add("http://www.w3.org/2005/Atom");
     this.AtomCategoryElementName = nameTable.Add("category");
     this.AtomHRefAttributeName = nameTable.Add("href");
     this.AtomPublishingFixedAttributeName = nameTable.Add("fixed");
     this.AtomCategorySchemeAttributeName = nameTable.Add("scheme");
     this.AtomCategoryTermAttributeName = nameTable.Add("term");
     this.AtomCategoryLabelAttributeName = nameTable.Add("label");
     this.EmptyNamespace = nameTable.Add(string.Empty);
 }
Example #26
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomEntityReferenceLinkDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;

            this.ODataLinksElementName = nameTable.Add(AtomConstants.ODataLinksElementName);
            this.ODataCountElementName = nameTable.Add(AtomConstants.ODataCountElementName);
            this.ODataNextElementName  = nameTable.Add(AtomConstants.ODataNextLinkElementName);
            this.ODataUriElementName   = nameTable.Add(AtomConstants.ODataUriElementName);
        }
        /// <summary>
        /// Reads the syndication EPM for an entry.
        /// </summary>
        /// <param name="entryState">The reader entry state for the entry to which the EPM is applied.</param>
        /// <param name="inputContext">The input context currently in use.</param>
        internal static void ReadEntryEpm(
            IODataAtomReaderEntryState entryState,
            ODataAtomInputContext inputContext)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(entryState != null, "entryState != null");
            Debug.Assert(entryState.CachedEpm != null, "To read entry EPM, the entity type must have an EPM annotation.");
            Debug.Assert(inputContext != null, "inputContext != null");

            EpmSyndicationReader epmSyndicationReader = new EpmSyndicationReader(entryState, inputContext);

            epmSyndicationReader.ReadEntryEpm();
        }
        internal ODataAtomServiceDocumentMetadataDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
        {
            XmlNameTable nameTable = base.XmlReader.NameTable;

            this.AtomNamespace                    = nameTable.Add("http://www.w3.org/2005/Atom");
            this.AtomCategoryElementName          = nameTable.Add("category");
            this.AtomHRefAttributeName            = nameTable.Add("href");
            this.AtomPublishingFixedAttributeName = nameTable.Add("fixed");
            this.AtomCategorySchemeAttributeName  = nameTable.Add("scheme");
            this.AtomCategoryTermAttributeName    = nameTable.Add("term");
            this.AtomCategoryLabelAttributeName   = nameTable.Add("label");
            this.EmptyNamespace                   = nameTable.Add(string.Empty);
        }
Example #29
0
        /// <summary>
        /// Reads the custom EPM for an entry.
        /// </summary>
        /// <param name="entryState">The reader entry state for the entry to which the EPM is applied.</param>
        /// <param name="inputContext">The input context currently in use.</param>
        internal static void ReadEntryEpm(
            IODataAtomReaderEntryState entryState,
            ODataAtomInputContext inputContext)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(entryState != null, "entryState != null");
            Debug.Assert(entryState.CachedEpm != null, "To read entry EPM, the entity type must have an EPM annotation.");
            Debug.Assert(entryState.EpmCustomReaderValueCache != null, "To read custom entry EPM, the entry must have the custom EPM reader value cache.");
            Debug.Assert(inputContext != null, "inputContext != null");

            EpmCustomReader epmCustomReader = new EpmCustomReader(entryState, inputContext);
            epmCustomReader.ReadEntryEpm();
        }
 internal ODataAtomServiceDocumentDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     XmlNameTable nameTable = base.XmlReader.NameTable;
     this.AtomPublishingServiceElementName = nameTable.Add("service");
     this.AtomPublishingWorkspaceElementName = nameTable.Add("workspace");
     this.AtomPublishingCollectionElementName = nameTable.Add("collection");
     this.AtomPublishingAcceptElementName = nameTable.Add("accept");
     this.AtomPublishingCategoriesElementName = nameTable.Add("categories");
     this.AtomHRefAttributeName = nameTable.Add("href");
     this.AtomPublishingNamespace = nameTable.Add("http://www.w3.org/2007/app");
     this.AtomNamespace = nameTable.Add("http://www.w3.org/2005/Atom");
     this.AtomTitleElementName = nameTable.Add("title");
     this.EmptyNamespace = nameTable.Add(string.Empty);
 }
Example #31
0
        internal ODataAtomServiceDocumentDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
        {
            XmlNameTable nameTable = base.XmlReader.NameTable;

            this.AtomPublishingServiceElementName    = nameTable.Add("service");
            this.AtomPublishingWorkspaceElementName  = nameTable.Add("workspace");
            this.AtomPublishingCollectionElementName = nameTable.Add("collection");
            this.AtomPublishingAcceptElementName     = nameTable.Add("accept");
            this.AtomPublishingCategoriesElementName = nameTable.Add("categories");
            this.AtomHRefAttributeName   = nameTable.Add("href");
            this.AtomPublishingNamespace = nameTable.Add("http://www.w3.org/2007/app");
            this.AtomNamespace           = nameTable.Add("http://www.w3.org/2005/Atom");
            this.AtomTitleElementName    = nameTable.Add("title");
            this.EmptyNamespace          = nameTable.Add(string.Empty);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomServiceDocumentMetadataDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;
            this.AtomNamespace = nameTable.Add(AtomConstants.AtomNamespace);
            this.AtomCategoryElementName = nameTable.Add(AtomConstants.AtomCategoryElementName);
            this.AtomHRefAttributeName = nameTable.Add(AtomConstants.AtomHRefAttributeName);
            this.AtomPublishingFixedAttributeName = nameTable.Add(AtomConstants.AtomPublishingFixedAttributeName);
            this.AtomCategorySchemeAttributeName = nameTable.Add(AtomConstants.AtomCategorySchemeAttributeName);
            this.AtomCategoryTermAttributeName = nameTable.Add(AtomConstants.AtomCategoryTermAttributeName);
            this.AtomCategoryLabelAttributeName = nameTable.Add(AtomConstants.AtomCategoryLabelAttributeName);
            this.EmptyNamespace = nameTable.Add(string.Empty);
        }
Example #33
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomServiceDocumentMetadataDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;

            this.AtomNamespace                    = nameTable.Add(AtomConstants.AtomNamespace);
            this.AtomCategoryElementName          = nameTable.Add(AtomConstants.AtomCategoryElementName);
            this.AtomHRefAttributeName            = nameTable.Add(AtomConstants.AtomHRefAttributeName);
            this.AtomPublishingFixedAttributeName = nameTable.Add(AtomConstants.AtomPublishingFixedAttributeName);
            this.AtomCategorySchemeAttributeName  = nameTable.Add(AtomConstants.AtomCategorySchemeAttributeName);
            this.AtomCategoryTermAttributeName    = nameTable.Add(AtomConstants.AtomCategoryTermAttributeName);
            this.AtomCategoryLabelAttributeName   = nameTable.Add(AtomConstants.AtomCategoryLabelAttributeName);
            this.EmptyNamespace                   = nameTable.Add(string.Empty);
        }
Example #34
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The input to read the payload from.</param>
        /// <param name="expectedEntityType">The expected entity type for the entry to be read (in case of entry reader) or entries in the feed to be read (in case of feed reader).</param>
        /// <param name="readingFeed">true if the reader is created for reading a feed; false when it is created for reading an entry.</param>
        internal ODataAtomReader(ODataAtomInputContext atomInputContext, IEdmEntityType expectedEntityType, bool readingFeed)
            : base(atomInputContext, expectedEntityType, readingFeed, null /*listener*/)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(atomInputContext != null, "atomInputContext != null");

            this.atomInputContext = atomInputContext;
            this.atomEntryAndFeedDeserializer = new ODataAtomEntryAndFeedDeserializer(atomInputContext);

            if (this.atomInputContext.MessageReaderSettings.AtomEntryXmlCustomizationCallback != null)
            {
                this.atomInputContext.InitializeReaderCustomization();
                this.atomEntryAndFeedDeserializersStack = new Stack<ODataAtomEntryAndFeedDeserializer>();
                this.atomEntryAndFeedDeserializersStack.Push(this.atomEntryAndFeedDeserializer);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomServiceDocumentDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();
            XmlNameTable nameTable = this.XmlReader.NameTable;

            this.AtomPublishingServiceElementName    = nameTable.Add(AtomConstants.AtomPublishingServiceElementName);
            this.AtomPublishingWorkspaceElementName  = nameTable.Add(AtomConstants.AtomPublishingWorkspaceElementName);
            this.AtomPublishingCollectionElementName = nameTable.Add(AtomConstants.AtomPublishingCollectionElementName);
            this.AtomPublishingAcceptElementName     = nameTable.Add(AtomConstants.AtomPublishingAcceptElementName);
            this.AtomPublishingCategoriesElementName = nameTable.Add(AtomConstants.AtomPublishingCategoriesElementName);
            this.AtomHRefAttributeName   = nameTable.Add(AtomConstants.AtomHRefAttributeName);
            this.AtomPublishingNamespace = nameTable.Add(AtomConstants.AtomPublishingNamespace);
            this.AtomNamespace           = nameTable.Add(AtomConstants.AtomNamespace);
            this.AtomTitleElementName    = nameTable.Add(AtomConstants.AtomTitleElementName);
            this.EmptyNamespace          = nameTable.Add(string.Empty);
        }
Example #36
0
 /// <summary>
 /// Detects the payload kind(s) from the message stream.
 /// </summary>
 /// <param name="messageStream">The message stream to read from for payload kind detection.</param>
 /// <param name="readingResponse">true if reading a response message; otherwise false.</param>
 /// <param name="synchronous">true if the input should be read synchronously; false if it should be read asynchronously.</param>
 /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
 /// <returns>An enumerable of zero or more payload kinds depending on what payload kinds were detected.</returns>
 private IEnumerable <ODataPayloadKind> DetectPayloadKindImplementation(
     Stream messageStream,
     bool readingResponse,
     bool synchronous,
     ODataPayloadKindDetectionInfo detectionInfo)
 {
     using (ODataAtomInputContext inputContext = new ODataAtomInputContext(
                this,
                messageStream,
                detectionInfo.GetEncoding(),
                detectionInfo.MessageReaderSettings,
                ODataVersion.V3, // NOTE: we don't rely on the version for payload kind detection; taking the latest.
                readingResponse,
                synchronous,
                detectionInfo.Model,
                /*urlResolver*/ null))
     {
         return(inputContext.DetectPayloadKind(detectionInfo));
     }
 }
Example #37
0
        /// <summary>
        /// Creates a new ATOM annotation parser.
        /// </summary>
        /// <param name="inputContext">The input context this annotation reader should use to read annotation elements.</param>
        /// <param name="propertyAndValueDeserializer">The property and value deserializer to use to read the value of an annotation element.</param>
        internal ODataAtomAnnotationReader(ODataAtomInputContext inputContext, ODataAtomPropertyAndValueDeserializer propertyAndValueDeserializer)
        {
            DebugUtils.CheckNoExternalCallers();

            this.inputContext = inputContext;
            this.propertyAndValueDeserializer = propertyAndValueDeserializer;
            BufferingXmlReader xmlReader = this.inputContext.XmlReader;

            Debug.Assert(xmlReader != null, "xmlReader != null");
            Debug.Assert(xmlReader.NameTable != null, "xmlReader.NameTable != null");
            xmlReader.NameTable.Add(AtomConstants.ODataAnnotationTargetAttribute);
            xmlReader.NameTable.Add(AtomConstants.ODataAnnotationTermAttribute);
            xmlReader.NameTable.Add(AtomConstants.AtomTypeAttributeName);
            xmlReader.NameTable.Add(AtomConstants.ODataNullAttributeName);
            xmlReader.NameTable.Add(AtomConstants.ODataAnnotationStringAttribute);
            xmlReader.NameTable.Add(AtomConstants.ODataAnnotationBoolAttribute);
            xmlReader.NameTable.Add(AtomConstants.ODataAnnotationDecimalAttribute);
            xmlReader.NameTable.Add(AtomConstants.ODataAnnotationIntAttribute);
            xmlReader.NameTable.Add(AtomConstants.ODataAnnotationFloatAttribute);
            this.odataMetadataNamespace = xmlReader.NameTable.Add(AtomConstants.ODataMetadataNamespace);
            this.attributeElementName   = xmlReader.NameTable.Add(AtomConstants.ODataAnnotationElementName);
        }
 private EpmSyndicationReader(IODataAtomReaderEntryState entryState, ODataAtomInputContext inputContext) : base(entryState, inputContext)
 {
 }
Example #39
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="entryState">The reader entry state for the entry to which the EPM is applied.</param>
 /// <param name="inputContext">The input context currently in use.</param>
 private EpmCustomReader(
     IODataAtomReaderEntryState entryState,
     ODataAtomInputContext inputContext)
     : base(entryState, inputContext)
 {
 }
Example #40
0
 internal static void ReadEntryEpm(IODataAtomReaderEntryState entryState, ODataAtomInputContext inputContext)
 {
     new EpmCustomReader(entryState, inputContext).ReadEntryEpm();
 }
Example #41
0
 private EpmCustomReader(IODataAtomReaderEntryState entryState, ODataAtomInputContext inputContext) : base(entryState, inputContext)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="atomInputContext">The ATOM input context to read from.</param>
 internal ODataAtomErrorDeserializer(ODataAtomInputContext atomInputContext)
     : base(atomInputContext)
 {
     DebugUtils.CheckNoExternalCallers();
 }
Example #43
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="atomInputContext">The ATOM input context to read from.</param>
 internal ODataAtomPayloadKindDetectionDeserializer(ODataAtomInputContext atomInputContext)
     : base(atomInputContext)
 {
     DebugUtils.CheckNoExternalCallers();
 }
 internal ODataAtomEntryMetadataDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     XmlNameTable nameTable = base.XmlReader.NameTable;
     this.EmptyNamespace = nameTable.Add(string.Empty);
     this.AtomNamespace = nameTable.Add("http://www.w3.org/2005/Atom");
 }
 internal ODataAtomCollectionReader(ODataAtomInputContext atomInputContext, IEdmTypeReference expectedItemTypeReference) : base(atomInputContext, expectedItemTypeReference, null)
 {
     this.atomInputContext           = atomInputContext;
     this.atomCollectionDeserializer = new ODataAtomCollectionDeserializer(atomInputContext);
 }
Example #46
0
 /// <summary>
 /// Detects the payload kind(s) from the message stream.
 /// </summary>
 /// <param name="messageStream">The message stream to read from for payload kind detection.</param>
 /// <param name="readingResponse">true if reading a response message; otherwise false.</param>
 /// <param name="synchronous">true if the input should be read synchronously; false if it should be read asynchronously.</param>
 /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
 /// <returns>An enumerable of zero or more payload kinds depending on what payload kinds were detected.</returns>
 private IEnumerable<ODataPayloadKind> DetectPayloadKindImplementation(
     Stream messageStream,
     bool readingResponse,
     bool synchronous,
     ODataPayloadKindDetectionInfo detectionInfo)
 {
     using (ODataAtomInputContext inputContext = new ODataAtomInputContext(
         this,
         messageStream,
         detectionInfo.GetEncoding(),
         detectionInfo.MessageReaderSettings,
         ODataVersion.V3,    // NOTE: we don't rely on the version for payload kind detection; taking the latest.
         readingResponse,
         synchronous,
         detectionInfo.Model,
         /*urlResolver*/ null))
     {
         return inputContext.DetectPayloadKind(detectionInfo);
     }
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="atomInputContext">The ATOM input context to read from.</param>
        internal ODataAtomEntryAndFeedDeserializer(ODataAtomInputContext atomInputContext)
            : base(atomInputContext)
        {
            DebugUtils.CheckNoExternalCallers();

            XmlNameTable nameTable = this.XmlReader.NameTable;
            this.AtomNamespace = nameTable.Add(AtomConstants.AtomNamespace);
            this.AtomEntryElementName = nameTable.Add(AtomConstants.AtomEntryElementName);
            this.AtomCategoryElementName = nameTable.Add(AtomConstants.AtomCategoryElementName);
            this.AtomCategoryTermAttributeName = nameTable.Add(AtomConstants.AtomCategoryTermAttributeName);
            this.AtomCategorySchemeAttributeName = nameTable.Add(AtomConstants.AtomCategorySchemeAttributeName);
            this.AtomContentElementName = nameTable.Add(AtomConstants.AtomContentElementName);
            this.AtomLinkElementName = nameTable.Add(AtomConstants.AtomLinkElementName);
            this.AtomPropertiesElementName = nameTable.Add(AtomConstants.AtomPropertiesElementName);
            this.AtomFeedElementName = nameTable.Add(AtomConstants.AtomFeedElementName);
            this.AtomIdElementName = nameTable.Add(AtomConstants.AtomIdElementName);
            this.AtomLinkRelationAttributeName = nameTable.Add(AtomConstants.AtomLinkRelationAttributeName);
            this.AtomLinkHrefAttributeName = nameTable.Add(AtomConstants.AtomLinkHrefAttributeName);
            this.MediaLinkEntryContentSourceAttributeName = nameTable.Add(AtomConstants.MediaLinkEntryContentSourceAttributeName);
            this.ODataETagAttributeName = nameTable.Add(AtomConstants.ODataETagAttributeName);
            this.ODataCountElementName = nameTable.Add(AtomConstants.ODataCountElementName);
            this.ODataInlineElementName = nameTable.Add(AtomConstants.ODataInlineElementName);
            this.ODataActionElementName = nameTable.Add(AtomConstants.ODataActionElementName);
            this.ODataFunctionElementName = nameTable.Add(AtomConstants.ODataFunctionElementName);
            this.ODataOperationMetadataAttribute = nameTable.Add(AtomConstants.ODataOperationMetadataAttribute);
            this.ODataOperationTitleAttribute = nameTable.Add(AtomConstants.ODataOperationTitleAttribute);
            this.ODataOperationTargetAttribute = nameTable.Add(AtomConstants.ODataOperationTargetAttribute);
        }
Example #48
0
 protected ODataAtomDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     this.atomInputContext = atomInputContext;
 }
 internal static void ReadEntryEpm(IODataAtomReaderEntryState entryState, ODataAtomInputContext inputContext)
 {
     new EpmSyndicationReader(entryState, inputContext).ReadEntryEpm();
 }
 internal ODataAtomFeedMetadataDeserializer(ODataAtomInputContext atomInputContext, bool inSourceElement) : base(atomInputContext)
 {
     this.EmptyNamespace  = base.XmlReader.NameTable.Add(string.Empty);
     this.InSourceElement = inSourceElement;
 }
Example #51
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="atomInputContext">The ATOM input context to read from.</param>
 internal ODataAtomEpmDeserializer(ODataAtomInputContext atomInputContext)
     : base(atomInputContext)
 {
     DebugUtils.CheckNoExternalCallers();
 }
 internal ODataAtomErrorDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
 }
 internal ODataAtomCollectionReader(ODataAtomInputContext atomInputContext, IEdmTypeReference expectedItemTypeReference) : base(atomInputContext, expectedItemTypeReference, null)
 {
     this.atomInputContext = atomInputContext;
     this.atomCollectionDeserializer = new ODataAtomCollectionDeserializer(atomInputContext);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="atomInputContext">The ATOM input context to read from.</param>
 internal ODataAtomPayloadKindDetectionDeserializer(ODataAtomInputContext atomInputContext)
     : base(atomInputContext)
 {
     DebugUtils.CheckNoExternalCallers();
 }
Example #55
0
        /// <summary>
        /// Creates a new instance of this class by consuming xml from the given input context.
        /// </summary>
        /// <param name="inputContext">The input context to use to create the annotation.</param>
        /// <param name="propertyAndValueDeserializer">The property and value deserializer to use when reading values in the annotation element content.</param>
        /// <returns>The <see cref="AtomInstanceAnnotation"/> populated with the information from the 'm:annotation' XML element, as long as the value is a string. Returns null otherwise.</returns>
        /// <remarks>
        /// Pre-Condition:   XmlNodeType.Element    - The annotation element to read.
        /// Post-Condition:  XmlNodeType.Any        - The node after the end of the annotation element, or the same element as in the pre-condition if the annotation was skipped.
        /// </remarks>
        internal static AtomInstanceAnnotation CreateFrom(ODataAtomInputContext inputContext, ODataAtomPropertyAndValueDeserializer propertyAndValueDeserializer)
        {
            DebugUtils.CheckNoExternalCallers();

            var xmlReader = inputContext.XmlReader;

            Debug.Assert(xmlReader != null, "xmlReader != null");
            Debug.Assert(xmlReader.NodeType == XmlNodeType.Element, "xmlReader must be positioned on an Element");
            Debug.Assert(xmlReader.NameTable != null, "xmlReader.NameTable != null");
            Debug.Assert(xmlReader.LocalName == "annotation", "Must be positioned on an annotation element");

            string termAttributeValue                 = null;
            string targetAttributeValue               = null;
            string typeAttributeValue                 = null;
            bool   nullAttributePresentAndTrue        = false;
            bool   sawMultipleAttributeValueNotations = false;

            // Notes on "attribute value notation":
            // Empty elements may have the annotation value specified via an attribute on the annotation element.
            // Exactly one of the following attributes must be present if this notation is being used: "string", "int", "bool", "float", "decimal".
            // The value of the annotation is the value of this value-specifying attribute.
            string attributeValueNotationAttributeName  = null;
            string attributeValueNotationAttributeValue = null;
            IEdmPrimitiveTypeReference attributeValueNotationTypeReference = null;

            XmlNameTable xmlNameTable        = xmlReader.NameTable;
            string       metadataNamespace   = xmlNameTable.Get(AtomConstants.ODataMetadataNamespace);
            string       nullAttributeName   = xmlNameTable.Get(AtomConstants.ODataNullAttributeName);
            string       typeAttributeName   = xmlNameTable.Get(AtomConstants.AtomTypeAttributeName);
            string       emptyNamespace      = xmlNameTable.Get(string.Empty);
            string       termAttributeName   = xmlNameTable.Get(AtomConstants.ODataAnnotationTermAttribute);
            string       targetAttributeName = xmlNameTable.Get(AtomConstants.ODataAnnotationTargetAttribute);

            // Loop through all the attributes and remember the ones specific to annotations.
            while (xmlReader.MoveToNextAttribute())
            {
                if (xmlReader.NamespaceEquals(metadataNamespace))
                {
                    if (xmlReader.LocalNameEquals(typeAttributeName))
                    {
                        typeAttributeValue = xmlReader.Value;
                    }
                    else if (xmlReader.LocalNameEquals(nullAttributeName))
                    {
                        nullAttributePresentAndTrue = ODataAtomReaderUtils.ReadMetadataNullAttributeValue(xmlReader.Value);
                    }

                    // Ignore all other attributes in the metadata namespace.
                    // In general, we only fail on reading if we can't make sense of the document any more. Reader should be loose.
                    // If we choose to start recognizing an additional attribute in the metadata namespace later, be careful not to
                    // fail if it doesn't parse correctly (so that we don't cause a breaking change).
                }
                else if (xmlReader.NamespaceEquals(emptyNamespace))
                {
                    if (xmlReader.LocalNameEquals(termAttributeName))
                    {
                        termAttributeValue = xmlReader.Value;

                        // Before doing any other validation or further reading, check whether or not to read this annotation according to the filter.
                        if (propertyAndValueDeserializer.MessageReaderSettings.ShouldSkipAnnotation(termAttributeValue))
                        {
                            xmlReader.MoveToElement();
                            return(null);
                        }
                    }
                    else if (xmlReader.LocalNameEquals(targetAttributeName))
                    {
                        targetAttributeValue = xmlReader.Value;
                    }
                    else
                    {
                        // Check if this attribute is one used by attribute value notation.
                        IEdmPrimitiveTypeReference potentialTypeFromAttributeValueNotation = LookupEdmTypeByAttributeValueNotationName(xmlReader.LocalName);
                        if (potentialTypeFromAttributeValueNotation != null)
                        {
                            // If we've already seen an attribute used for attribute value notation,
                            // throw since we don't know which type to use (even if the values are the same).
                            // But don't throw yet, because we might not have encountered the term name yet,
                            // and the annotation filter might say to ignore this annotation (and so we shouldn't throw).
                            if (attributeValueNotationTypeReference != null)
                            {
                                sawMultipleAttributeValueNotations = true;
                            }

                            attributeValueNotationTypeReference  = potentialTypeFromAttributeValueNotation;
                            attributeValueNotationAttributeName  = xmlReader.LocalName;
                            attributeValueNotationAttributeValue = xmlReader.Value;
                        }
                    }

                    // Ignore all other attributes in the empty namespace.
                }

                // Ignore all other attributes in all other namespaces.
            }

            xmlReader.MoveToElement();

            // The term attribute is required.
            if (termAttributeValue == null)
            {
                throw new ODataException(ODataErrorStrings.AtomInstanceAnnotation_MissingTermAttributeOnAnnotationElement);
            }

            if (sawMultipleAttributeValueNotations)
            {
                throw new ODataException(ODataErrorStrings.AtomInstanceAnnotation_MultipleAttributeValueNotationAttributes);
            }

            // If this term is defined in the model, look up its type. If the term is not in the model, this will be null.
            IEdmTypeReference expectedTypeReference = MetadataUtils.LookupTypeOfValueTerm(termAttributeValue, propertyAndValueDeserializer.Model);

            ODataValue annotationValue;

            if (nullAttributePresentAndTrue)
            {
                // The m:null attribute has precedence over the content of the element, thus if we find m:null='true' we ignore the content of the element.
                ReaderValidationUtils.ValidateNullValue(
                    propertyAndValueDeserializer.Model,
                    expectedTypeReference,
                    propertyAndValueDeserializer.MessageReaderSettings,
                    /*validateNullValue*/ true,
                    propertyAndValueDeserializer.Version,
                    termAttributeValue);
                annotationValue = new ODataNullValue();
            }
            else if (attributeValueNotationTypeReference != null)
            {
                annotationValue = GetValueFromAttributeValueNotation(
                    expectedTypeReference,
                    attributeValueNotationTypeReference,
                    attributeValueNotationAttributeName,
                    attributeValueNotationAttributeValue,
                    typeAttributeValue,
                    xmlReader.IsEmptyElement,
                    propertyAndValueDeserializer.Model,
                    propertyAndValueDeserializer.MessageReaderSettings,
                    propertyAndValueDeserializer.Version);
            }
            else
            {
                annotationValue = ReadValueFromElementContent(propertyAndValueDeserializer, expectedTypeReference);
            }

            // Read the end tag (or the start tag if it was an empty element).
            xmlReader.Read();

            return(new AtomInstanceAnnotation(
                       targetAttributeValue,
                       termAttributeValue,
                       annotationValue));
        }
 internal ODataAtomPayloadKindDetectionDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
 }
 internal ODataAtomFeedMetadataDeserializer(ODataAtomInputContext atomInputContext, bool inSourceElement) : base(atomInputContext)
 {
     this.EmptyNamespace = base.XmlReader.NameTable.Add(string.Empty);
     this.InSourceElement = inSourceElement;
 }
 internal ODataAtomEpmDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
 }
 internal ODataAtomCollectionDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     this.duplicatePropertyNamesChecker = base.CreateDuplicatePropertyNamesChecker();
 }
Example #60
0
 protected ODataAtomDeserializer(ODataAtomInputContext atomInputContext) : base(atomInputContext)
 {
     this.atomInputContext = atomInputContext;
 }