private void EndEntry()
        {
            IODataAtomReaderEntryState currentEntryState = this.CurrentEntryState;
            ODataEntry entry = currentEntryState.Entry;

            if (entry != null)
            {
                if (currentEntryState.CachedEpm != null)
                {
                    AtomScope currentScope = (AtomScope)base.CurrentScope;
                    if (currentScope.HasAtomEntryMetadata)
                    {
                        EpmSyndicationReader.ReadEntryEpm(currentEntryState, this.atomInputContext);
                    }
                    if (currentScope.HasEpmCustomReaderValueCache)
                    {
                        EpmCustomReader.ReadEntryEpm(currentEntryState, this.atomInputContext);
                    }
                }
                if (currentEntryState.AtomEntryMetadata != null)
                {
                    entry.SetAnnotation <AtomEntryMetadata>(currentEntryState.AtomEntryMetadata);
                }
                IEdmEntityType entityType = currentEntryState.EntityType;
                if ((!currentEntryState.MediaLinkEntry.HasValue && (entityType != null)) && this.atomInputContext.Model.HasDefaultStream(entityType))
                {
                    ODataAtomEntryAndFeedDeserializer.EnsureMediaResource(currentEntryState, true);
                }
                bool validateMediaResource = this.atomInputContext.UseDefaultFormatBehavior || this.atomInputContext.UseServerFormatBehavior;
                ValidationUtils.ValidateEntryMetadata(entry, entityType, this.atomInputContext.Model, validateMediaResource);
            }
            this.ReplaceScope(ODataReaderState.EntryEnd);
        }
        private void ReadEntryStart()
        {
            ODataEntry entry = ReaderUtils.CreateNewEntry();

            if (this.atomInputContext.MessageReaderSettings.ReaderBehavior.EntryXmlCustomizationCallback != null)
            {
                this.atomEntryAndFeedDeserializer.VerifyEntryStart();
                Uri       xmlBaseUri = this.atomInputContext.XmlReader.XmlBaseUri;
                XmlReader objB       = this.atomInputContext.MessageReaderSettings.ReaderBehavior.EntryXmlCustomizationCallback(entry, this.atomInputContext.XmlReader, this.atomInputContext.XmlReader.ParentXmlBaseUri);
                if (objB != null)
                {
                    if (object.ReferenceEquals(this.atomInputContext.XmlReader, objB))
                    {
                        throw new ODataException(Microsoft.Data.OData.Strings.ODataAtomReader_EntryXmlCustomizationCallbackReturnedSameInstance);
                    }
                    this.atomInputContext.PushCustomReader(objB, xmlBaseUri);
                    this.atomEntryAndFeedDeserializer = new ODataAtomEntryAndFeedDeserializer(this.atomInputContext);
                    this.atomEntryAndFeedDeserializersStack.Push(this.atomEntryAndFeedDeserializer);
                }
                else
                {
                    this.atomInputContext.PushCustomReader(this.atomInputContext.XmlReader, null);
                }
            }
            this.atomEntryAndFeedDeserializer.ReadEntryStart(entry);
            this.EnterScope(ODataReaderState.EntryStart, entry, base.CurrentEntityType);
            AtomScope currentScope = (AtomScope)base.CurrentScope;

            currentScope.DuplicatePropertyNamesChecker = this.atomInputContext.CreateDuplicatePropertyNamesChecker();
            string entityTypeNameFromPayload = this.atomEntryAndFeedDeserializer.FindTypeName();

            base.ApplyEntityTypeNameFromPayload(entityTypeNameFromPayload);
            if (base.CurrentFeedValidator != null)
            {
                base.CurrentFeedValidator.ValidateEntry(base.CurrentEntityType);
            }
            ODataEntityPropertyMappingCache cache = this.atomInputContext.Model.EnsureEpmCache(this.CurrentEntryState.EntityType, 0x7fffffff);

            if (cache != null)
            {
                currentScope.CachedEpm = cache;
            }
            if (this.atomEntryAndFeedDeserializer.XmlReader.IsEmptyElement)
            {
                this.CurrentEntryState.EntryElementEmpty = true;
            }
            else
            {
                this.atomEntryAndFeedDeserializer.XmlReader.Read();
                if (this.atomInputContext.UseServerApiBehavior)
                {
                    this.CurrentEntryState.FirstNavigationLinkDescriptor = null;
                }
                else
                {
                    this.CurrentEntryState.FirstNavigationLinkDescriptor = this.atomEntryAndFeedDeserializer.ReadEntryContent(this.CurrentEntryState);
                }
            }
        }
 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);
     }
 }
        protected override bool ReadAtEntryEndImplementation()
        {
            bool isTopLevel            = base.IsTopLevel;
            bool isExpandedLinkContent = base.IsExpandedLinkContent;
            bool emptyInline           = base.CurrentEntry == null;

            base.PopScope(ODataReaderState.EntryEnd);
            if (!emptyInline)
            {
                bool flag4 = false;
                if (this.atomInputContext.MessageReaderSettings.ReaderBehavior.EntryXmlCustomizationCallback != null)
                {
                    XmlReader objB = this.atomInputContext.PopCustomReader();
                    if (!object.ReferenceEquals(this.atomInputContext.XmlReader, objB))
                    {
                        flag4 = true;
                        this.atomEntryAndFeedDeserializersStack.Pop();
                        this.atomEntryAndFeedDeserializer = this.atomEntryAndFeedDeserializersStack.Peek();
                    }
                }
                if (!flag4)
                {
                    this.atomEntryAndFeedDeserializer.ReadEntryEnd();
                }
            }
            bool flag5 = true;

            if (isTopLevel)
            {
                this.atomEntryAndFeedDeserializer.ReadPayloadEnd();
                this.ReplaceScope(ODataReaderState.Completed);
                return(false);
            }
            if (isExpandedLinkContent)
            {
                this.atomEntryAndFeedDeserializer.ReadNavigationLinkContentAfterExpansion(emptyInline);
                this.ReplaceScope(ODataReaderState.NavigationLinkEnd);
                return(flag5);
            }
            if (this.atomEntryAndFeedDeserializer.ReadFeedContent(this.CurrentFeedState, base.IsExpandedLinkContent))
            {
                this.ReadEntryStart();
                return(flag5);
            }
            this.ReplaceScope(ODataReaderState.FeedEnd);
            return(flag5);
        }