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


C# EdmEntityType.FullName方法代码示例

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


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

示例1: EdmPathExpressionWithInvalidNonInheritedTypeCastSegmentShouldError

        public void EdmPathExpressionWithInvalidNonInheritedTypeCastSegmentShouldError()
        {
            EdmEntityType entityType = new EdmEntityType("ds.s", "entityType");
            EdmEntityType otherEntityType = new EdmEntityType("ds.s", "otherEntityType");
            EdmModel model = new EdmModel();
            model.AddElement(entityType);
            model.AddElement(otherEntityType);

            EdmFunction function = new EdmFunction("ns", "GetStuff", new EdmEntityTypeReference(entityType, true), true /*isBound*/, new EdmPathExpression("bindingEntity/ds.s.otherEntityType"), false);
            function.AddParameter("bindingEntity", new EdmEntityTypeReference(entityType, false));
            model.AddElement(function);

            ValidateErrorInList(
                model,
                function,
                EdmErrorCode.InvalidPathInvalidTypeCastSegment,
                Strings.EdmModel_Validator_Semantic_InvalidEntitySetPathInvalidTypeCastSegment("EntitySetPath", "bindingEntity/ds.s.otherEntityType", entityType.FullName(), otherEntityType.FullName()));
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:18,代码来源:ExtensionMethodTests.cs

示例2: WriterStreamPropertiesTests

        public void WriterStreamPropertiesTests()
        {
            Uri baseUri = new Uri("http://www.odata.org/", UriKind.Absolute);
            Uri relativeReadLinkUri = new Uri("readlink", UriKind.RelativeOrAbsolute);
            Uri relativeEditLinkUri = new Uri("editlink", UriKind.RelativeOrAbsolute);
            Uri absoluteReadLinkUri = new Uri(baseUri, relativeReadLinkUri.OriginalString);
            Uri absoluteEditLinkUri = new Uri(baseUri, relativeEditLinkUri.OriginalString);

            string contentType = "application/binary";
            string etag = "\"myetagvalue\"";
            string streamPropertyName = "stream1";

            var namedStreamProperties = new[]
            {
                // with only read link
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = relativeReadLinkUri }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = relativeReadLinkUri, ContentType = contentType}},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = absoluteReadLinkUri }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = absoluteReadLinkUri, ContentType = contentType}},
                // with only edit link
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { EditLink = relativeEditLinkUri }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { EditLink = relativeEditLinkUri, ContentType = contentType }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { EditLink = relativeEditLinkUri, ContentType = contentType, ETag = etag }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { EditLink = absoluteEditLinkUri }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { EditLink = absoluteEditLinkUri, ContentType = contentType }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { EditLink = absoluteEditLinkUri, ContentType = contentType, ETag = etag }},
                // with both edit and read link
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = relativeReadLinkUri, EditLink = relativeEditLinkUri }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = relativeReadLinkUri, EditLink = relativeEditLinkUri, ContentType = contentType}},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = relativeReadLinkUri, EditLink = relativeEditLinkUri, ContentType = contentType, ETag = etag }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = absoluteReadLinkUri, EditLink = relativeEditLinkUri }},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = absoluteReadLinkUri, EditLink = relativeEditLinkUri, ContentType = contentType}},
                new ODataProperty { Name = streamPropertyName, Value = new ODataStreamReferenceValue { ReadLink = absoluteReadLinkUri, EditLink = relativeEditLinkUri, ContentType = contentType, ETag = etag }},
            };

            var testCases = namedStreamProperties.Select(property =>
            {
                var propertyName = property.Name;
                var streamReferenceValue = (ODataStreamReferenceValue)property.Value;
                return new StreamPropertyTestCase
                {
                    NamedStreamProperty = property,
                    GetExpectedAtomPayload = (testConfiguration) =>
                        {
                            return
                                (streamReferenceValue.ReadLink == null
                                    ? string.Empty
                                    : (
                                        "<link rel=\"http://docs.oasis-open.org/odata/ns/mediaresource/" + property.Name + "\" " +
                                        (streamReferenceValue.ContentType == null ? string.Empty : "type=\"" + streamReferenceValue.ContentType + "\" ") +
                                        "title=\"" + property.Name + "\" " +
                                        "href=\"" + (((ODataStreamReferenceValue)property.Value).ReadLink.IsAbsoluteUri ? absoluteReadLinkUri.OriginalString : relativeReadLinkUri.OriginalString) + "\" " +
                                        "xmlns=\"" + TestAtomConstants.AtomNamespace + "\" />")) +

                                (streamReferenceValue.EditLink == null
                                    ? string.Empty
                                    : (
                                        "<link rel=\"http://docs.oasis-open.org/odata/ns/edit-media/" + property.Name + "\" " +
                                        (streamReferenceValue.ContentType == null ? string.Empty : "type=\"" + streamReferenceValue.ContentType + "\" ") +
                                        "title=\"" + property.Name + "\" " +
                                        "href=\"" + (((ODataStreamReferenceValue)property.Value).EditLink.IsAbsoluteUri ? absoluteEditLinkUri.OriginalString : relativeEditLinkUri.OriginalString) + "\" " +
                                        (streamReferenceValue.ETag == null ? string.Empty : "m:etag=\"" + streamReferenceValue.ETag.Replace("\"", "&quot;") + "\" xmlns:m=\"" + TestAtomConstants.ODataMetadataNamespace + "\" ") +
                                        "xmlns=\"" + TestAtomConstants.AtomNamespace + "\" />"));
                        },
                    GetExpectedJsonLightPayload = (testConfiguration) =>
                        {
                            return JsonLightWriterUtils.CombineProperties(
                                (streamReferenceValue.EditLink == null ? string.Empty : ("\"" + JsonLightUtils.GetPropertyAnnotationName(propertyName, JsonLightConstants.ODataMediaEditLinkAnnotationName) + "\":\"" + absoluteEditLinkUri.OriginalString + "\"")),
                                (streamReferenceValue.ReadLink == null ? string.Empty : ("\"" + JsonLightUtils.GetPropertyAnnotationName(propertyName, JsonLightConstants.ODataMediaReadLinkAnnotationName) + "\":\"" + absoluteReadLinkUri.OriginalString + "\"")),
                                (streamReferenceValue.ContentType == null ? string.Empty : ("\"" + JsonLightUtils.GetPropertyAnnotationName(propertyName, JsonLightConstants.ODataMediaContentTypeAnnotationName) + "\":\"" + streamReferenceValue.ContentType + "\"")),
                                (streamReferenceValue.ETag == null ? string.Empty : ("\"" + JsonLightUtils.GetPropertyAnnotationName(propertyName, JsonLightConstants.ODataMediaETagAnnotationName) + "\":\"" + streamReferenceValue.ETag.Replace("\"", "\\\"") + "\"")));
                        },
                };
            });

            var testDescriptors = testCases.SelectMany(testCase =>
                {
                    EdmModel model = new EdmModel();
                    
                    EdmEntityType edmEntityType = new EdmEntityType("TestModel", "StreamPropertyEntityType");
                    EdmStructuralProperty edmStructuralProperty= edmEntityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false);
                    edmEntityType.AddKeys(new IEdmStructuralProperty[]{edmStructuralProperty});
                    model.AddElement(edmEntityType);

                    EdmEntityContainer edmEntityContainer = new EdmEntityContainer("TestModel", "DefaultContainer");
                    model.AddElement(edmEntityContainer);

                    EdmEntitySet edmEntitySet = new EdmEntitySet(edmEntityContainer, "StreamPropertyEntitySet", edmEntityType);
                    edmEntityContainer.AddElement(edmEntitySet);

                    ODataEntry entry = new ODataEntry()
                    {
                        Id = ObjectModelUtils.DefaultEntryId,
                        ReadLink = ObjectModelUtils.DefaultEntryReadLink,
                        TypeName = edmEntityType.FullName()
                    };
                    
                    var streamReference = (ODataStreamReferenceValue)testCase.NamedStreamProperty.Value;
                    bool needBaseUri = (streamReference.ReadLink != null && !streamReference.ReadLink.IsAbsoluteUri) || (streamReference.EditLink != null && !streamReference.EditLink.IsAbsoluteUri);
                    entry.Properties = new ODataProperty[] { testCase.NamedStreamProperty };
//.........这里部分代码省略.........
开发者ID:larsenjo,项目名称:odata.net,代码行数:101,代码来源:WriterStreamPropertyTests.cs

示例3: AddEntityType

        /// <summary>Adds a new entity type (without any properties).</summary>
        /// <param name="name">The name of the type.</param>
        /// <param name="instanceType">The instance type or null if this should be untyped resource.</param>
        /// <param name="baseType">The base type.</param>
        /// <param name="isAbstract">If the type should be abstract.</param>
        /// <param name="nameSpace">The namespace of the entity type</param>
        /// <returns>The newly created entity type.</returns>
        public IEdmEntityType AddEntityType(string name, Type instanceType, IEdmEntityType baseType, bool isAbstract, string nameSpace, bool isOpen = false)
        {
            EdmEntityType entityType = new EdmEntityType(
                this.namespaceName,
                name,
                baseType,
                isAbstract,
                isOpen);

            this.entityTypes.Add(entityType.FullName(), entityType);

            if (entityType.BaseType != null)
            {
                List<IEdmStructuredType> derivedTypes;
                if (!this.derivedTypeMappings.TryGetValue(entityType.BaseType, out derivedTypes))
                {
                    derivedTypes = new List<IEdmStructuredType>();
                    this.derivedTypeMappings[entityType.BaseType] = derivedTypes;
                }
            }

            return entityType;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:30,代码来源:ConstructableMetadata.cs

示例4: DefaultStreamMetadataWcfDSServerTest

        public void DefaultStreamMetadataWcfDSServerTest()
        {

            EdmModel model = new EdmModel();
            var cityType = new EdmEntityType("TestModel", "CityType");
            model.AddElement(cityType);
            var cityWithMapType = new EdmEntityType("TestModel", "CityWithMapType", null, false, false, true);
            model.AddElement(cityWithMapType);

            var container = new EdmEntityContainer("TestModel", "TestContainer");
            container.AddEntitySet("CityType", cityType);
            container.AddEntitySet("CityWithMapType", cityWithMapType);
            model.AddElement(container);

            IEnumerable<PayloadWriterTestDescriptor<ODataItem>> testDescriptors =
                // non-MLE payload and non-MLE type
                NonMLEDefaultStreamValues.Select(mr => this.CreateDefaultStreamMetadataTestDescriptor(model, cityType.FullName(), mr))
                // non-MLE payload and MLE type
                .Concat(NonMLEDefaultStreamValues.Select(mr => this.CreateDefaultStreamMetadataTestDescriptor(model, cityWithMapType.FullName(), mr,
                    ODataExpectedExceptions.ODataException("ValidationUtils_EntryWithoutMediaResourceAndMLEType", "TestModel.CityWithMapType"))))
                // MLE payload and non-MLE type
                .Concat(MLEDefaultStreamValues.Select(mr => this.CreateDefaultStreamMetadataTestDescriptor(model, cityType.FullName(), mr,
                    ODataExpectedExceptions.ODataException("ValidationUtils_EntryWithMediaResourceAndNonMLEType", "TestModel.CityType"))))
                // MLE payload and MLE type
                .Concat(MLEDefaultStreamValues.Select(mr => this.CreateDefaultStreamMetadataTestDescriptor(model, cityWithMapType.FullName(), mr)));

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.WriterTestConfigurationProvider.AtomFormatConfigurations,
                (testDescriptor, testConfiguration) =>
                {
                    testConfiguration = testConfiguration.Clone();
                    testConfiguration.MessageWriterSettings.EnableODataServerBehavior(false);
                    testConfiguration.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri);
                    TestWriterUtils.WriteAndVerifyODataPayload(testDescriptor, testConfiguration, this.Assert, this.Logger);
                });
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:37,代码来源:WriterMetadataInputValidationTests.cs

示例5: GeolocatedUriTest

        public void GeolocatedUriTest()
        {
            // Geolocated URIs are cases where the read/edit/etc URIs for the same resource use different services
            string baseUri = "http://www.test.com/foo.svc/Target";

            EdmModel model = new EdmModel();
            var mleType = new EdmEntityType("TestModel", "MediaLinkType", null, false, false, true);
            mleType.AddKeys(mleType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(mleType);

            var entityType = new EdmEntityType("TestModel", "GeolocatedUriType");
            entityType.AddKeys(entityType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetString(true)));
            var navProp = entityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "NavProp", Target = mleType, TargetMultiplicity = EdmMultiplicity.Many });
            entityType.AddStructuralProperty("StreamProperty", EdmPrimitiveTypeKind.Stream);
            model.AddElement(entityType);

            var container = new EdmEntityContainer("TestModel", "DefaultContainer");
            var mleSet = container.AddEntitySet("MediaLinkSet", mleType);
            var entitySet = container.AddEntitySet("GeolocatedUriSet", entityType);
            model.AddElement(container);
            entitySet.AddNavigationTarget(navProp, mleSet);

            var testDescriptors = new[]
            {
                new PayloadReaderTestDescriptor(this.Settings) 
                { 
                    PayloadElement = PayloadBuilder.Entity(entityType.FullName())
                        .PrimitiveProperty("Id", System.Guid.NewGuid().ToString())
                        .Property(PayloadBuilder.NavigationProperty("NavProp", baseUri.Replace("foo", "geo1"), baseUri.Replace("foo", "geo2")).IsCollection(true))
                        .StreamProperty("StreamProperty", baseUri.Replace("foo", "read"), baseUri.Replace("foo", "edit"))
                        .ExpectedEntityType(entityType, entitySet),
                    PayloadEdmModel = model,
                    // No stream properties in requests or <V3 payloads
                    SkipTestConfiguration = tc => tc.IsRequest
                },
                new PayloadReaderTestDescriptor(this.Settings) 
                { 
                    PayloadElement = PayloadBuilder.Entity(mleType.FullName())
                        .EnsureMediaLinkEntry()
                        .PrimitiveProperty("Id", System.Guid.NewGuid().ToString())
                        .StreamContentType("image/jpeg")
                        .StreamEditLink(baseUri.Replace("foo", "edit-stream"))
                        .StreamSourceLink(baseUri.Replace("foo", "source-stream"))
                        .ExpectedEntityType(mleType, mleSet),
                    PayloadEdmModel = model 
                },
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations,
                new[] { true, false },
                (testDescriptor, testConfiguration, withBaseUri) =>
                {
                    var actualConfiguration = new ReaderTestConfiguration(testConfiguration);
                    actualConfiguration.MessageReaderSettings.BaseUri = withBaseUri ? new Uri(baseUri) : (testConfiguration.Format != ODataFormat.Json ? null : new Uri(baseUri));
                    testDescriptor.RunTest(actualConfiguration);
                });
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:59,代码来源:EntryReaderTests.cs

