当前位置: 首页>>代码示例>>C#>>正文


C# EdmModel.FindEntityContainer方法代码示例

本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmModel.FindEntityContainer方法的典型用法代码示例。如果您正苦于以下问题:C# EdmModel.FindEntityContainer方法的具体用法?C# EdmModel.FindEntityContainer怎么用?C# EdmModel.FindEntityContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.OData.Edm.Library.EdmModel的用法示例。


在下文中一共展示了EdmModel.FindEntityContainer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEdmModel


//.........这里部分代码省略.........
            var FullyQualifiedNamespaceContextPet3Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet3Set", FullyQualifiedNamespacePet3);
            var FullyQualifiedNamespaceContextPet4Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet4Set", FullyQualifiedNamespacePet4);
            var FullyQualifiedNamespaceContextPet5Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet5Set", FullyQualifiedNamespacePet5);
            var FullyQualifiedNamespaceContextPet6Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet6Set", FullyQualifiedNamespacePet6);
            var FullyQualifiedNamespaceContextChimera = FullyQualifiedNamespaceContext.AddEntitySet("Chimeras", FullyQualifiedNamespaceChimera);

            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyDog, FullyQualifiedNamespaceContextDogs);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyRelatedDogs, FullyQualifiedNamespaceContextDogs);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyLions, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPaintings, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyFavoritePainting, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceEmployee_PaintingsInOffice, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceEmployee_Manager, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceManager_DirectReports, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPet2Set, FullyQualifiedNamespaceContextPet2Set);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_MyPeople, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_FastestOwner, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_LionsISaw, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextLions.AddNavigationTarget(FullyQualifiedNamespaceLion_Friends, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextPaintings.AddNavigationTarget(FullyQualifiedNamespacePainting_Owner, FullyQualifiedNamespaceContextPeople);

            // Add singleton
            var FullQualifiedNamespaceSingletonBoss = FullyQualifiedNamespaceContext.AddSingleton("Boss", FullyQualifiedNamespacePerson);
            FullQualifiedNamespaceSingletonBoss.AddNavigationTarget(FullyQualifiedNamespacePerson_MyDog, FullyQualifiedNamespaceContextDogs);
            FullQualifiedNamespaceSingletonBoss.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPaintings, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet1", FullyQualifiedNamespaceGetPet1Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet1Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet2", FullyQualifiedNamespaceGetPet2Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet2Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet3", FullyQualifiedNamespaceGetPet3Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet3Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet4", FullyQualifiedNamespaceGetPet4Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet4Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet5", FullyQualifiedNamespaceGetPet5Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet5Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet6", FullyQualifiedNamespaceGetPet6Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet6Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPetCount", FullyQualifiedNamespaceGetPetCountFunction, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet5Set));

            FullyQualifiedNamespaceContext.AddFunctionImport("FindMyOwner", FullyQualifiedNamespaceFindMyOwnerFunction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("IsAddressGood", FullyQualifiedNamespaceIsAddressGoodFunction, null);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolPeople", FullyQualifiedNamespaceGetCoolPeopleAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolestPerson", FullyQualifiedNamespaceGetCoolestPersonAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolestPersonWithStyle", FullyQualifiedNamespaceGetCoolestPersonWithStyleAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetBestManager", FullyQualifiedNamespaceGetBestManagerAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddActionImport("GetNothing", FullyQualifiedNamespaceGetNothingAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeNumber", FullyQualifiedNamespaceGetSomeNumberAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeAddress", FullyQualifiedNamespaceGetSomeAddressAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeNumbers", FullyQualifiedNamespaceGetSomeNumbersAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeAddresses", FullyQualifiedNamespaceGetSomeAddressesAction);

            FullyQualifiedNamespaceContext.AddActionImport("ResetAllData", FullyQualifiedNamespaceResetAllDataAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetMostImporantPerson", FullyQualifiedNamespaceGetMostImporantPersonFunction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetMostImporantPerson", FullyQualifiedNamespaceGetMostImporantPersonFunction2);

            FullyQualifiedNamespaceContext.AddActionImport("MoveEveryone", FullyQualifiedNamespaceMoveEveryoneAction);

            #endregion

            try
开发者ID:rossjempson,项目名称:odata.net,代码行数:67,代码来源:HardCodedTestModel.cs

示例2: FillStockContentsForEntityContainer

        private void FillStockContentsForEntityContainer(IEdmEntityContainer edmContainer, IEdmModel edmModel, EdmModel stockModel)
        {
            var stockContainer = (EdmEntityContainer)stockModel.FindEntityContainer(edmContainer.FullName());
            this.SetImmediateAnnotations(edmContainer, stockContainer, edmModel, stockModel);

            foreach (var edmNavigationSource in edmContainer.Elements.OfType<IEdmNavigationSource>())
            {
                var stockEntityType = (EdmEntityType)stockModel.FindType(GetFullName(edmNavigationSource.EntityType()));
                if (edmNavigationSource is IEdmSingleton)
                {
                    stockContainer.AddSingleton(edmNavigationSource.Name, stockEntityType);
                }
                else
                {
                    stockContainer.AddEntitySet(edmNavigationSource.Name, stockEntityType);
                }
            }

            foreach (var stockNavigationSource in stockContainer.Elements.OfType<EdmNavigationSource>())
            {
                var stockEntityType = (EdmEntityType)stockModel.FindType(GetFullName(stockNavigationSource.EntityType()));
                IEdmNavigationSource edmNavigationSource = edmContainer.FindEntitySet(stockNavigationSource.Name);
                if (edmNavigationSource == null)
                {
                    edmNavigationSource = edmContainer.FindSingleton(stockNavigationSource.Name);
                }

                var stockDerivedNavigations = GetAllNavigationFromDerivedTypesAndSelf(stockEntityType, stockModel);

                foreach (var stockNavigationProperty in stockDerivedNavigations)
                {
                    var edmNavigationProperty = edmNavigationSource.NavigationPropertyBindings.Select(n => n.NavigationProperty).SingleOrDefault(n => n.Name == stockNavigationProperty.Name);

                    if (edmNavigationProperty != null)
                    {
                        var targetEdmEntitySet = edmNavigationSource.FindNavigationTarget(edmNavigationProperty);

                        if (null != targetEdmEntitySet)
                        {
                            var targetEntitySetFromContainer = stockContainer.Elements.OfType<EdmEntitySet>().SingleOrDefault
                                (
                                    n =>
                                        GetBaseTypesAndSelf(((IEdmNavigationProperty)stockNavigationProperty).ToEntityType()).Select(m => GetFullName(m)).Contains(n.EntityType().FullName()) && n.Name == targetEdmEntitySet.Name
                                );

                            if (null == targetEntitySetFromContainer)
                            {
                                targetEntitySetFromContainer = stockContainer.Elements.OfType<EdmEntitySet>().SingleOrDefault
                                (
                                    n =>
                                        GetAllDerivedTypesAndSelf(((IEdmNavigationProperty)stockNavigationProperty).ToEntityType(), stockModel).Select(m => GetFullName(m)).Contains(n.EntityType().FullName()) && n.Name == targetEdmEntitySet.Name
                                );
                            }

                            stockNavigationSource.AddNavigationTarget(stockNavigationProperty, targetEntitySetFromContainer);
                        }
                    }
                }
            }
            
            foreach (var edmOperationImport in edmContainer.OperationImports())
            {
                EdmOperationImport stockEdmOperationImport = null;
                var edmActionImport = edmOperationImport as IEdmActionImport;

                if (edmActionImport != null)
                {
                    var newEdmAction = stockModel.FindDeclaredOperations(edmActionImport.Action.FullName()).OfType<IEdmAction>().FirstOrDefault() as EdmAction;
                    ExceptionUtilities.CheckObjectNotNull(newEdmAction, "cannot find action");
                    stockEdmOperationImport = stockContainer.AddActionImport(edmOperationImport.Name, newEdmAction, edmActionImport.EntitySet);
                }
                else
                {
                    IEdmFunctionImport edmFunctionImport = edmOperationImport as IEdmFunctionImport;
                    ExceptionUtilities.CheckArgumentNotNull(edmFunctionImport, "edmFunctionImport");

                    var newEdmFunction = edmModel.FindDeclaredOperations(edmFunctionImport.Function.FullName()).OfType<IEdmFunction>().FirstOrDefault();
                    ExceptionUtilities.CheckObjectNotNull(newEdmFunction, "Expected to find an function: " + edmFunctionImport.Function.FullName());
                    stockEdmOperationImport = stockContainer.AddFunctionImport(edmFunctionImport.Name, newEdmFunction, edmFunctionImport.EntitySet, edmFunctionImport.IncludeInServiceDocument);
                }

                this.SetImmediateAnnotations(edmOperationImport, stockEdmOperationImport, edmModel, stockModel);
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:84,代码来源:EdmToStockModelConverter.cs

示例3: CreateFeedNextLinkDescriptors

        private PayloadWriterTestDescriptor<ODataItem>[] CreateFeedNextLinkDescriptors()
        {
            string[] nextLinkUris = new string[] 
            {
                "http://my.customers.com/?skiptoken=1234",
                "http://my.customers.com/?",
                "http://my.customers.com/",
                "http://my.customers.com/?$filter=3.14E%2B%20ne%20null",
                "http://my.customers.com/?$filter='foo%20%26%20'%20ne%20null",
                "http://my.customers.com/?$filter=not%20endswith(Name,'%2B')",
                "http://my.customers.com/?$filter=geo.distance(Point,%20geometry'SRID=0;Point(6.28E%2B3%20-2.1e%2B4)')%20eq%20null",
            };

            Func<string, ODataFeed> feedCreator = (nextLink) =>
                {
                    ODataFeed feed = ObjectModelUtils.CreateDefaultFeed();
                    feed.NextPageLink = new Uri(nextLink);
                    return feed;
                };

            EdmModel model = new EdmModel();

            ODataFeed dummyFeed = ObjectModelUtils.CreateDefaultFeed("CustomersSet", "CustomerType", model);

            var container = model.FindEntityContainer("DefaultContainer");
            var customerSet = container.FindEntitySet("CustomersSet") as EdmEntitySet;
            var customerType = model.FindType("TestModel.CustomerType") as EdmEntityType;

            return nextLinkUris.Select(nextLink => new PayloadWriterTestDescriptor<ODataItem>(
                this.Settings,
                feedCreator(nextLink),
                (testConfiguration) =>
                {
                    if (testConfiguration.IsRequest)
                    {
                        return new WriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                        {
                            ExpectedException2 = ODataExpectedExceptions.ODataException("WriterValidationUtils_NextPageLinkInRequest")
                        };
                    }

                    if (testConfiguration.Format == ODataFormat.Atom)
                    {
                        return new AtomWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                        {
                            Xml = @"<link rel=""next"" href=""" + nextLink + @""" xmlns=""" + TestAtomConstants.AtomNamespace + @""" />",
                            FragmentExtractor = (result) => result.Elements(XName.Get("link", TestAtomConstants.AtomNamespace)).Single()
                        };
                    }
                    else if (testConfiguration.Format == ODataFormat.Json)
                    {
                        return new JsonWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                        {
                            Json = "\"" + JsonLightConstants.ODataNextLinkAnnotationName + "\":\"" + nextLink + "\"",
                            FragmentExtractor = (result) => result.Object().Property(JsonLightConstants.ODataNextLinkAnnotationName)
                        };
                    }
                    else
                    {
                        string formatName = testConfiguration.Format == null ? "null" : testConfiguration.Format.GetType().Name;
                        throw new NotSupportedException("Invalid format detected: " + formatName);
                    }
                })
                {
                    Model = model,
                    PayloadEdmElementContainer = customerSet,
                    PayloadEdmElementType = customerType,
                }).ToArray();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:69,代码来源:WriterFeedTests.cs

示例4: CreateHomogeneousCollectionValues

        /// <summary>
        /// Creates a set of interesting homogeneous collection values with primitive and complex items.
        /// </summary>
        /// <param name="model">The model to add complex types to.</param>
        /// <param name="withTypeNames">true if the collection and complex value payloads should specify type names.</param>
        /// <param name="withExpectedType">true if an expected type annotation should be added to the generated payload element; otherwise false.</param>
        /// <param name="withcollectionName">true if the collection is not in the top level, otherwise false</param>
        /// <param name="fullSet">true if all available collection values should be returned, false if only the most interesting subset should be returned.</param>
        /// <returns>List of interesting collection values.</returns>
        public static IEnumerable<ODataPayloadElementCollection> CreateHomogeneousCollectionValues(
            EdmModel model,
            bool withTypeNames,
            bool withExpectedType,
            bool withcollectionName,
            bool fullset = true)
        {
            IEdmTypeReference itemTypeAnnotationType = null;
            IEdmTypeReference collectionTypeAnnotationType = null;
            EdmOperationImport primitiveCollectionFunctionImport = null;
            EdmEntityContainer defaultContainer = null;

            if (model != null)
            {
                defaultContainer = model.FindEntityContainer("TestModel.TestContainer") as EdmEntityContainer;
                if (defaultContainer == null)
                {
                    defaultContainer = new EdmEntityContainer("TestModel", "TestContainer");
                    model.AddElement(defaultContainer);
                }

                itemTypeAnnotationType = EdmCoreModel.Instance.GetString(true);
                collectionTypeAnnotationType = EdmCoreModel.GetCollection(itemTypeAnnotationType);

                var function = new EdmFunction("TestModel", "PrimitiveCollectionFunctionImport", collectionTypeAnnotationType);
                model.AddElement(function);
                primitiveCollectionFunctionImport = defaultContainer.AddFunctionImport("PrimitiveCollectionFunctionImport", function);
            }

            // primitive collection with single null item
            yield return new PrimitiveCollection(PayloadBuilder.PrimitiveValue(null).WithTypeAnnotation(itemTypeAnnotationType))
                .WithTypeAnnotation(collectionTypeAnnotationType)
                .ExpectedCollectionItemType(withExpectedType ? itemTypeAnnotationType : null)
                .ExpectedFunctionImport(withExpectedType ? primitiveCollectionFunctionImport : null)
                .CollectionName(withcollectionName ? "PrimitiveCollectionFunctionImport" : null);

            // primitive collection with multiple items (same type)
            yield return new PrimitiveCollection(
                PayloadBuilder.PrimitiveValue("Vienna").WithTypeAnnotation(itemTypeAnnotationType),
                PayloadBuilder.PrimitiveValue("Prague").WithTypeAnnotation(itemTypeAnnotationType),
                PayloadBuilder.PrimitiveValue("Redmond").WithTypeAnnotation(itemTypeAnnotationType)
                )
                .WithTypeAnnotation(collectionTypeAnnotationType)
                .ExpectedCollectionItemType(withExpectedType ? itemTypeAnnotationType : null)
                .ExpectedFunctionImport(withExpectedType ? primitiveCollectionFunctionImport : null)
                .CollectionName(withcollectionName ? "PrimitiveCollectionFunctionImport" : null);

            if (fullset)
            {
                // empty primitive collection
                yield return new PrimitiveCollection()
                    .WithTypeAnnotation(collectionTypeAnnotationType)
                    .ExpectedCollectionItemType(withExpectedType ? itemTypeAnnotationType : null)
                    .ExpectedFunctionImport(withExpectedType ? primitiveCollectionFunctionImport : null)
                    .CollectionName(withcollectionName ? "PrimitiveCollectionFunctionImport" : null);

                // primitive collection with a single item
                yield return new PrimitiveCollection(
                    PayloadBuilder.PrimitiveValue("Vienna").WithTypeAnnotation(itemTypeAnnotationType)
                    ).WithTypeAnnotation(collectionTypeAnnotationType)
                    .ExpectedCollectionItemType(withExpectedType ? itemTypeAnnotationType : null)
                    .ExpectedFunctionImport(withExpectedType ? primitiveCollectionFunctionImport : null)
                    .CollectionName(withcollectionName ? "PrimitiveCollectionFunctionImport" : null);

                // primitive collection with multiple null items
                yield return new PrimitiveCollection(
                    PayloadBuilder.PrimitiveValue(null).WithTypeAnnotation(itemTypeAnnotationType),
                    PayloadBuilder.PrimitiveValue(null).WithTypeAnnotation(itemTypeAnnotationType),
                    PayloadBuilder.PrimitiveValue(null).WithTypeAnnotation(itemTypeAnnotationType)
                    ).WithTypeAnnotation(collectionTypeAnnotationType)
                    .ExpectedCollectionItemType(withExpectedType ? itemTypeAnnotationType : null)
                    .ExpectedFunctionImport(withExpectedType ? primitiveCollectionFunctionImport : null)
                    .CollectionName(withcollectionName ? "PrimitiveCollectionFunctionImport" : null);
            }

            string localPersonTypeName = "ComplexCollectionPersonItemType";
            string personTypeName = GetFullTypeName(localPersonTypeName);
            EdmOperationImport complexCollectionFunctionImport = null;
            if (model != null)
            {
                EdmComplexType complexItemType = model.FindDeclaredType(personTypeName) as EdmComplexType;
                if (complexItemType == null)
                {
                    complexItemType = new EdmComplexType(NamespaceName, localPersonTypeName);
                    complexItemType.AddStructuralProperty("FirstName", EdmCoreModel.Instance.GetString(true));
                    complexItemType.AddStructuralProperty("LastName", EdmCoreModel.Instance.GetString(true));
                    model.AddElement(complexItemType);
                }

                itemTypeAnnotationType = complexItemType.ToTypeReference();
                collectionTypeAnnotationType = EdmCoreModel.GetCollection(itemTypeAnnotationType);
//.........这里部分代码省略.........
开发者ID:AlineGuan,项目名称:odata.net,代码行数:101,代码来源:TestValues.cs

示例5: CreateFeedQueryCountDescriptors

        private PayloadWriterTestDescriptor<ODataItem>[] CreateFeedQueryCountDescriptors()
        {
            Func<long?, ODataFeed> feedCreator = (c) =>
            {
                ODataFeed feed = ObjectModelUtils.CreateDefaultFeed();
                feed.Count = c;
                return feed;
            };

            long?[] counts = new long?[] { 0, 1, 2, 1000, -1 - 10, long.MaxValue, long.MinValue, null };

            EdmModel model = new EdmModel();
            ODataEntry entry = ObjectModelUtils.CreateDefaultEntryWithAtomMetadata("DefaultEntitySet", "DefaultEntityType", model);

            var container = model.FindEntityContainer("DefaultContainer");
            var entitySet = container.FindEntitySet("DefaultEntitySet") as EdmEntitySet;
            var entityType = model.FindType("TestModel.DefaultEntityType") as EdmEntityType;

            var descriptors = counts.Select(count => new PayloadWriterTestDescriptor<ODataItem>(this.Settings, feedCreator(count),
                (testConfiguration) =>
                {
                    if (testConfiguration.IsRequest && count.HasValue)
                    {
                        return new WriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                        {
                            ExpectedException2 = ODataExpectedExceptions.ODataException("ODataWriterCore_QueryCountInRequest")
                        };
                    }

                    if (testConfiguration.Format == ODataFormat.Atom)
                    {
                        if (count.HasValue)
                        {
                            return new AtomWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                            {
                                Xml = @"<m:count xmlns:m =""" + TestAtomConstants.ODataMetadataNamespace + @""">" + count + "</m:count>",
                                FragmentExtractor = (result) => result.Elements(XName.Get("count", TestAtomConstants.ODataMetadataNamespace)).Single()
                            };
                        }
                        else
                        {
                            return new AtomWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                            {
                                Xml = @"<nocount xmlns=""" + TestAtomConstants.ODataMetadataNamespace + @"""/>",
                                FragmentExtractor = (result) =>
                                    {
                                        var countElement = result.Elements(XName.Get("count", TestAtomConstants.ODataMetadataNamespace)).SingleOrDefault();
                                        if (countElement == null)
                                        {
                                            countElement = new XElement(TestAtomConstants.ODataMetadataXNamespace + "nocount");
                                        }
                                        return countElement;
                                    }
                            };
                        }
                    }
                    else if (testConfiguration.Format == ODataFormat.Json)
                    {
                        if (count.HasValue)
                        {
                            return new JsonWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                            {
                                Json = "$(Indent)$(Indent)\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataCountAnnotationName + "\":\"" + count + "\"",
                                FragmentExtractor = (result) => result.Object().Property(JsonLightConstants.ODataCountAnnotationName)
                            };
                        }
                        else
                        {
                            return new JsonWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                            {
                                Json = string.Join("$(NL)",
                                    "[",
                                    string.Empty,
                                    "]"),
                                FragmentExtractor = (result) =>
                                {
                                    return JsonLightWriterUtils.GetTopLevelFeedItemsArray(testConfiguration, result).RemoveAllAnnotations(true);
                                }
                            };
                        }
                    }
                    else
                    {
                        string formatName = testConfiguration.Format == null ? "null" : testConfiguration.Format.GetType().Name;
                        throw new NotSupportedException("Invalid format detected: " + formatName);
                    }
                })
                {
                    Model = model,
                    PayloadEdmElementContainer = entitySet,
                    PayloadEdmElementType = entityType,
                });

            return descriptors.ToArray();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:95,代码来源:WriterFeedTests.cs


注:本文中的Microsoft.OData.Edm.Library.EdmModel.FindEntityContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。