當前位置: 首頁>>代碼示例>>C#>>正文


C# ODataEntityDeserializer.CreateEntityResource方法代碼示例

本文整理匯總了C#中System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer.CreateEntityResource方法的典型用法代碼示例。如果您正苦於以下問題:C# ODataEntityDeserializer.CreateEntityResource方法的具體用法?C# ODataEntityDeserializer.CreateEntityResource怎麽用?C# ODataEntityDeserializer.CreateEntityResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer的用法示例。


在下文中一共展示了ODataEntityDeserializer.CreateEntityResource方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateEntityResource_CreatesDeltaOfT_IfPatchMode

        public void CreateEntityResource_CreatesDeltaOfT_IfPatchMode()
        {
            var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
            ODataDeserializerContext readContext = new ODataDeserializerContext
            {
                Model = _readContext.Model,
                IsPatchMode = true,
                PatchEntityType = typeof(Delta<Product>)
            };

            Assert.IsType<Delta<Product>>(deserializer.CreateEntityResource(readContext));
        }
開發者ID:brianly,項目名稱:aspnetwebstack,代碼行數:12,代碼來源:ODataEntityDeserializerTests.cs

示例2: CreateEntityResource_CreatesT_IfNotPatchMode

        public void CreateEntityResource_CreatesT_IfNotPatchMode()
        {
            var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
            ODataDeserializerContext readContext = new ODataDeserializerContext
            {
                Model = _readContext.Model,
                IsPatchMode = false
            };

            Assert.IsType<Product>(deserializer.CreateEntityResource(readContext));
        }
開發者ID:brianly,項目名稱:aspnetwebstack,代碼行數:11,代碼來源:ODataEntityDeserializerTests.cs

示例3: CreateEntityResource_ThrowsODataException_MappingDoesNotContainEntityType

 public void CreateEntityResource_ThrowsODataException_MappingDoesNotContainEntityType()
 {
     var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
     Assert.Throws<ODataException>(
         () => deserializer.CreateEntityResource(new ODataDeserializerContext { Model = EdmCoreModel.Instance }),
         "The provided mapping doesn't contain an entry for the entity type 'ODataDemo.Product'.");
 }
開發者ID:brianly,項目名稱:aspnetwebstack,代碼行數:7,代碼來源:ODataEntityDeserializerTests.cs

示例4: CreateEntityResource_ThrowsArgument_ModelMissingFromReadContext

 public void CreateEntityResource_ThrowsArgument_ModelMissingFromReadContext()
 {
     var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
     Assert.ThrowsArgument(
         () => deserializer.CreateEntityResource(new ODataDeserializerContext()),
         "readContext",
         "The EDM model is missing on the read context. The model is required on the read context to deserialize the payload.");
 }
開發者ID:brianly,項目名稱:aspnetwebstack,代碼行數:8,代碼來源:ODataEntityDeserializerTests.cs

示例5: CreateEntityResource_ThrowsArgumentNull_ReadContext

 public void CreateEntityResource_ThrowsArgumentNull_ReadContext()
 {
     var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
     Assert.ThrowsArgumentNull(
         () => deserializer.CreateEntityResource(readContext: null),
         "readContext");
 }
開發者ID:brianly,項目名稱:aspnetwebstack,代碼行數:7,代碼來源:ODataEntityDeserializerTests.cs

示例6: CreateEntityResource_CreatesEdmEntityObject_IfTypeLessMode

        public void CreateEntityResource_CreatesEdmEntityObject_IfTypeLessMode()
        {
            // Arrange
            var deserializer = new ODataEntityDeserializer(_deserializerProvider);
            ODataDeserializerContext readContext = new ODataDeserializerContext
            {
                Model = _readContext.Model,
                ResourceType = typeof(IEdmObject)
            };

            // Act
            var result = deserializer.CreateEntityResource(_productEdmType, readContext);

            // Assert
            EdmEntityObject resource = Assert.IsType<EdmEntityObject>(result);
            Assert.Equal(_productEdmType, resource.GetEdmType(), new EdmTypeReferenceEqualityComparer());
        }
開發者ID:normalian,項目名稱:aspnetwebstack,代碼行數:17,代碼來源:ODataEntityDeserializerTests.cs

示例7: CreateEntityResource_CreatesDeltaWith_ExpectedUpdatableProperties

        public void CreateEntityResource_CreatesDeltaWith_ExpectedUpdatableProperties()
        {
            // Arrange
            var deserializer = new ODataEntityDeserializer(_deserializerProvider);
            ODataDeserializerContext readContext = new ODataDeserializerContext
            {
                Model = _readContext.Model,
                ResourceType = typeof(Delta<Product>)
            };
            var structuralProperties = _productEdmType.StructuralProperties().Select(p => p.Name);

            // Act
            Delta<Product> resource = deserializer.CreateEntityResource(_productEdmType, readContext) as Delta<Product>;

            // Assert
            Assert.NotNull(resource);
            Assert.Equal(structuralProperties, resource.GetUnchangedPropertyNames());
        }
開發者ID:huangw-t,項目名稱:aspnetwebstack,代碼行數:18,代碼來源:ODataEntityDeserializerTests.cs


注:本文中的System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer.CreateEntityResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。