示例6: ToEdmTestDescriptor

            public PayloadWriterTestDescriptor<ODataItem> ToEdmTestDescriptor(PayloadWriterTestDescriptor.Settings settings, EdmModel model = null, EdmEntitySet entitySet = null, EdmEntityType entityType = null)
            {
                ODataEntry entry = ObjectModelUtils.CreateDefaultEntry();
                entry.TypeName = entityType == null ? null : entityType.FullName();

                return new PayloadWriterTestDescriptor<ODataItem>(
                    settings,
                    new ODataItem[] { entry }.Concat(this.Items).ToArray(),
                    testConfiguration =>
                    {
                        ExpectedException expectedException = this.ExpectedException;
                        if (this.EdmExpectedExceptionCallback != null)
                        {
                            expectedException = this.EdmExpectedExceptionCallback(testConfiguration, model);
                        }

                        if (testConfiguration.Format == ODataFormat.Atom)
                        {
                            return new AtomWriterTestExpectedResults(settings.ExpectedResultSettings)
                            {
                                FragmentExtractor = result => new XElement("results",
                                    result.Elements(TestAtomConstants.AtomXNamespace + "link")
                                        .Where(e => e.Attribute("rel").Value == (TestAtomConstants.ODataNavigationPropertiesRelatedLinkRelationPrefix + this.PropertyName))),
                                Xml = "<results>" + this.Xml + "</results>",
                                ExpectedException2 = expectedException
                            };
                        }
                        else if (testConfiguration.Format == ODataFormat.Json)
                        {
                            return new JsonWriterTestExpectedResults(settings.ExpectedResultSettings)
                            {
                                FragmentExtractor = result => new JsonObject().AddProperties(result.RemoveAllAnnotations(true).Object().GetPropertyAnnotationsAndProperty(this.PropertyName)),
                                Json = this.JsonLight,
                                ExpectedException2 = expectedException
                            };
                        }
                        else
                        {
                            settings.Assert.Fail("Unsupported format {0}", testConfiguration.Format);
                            return null;
                        }
                    })
                {
                    SkipTestConfiguration = this.SkipTestConfiguration,
                    Model = model,
                    PayloadEdmElementContainer = entitySet,
                    PayloadEdmElementType = entityType,
                };
            }
