コード例 #1
0
ファイル: ODataAtomReader.cs プロジェクト: modulexcite/pash-1
        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);
        }
コード例 #2
0
ファイル: ODataAtomReader.cs プロジェクト: modulexcite/pash-1
        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);
                }
            }
        }
コード例 #3
0
ファイル: ODataAtomReader.cs プロジェクト: modulexcite/pash-1
        private void ReadAtNonExpandedNavigatLinkStart()
        {
            ODataNavigationLink        currentNavigationLink = base.CurrentNavigationLink;
            IODataAtomReaderEntryState linkParentEntityScope = (IODataAtomReaderEntryState)base.LinkParentEntityScope;

            linkParentEntityScope.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(currentNavigationLink, false, currentNavigationLink.IsCollection);
            if (this.atomInputContext.ReadingResponse)
            {
                AtomScope currentScope = (AtomScope)base.CurrentScope;
                IEdmNavigationProperty navigationProperty = currentScope.NavigationProperty;
                if (((currentNavigationLink.IsCollection == false) && (navigationProperty != null)) && navigationProperty.Type.IsCollection())
                {
                    throw new ODataException(Microsoft.Data.OData.Strings.ODataAtomReader_DeferredEntryInFeedNavigationLink);
                }
                this.ReplaceScope(ODataReaderState.NavigationLinkEnd);
            }
            else
            {
                ODataEntityReferenceLink item = new ODataEntityReferenceLink {
                    Url = currentNavigationLink.Url
                };
                this.EnterScope(ODataReaderState.EntityReferenceLink, item, null);
            }
        }
コード例 #4
0
ファイル: ODataAtomReader.cs プロジェクト: modulexcite/pash-1
        protected override bool ReadAtNavigationLinkStartImplementation()
        {
            ODataNavigationLink        currentNavigationLink = base.CurrentNavigationLink;
            IODataAtomReaderEntryState linkParentEntityScope = (IODataAtomReaderEntryState)base.LinkParentEntityScope;
            AtomScope currentScope = (AtomScope)base.CurrentScope;
            IEdmNavigationProperty navigationProperty = currentScope.NavigationProperty;

            if (this.atomEntryAndFeedDeserializer.XmlReader.IsEmptyElement)
            {
                this.ReadAtNonExpandedNavigatLinkStart();
            }
            else
            {
                this.atomEntryAndFeedDeserializer.XmlReader.Read();
                ODataAtomDeserializerExpandedNavigationLinkContent content = this.atomEntryAndFeedDeserializer.ReadNavigationLinkContentBeforeExpansion();
                if (((content != ODataAtomDeserializerExpandedNavigationLinkContent.None) && (navigationProperty == null)) && (this.atomInputContext.Model.IsUserModel() && this.atomInputContext.MessageReaderSettings.UndeclaredPropertyBehaviorKinds.HasFlag(ODataUndeclaredPropertyBehaviorKinds.ReportUndeclaredLinkProperty)))
                {
                    if (!this.atomInputContext.MessageReaderSettings.UndeclaredPropertyBehaviorKinds.HasFlag(ODataUndeclaredPropertyBehaviorKinds.IgnoreUndeclaredValueProperty))
                    {
                        throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_PropertyDoesNotExistOnType(currentNavigationLink.Name, base.LinkParentEntityScope.EntityType.ODataFullName()));
                    }
                    this.atomEntryAndFeedDeserializer.SkipNavigationLinkContentOnExpansion();
                    this.ReadAtNonExpandedNavigatLinkStart();
                    return(true);
                }
                switch (content)
                {
                case ODataAtomDeserializerExpandedNavigationLinkContent.None:
                    this.ReadAtNonExpandedNavigatLinkStart();
                    break;

                case ODataAtomDeserializerExpandedNavigationLinkContent.Empty:
                    if (currentNavigationLink.IsCollection != true)
                    {
                        currentNavigationLink.IsCollection = false;
                        linkParentEntityScope.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(currentNavigationLink, true, false);
                        this.EnterScope(ODataReaderState.EntryStart, null, base.CurrentEntityType);
                        break;
                    }
                    linkParentEntityScope.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(currentNavigationLink, true, true);
                    this.EnterScope(ODataReaderState.FeedStart, new ODataFeed(), base.CurrentEntityType);
                    this.CurrentFeedState.FeedElementEmpty = true;
                    break;

                case ODataAtomDeserializerExpandedNavigationLinkContent.Entry:
                    if ((currentNavigationLink.IsCollection == true) || ((navigationProperty != null) && navigationProperty.Type.IsCollection()))
                    {
                        throw new ODataException(Microsoft.Data.OData.Strings.ODataAtomReader_ExpandedEntryInFeedNavigationLink);
                    }
                    currentNavigationLink.IsCollection = false;
                    linkParentEntityScope.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(currentNavigationLink, true, false);
                    this.ReadEntryStart();
                    break;

                case ODataAtomDeserializerExpandedNavigationLinkContent.Feed:
                    if (currentNavigationLink.IsCollection == false)
                    {
                        throw new ODataException(Microsoft.Data.OData.Strings.ODataAtomReader_ExpandedFeedInEntryNavigationLink);
                    }
                    currentNavigationLink.IsCollection = true;
                    linkParentEntityScope.DuplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(currentNavigationLink, true, true);
                    this.ReadFeedStart();
                    break;

                default:
                    throw new ODataException(Microsoft.Data.OData.Strings.General_InternalError(InternalErrorCodes.ODataAtomReader_ReadAtNavigationLinkStartImplementation));
                }
            }
            return(true);
        }