开发者ID:larsenjo,项目名称:odata.net,代码行数:49,代码来源:WriterNavigationLinkTests.cs

示例7: CreateDefaultEntryWithAtomMetadata

        /// <summary>
        /// Creates an ODataEntry instance with the default values for 'Id', 'ReadLink' and 'Updated'
        /// that can be used and modified in tests.
        /// </summary>
        /// <param name="typeName">The optional type name for the default entry.</param>
        /// <param name="model">The product model to generate the type in (if not null).</param>
        /// <returns>The newly created ODataEntry instance.</returns>
        public static ODataEntry CreateDefaultEntryWithAtomMetadata(string entitySetName = null, string typeName = null, EdmModel model = null)
        {
            if (model != null && typeName != null)
            {
                EdmEntityType entityType = new EdmEntityType(DefaultNamespaceName, typeName);
                entityType.AddKeys(entityType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(isNullable: false)));
                model.AddElement(entityType);

                typeName = entityType.FullName();

                EdmEntityContainer container = new EdmEntityContainer(DefaultNamespaceName, "DefaultContainer");
                model.AddElement(container);

                if (entitySetName != null)
                {
                    container.AddEntitySet(entitySetName, entityType);
                }
            }

            ODataEntry entry = new ODataEntry()
            {
                Id = DefaultEntryId,
                ReadLink = DefaultEntryReadLink,
                TypeName = typeName,
                SerializationInfo = MySerializationInfo
            };
            AtomEntryMetadata metadata = new AtomEntryMetadata()
            {
                Updated = DateTimeOffset.Parse(DefaultEntryUpdated)
            };
            entry.SetAnnotation<AtomEntryMetadata>(metadata);
            return entry;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:40,代码来源:ObjectModelUtils.cs

示例8: GeolocatedUriTest

        // [TestMethod, Variation(Description = "Verify correct parsing of entries with geolocated URIs")]
        public void GeolocatedUriTest()
        {
            // Geolocated URIs are cases where the read/edit/etc URIs for the same resource use different services
            string baseUri = "http://www.test.com/foo.svc/Target";

            EdmModel model = new EdmModel();

            var mleType = new EdmEntityType("TestModel", "MediaLinkType", null, false, false, true);
            model.AddElement(mleType);

            var entityType = new EdmEntityType("TestModel", "GeolocatedUriType");
            entityType.AddKeys(entityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.String, isNullable: true));
            var navProp = entityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "NavProp", Target = mleType, TargetMultiplicity = EdmMultiplicity.Many });
            entityType.AddStructuralProperty("StreamProperty", EdmPrimitiveTypeKind.Stream, isNullable: false);
            model.AddElement(entityType);

            var container = new EdmEntityContainer("TestModel", "DefaultContainer");
            var mediaLinkSet = container.AddEntitySet("MediaLinkType", mleType);
            var geolocatedUriSet = container.AddEntitySet("GeolocatedUriType", entityType);
            geolocatedUriSet.AddNavigationTarget(navProp, mediaLinkSet);
            model.AddElement(container);

            EntityInstance entityInstance = PayloadBuilder.Entity(entityType.FullName())
                .Property("Id", PayloadBuilder.PrimitiveValue(System.Guid.NewGuid().ToString()))
                .Property(PayloadBuilder.DeferredNavigationProperty("NavProp",
                    PayloadBuilder.DeferredLink(baseUri.Replace("foo", "geo1")).IsCollection(true),
                    PayloadBuilder.DeferredLink(baseUri.Replace("foo", "geo2"))))
                .StreamProperty("StreamProperty", baseUri.Replace("foo", "read"), baseUri.Replace("foo", "edit"));

            entityInstance.Id = "1";

            EntityInstance mleInstance = PayloadBuilder.Entity(mleType.FullName()).EnsureMediaLinkEntry();
            mleInstance.Id = "1";
            mleInstance.StreamContentType = "image/jpeg";
            mleInstance.StreamEditLink = baseUri.Replace("foo", "edit-stream");
            mleInstance.StreamSourceLink = baseUri.Replace("foo", "source-stream");

            var testDescriptors = new[]
            {
                new PayloadWriterTestDescriptor<ODataPayloadElement>(this.Settings,entityInstance)
                { 
                    Model = model,
                    PayloadDescriptor = new PayloadTestDescriptor()
                    {
                        PayloadElement = entityInstance
                    },
                    ExpectedResultCallback = (tc) =>
                    {
                        return new PayloadWriterTestExpectedResults(this.ExpectedResultSettings)
                        {
                            ExpectedPayload = entityInstance,
                        };
                    },
                },
                new PayloadWriterTestDescriptor<ODataPayloadElement>(this.Settings, mleInstance)
                {
                    Model = model,
                    PayloadDescriptor = new PayloadTestDescriptor()
                    {
                        PayloadElement = mleInstance
                    },
                    ExpectedResultCallback = (tc) =>
                    {
                        return new PayloadWriterTestExpectedResults(this.ExpectedResultSettings)
                        {
                            ExpectedPayload = mleInstance
                        };
                    },
                },
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.WriterTestConfigurationProvider.JsonLightFormatConfigurationsWithIndent,
                (testDescriptor, testConfiguration) =>
                {
                    testDescriptor.RunTest(testConfiguration, this.Logger);
                });
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:80,代码来源:WriterEntryTests.cs

示例9: CreateOpenEntitySetInstance

        /// <summary>
        /// Generates an open entity set containing entities with different amounts of primitive open properties.
        /// </summary>
        /// <param name="model">The entity model. The method will modify the model and call Fixup().</param>
        /// <param name="withTypeNames">True if the payloads should specify type names.</param>
        /// <param name="primitiveValueFilter">A function for excluding primitives which are unsupported for open properties.</param>
        /// <returns>The open entity set containing entities with primitive open properties.</returns>
        public static ODataPayloadElement CreateOpenEntitySetInstance(EdmModel model, bool withTypeNames, Func<PrimitiveValue, bool> primitiveValueFilter)
        {
            ExceptionUtilities.CheckArgumentNotNull(model, "model");
            ExceptionUtilities.CheckArgumentNotNull(primitiveValueFilter, "primitiveValueFilter");

            var edmEntityType = new EdmEntityType("TestModel", "OpenEntityType", baseType: null, isAbstract: false, isOpen: true);
            model.AddElement(edmEntityType);
            edmEntityType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String, true);

            var container = new EdmEntityContainer("TestModel", "DefaultContainer");
            container.AddEntitySet("OpenEntityTypes", edmEntityType);
            model.AddElement(container);

            var feed = PayloadBuilder.EntitySet().WithTypeAnnotation(edmEntityType);

            string entityTypeName = withTypeNames ? edmEntityType.FullName() : null;

            var primitiveValues = TestValues.CreatePrimitiveValuesWithMetadata(true).Where(p => primitiveValueFilter(p));

            int idx = 0;
            for (int i = 0; i <= primitiveValues.Count(); ++i)
            {
                var entityInstance = PayloadBuilder.Entity(entityTypeName).PrimitiveProperty("Name", Guid.NewGuid().ToString());
                foreach (var property in primitiveValues.Take(i))
                {
                    entityInstance.PrimitiveProperty("Property" + (idx++), property.ClrValue);
                }
                feed.Add(entityInstance);
            }
            return feed;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:38,代码来源:TestFeeds.cs


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