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


C# Core.ODataComplexValue类代码示例

本文整理汇总了C#中Microsoft.OData.Core.ODataComplexValue的典型用法代码示例。如果您正苦于以下问题:C# ODataComplexValue类的具体用法?C# ODataComplexValue怎么用?C# ODataComplexValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ODataComplexValue类属于Microsoft.OData.Core命名空间,在下文中一共展示了ODataComplexValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssertODataComplexValueAreEqual

 private static void AssertODataComplexValueAreEqual(ODataComplexValue expectedComplexValue, ODataComplexValue actualComplexValue)
 {
     Assert.IsNotNull(expectedComplexValue);
     Assert.IsNotNull(actualComplexValue);
     Assert.AreEqual(expectedComplexValue.TypeName, actualComplexValue.TypeName);
     AssertODataPropertiesAreEqual(expectedComplexValue.Properties, actualComplexValue.Properties);
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:7,代码来源:ODataValueAssertEqualHelper.cs

示例2: ODataJsonLightInheritComplexCollectionWriterTests

        public ODataJsonLightInheritComplexCollectionWriterTests()
        {
            collectionStartWithoutSerializationInfo = new ODataCollectionStart();

            collectionStartWithSerializationInfo = new ODataCollectionStart();
            collectionStartWithSerializationInfo.SetSerializationInfo(new ODataCollectionStartSerializationInfo { CollectionTypeName = "Collection(ns.Address)" });

            address = new ODataComplexValue { Properties = new[]
            {
                new ODataProperty { Name = "Street", Value = "1 Microsoft Way" }, 
                new ODataProperty { Name = "Zipcode", Value = 98052 }, 
                new ODataProperty { Name = "State", Value = new ODataEnumValue("WA", "ns.StateEnum") }, 
                new ODataProperty { Name = "City", Value = "Shanghai" }
            }, TypeName = "TestNamespace.DerivedAddress" };
            items = new[] { address };

            EdmComplexType addressType = new EdmComplexType("ns", "Address");
            addressType.AddProperty(new EdmStructuralProperty(addressType, "Street", EdmCoreModel.Instance.GetString(isNullable: true)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "Zipcode", EdmCoreModel.Instance.GetInt32(isNullable: true)));
            var stateEnumType = new EdmEnumType("ns", "StateEnum", isFlags: true);
            stateEnumType.AddMember("IL", new EdmIntegerConstant(1));
            stateEnumType.AddMember("WA", new EdmIntegerConstant(2));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "State", new EdmEnumTypeReference(stateEnumType, true)));
            
            EdmComplexType derivedAddressType = new EdmComplexType("ns", "DerivedAddress", addressType, false);
            derivedAddressType.AddProperty(new EdmStructuralProperty(derivedAddressType, "City", EdmCoreModel.Instance.GetString(isNullable: true)));

            addressTypeReference = new EdmComplexTypeReference(addressType, isNullable: false);
            derivedAddressTypeReference = new EdmComplexTypeReference(derivedAddressType, isNullable: false);
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:30,代码来源:ODataJsonLightInheritComplexCollectionWriterTests.cs

示例3: MultipleTypeCustomInstanceAnnotationsOnErrorShouldRoundtrip

        public void MultipleTypeCustomInstanceAnnotationsOnErrorShouldRoundtrip()
        {
            var originalInt = new KeyValuePair<string, ODataValue>("int.error", new ODataPrimitiveValue(1));
            var originalDouble = new KeyValuePair<string, ODataValue>("double.error", new ODataPrimitiveValue(double.NaN));
            DateTimeOffset dateTimeOffset = new DateTimeOffset(2012, 10, 10, 12, 12, 59, new TimeSpan());
            var originalDateTimeOffset = new KeyValuePair<string, ODataValue>("DateTimeOffset.error", new ODataPrimitiveValue(dateTimeOffset));
            Date date = new Date(2014, 12, 12);
            var originalDate = new KeyValuePair<string, ODataValue>("Date.error", new ODataPrimitiveValue(date));
            TimeOfDay time = new TimeOfDay(10, 12, 3, 9);
            var originaltime = new KeyValuePair<string, ODataValue>("TimeOfDay.error", new ODataPrimitiveValue(time));
            TimeSpan timeSpan = new TimeSpan(12345);
            var originalTimeSpan = new KeyValuePair<string, ODataValue>("TimeSpan.error", new ODataPrimitiveValue(timeSpan));
            GeographyPoint geographyPoint = GeographyPoint.Create(32.0, -100.0);
            var originalGeography = new KeyValuePair<string, ODataValue>("Geography.error", new ODataPrimitiveValue(geographyPoint));
            var originalNull = new KeyValuePair<string, ODataValue>("null.error", new ODataNullValue());

            var complexValue = new ODataComplexValue
            {
                TypeName = "ns.ErrorDetails",
                Properties = new[] { new ODataProperty { Name = "ErrorDetailName", Value = "inner property value" } }
            };
            var originalComplex = new KeyValuePair<string, ODataValue>("sample.error", complexValue);

            var error = this.WriteThenReadErrorWithInstanceAnnotation(originalInt, originalDouble, originalDate, originalDateTimeOffset, originaltime, originalTimeSpan, originalGeography, originalNull, originalComplex);

            var annotation = RunBasicVerificationAndGetAnnotationValue("int.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(1);

            annotation = RunBasicVerificationAndGetAnnotationValue("double.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(double.NaN);

            annotation = RunBasicVerificationAndGetAnnotationValue("Date.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(date);

            annotation = RunBasicVerificationAndGetAnnotationValue("DateTimeOffset.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(dateTimeOffset);

            annotation = RunBasicVerificationAndGetAnnotationValue("TimeOfDay.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(time);

            annotation = RunBasicVerificationAndGetAnnotationValue("TimeSpan.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(timeSpan);

            annotation = RunBasicVerificationAndGetAnnotationValue("Geography.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(geographyPoint);

            annotation = RunBasicVerificationAndGetAnnotationValue("null.error", error);
            annotation.Should().BeOfType<ODataNullValue>();

            annotation = RunBasicVerificationAndGetAnnotationValue("sample.error", error);
            annotation.Should().BeOfType<ODataComplexValue>();
            annotation.As<ODataComplexValue>().Properties.First().Value.Should().Be("inner property value");
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:60,代码来源:CustomInstanceAnnotationRoundtrippingTests.cs

示例4: ReadComplexValue

        /// <summary>
        /// Deserializes the given <paramref name="complexValue"/> under the given <paramref name="readContext"/>.
        /// </summary>
        /// <param name="complexValue">The complex value to deserialize.</param>
        /// <param name="complexType">The EDM type of the complex value to read.</param>
        /// <param name="readContext">The deserializer context.</param>
        /// <returns>The deserialized complex value.</returns>
        public virtual object ReadComplexValue(ODataComplexValue complexValue, IEdmComplexTypeReference complexType,
            ODataDeserializerContext readContext)
        {
            if (complexValue == null)
            {
                throw Error.ArgumentNull("complexValue");
            }

            if (readContext == null)
            {
                throw Error.ArgumentNull("readContext");
            }

            if (readContext.Model == null)
            {
                throw Error.Argument("readContext", SRResources.ModelMissingFromReadContext);
            }

            object complexResource = CreateResource(complexType, readContext);
            foreach (ODataProperty complexProperty in complexValue.Properties)
            {
                DeserializationHelpers.ApplyProperty(complexProperty, complexType, complexResource, DeserializerProvider, readContext);
            }
            return complexResource;
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:32,代码来源:ODataComplexTypeDeserializer.cs

示例5: DefaultValuesAndPropertiesGetterAndSetterTest

 public void DefaultValuesAndPropertiesGetterAndSetterTest()
 {
     ODataComplexValue odataComplexValue = new ODataComplexValue();
     this.Assert.IsNull(odataComplexValue.Properties, "Expected null default value for property 'Properties'.");
     List<ODataProperty> properties = new List<ODataProperty>();
     odataComplexValue.Properties = properties;
     this.Assert.AreSame(odataComplexValue.Properties, properties, "Expected reference equal values for property 'Properties'.");
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:8,代码来源:ODataComplexValueTests.cs

示例6: PropertySettersNullTest

 public void PropertySettersNullTest()
 {
     ODataComplexValue odataComplexValue = new ODataComplexValue()
         {
             Properties = new List<ODataProperty>()
         };
     odataComplexValue.Properties = null;
     this.Assert.IsNull(odataComplexValue.Properties, "Expected null value for property 'Properties'.");
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:9,代码来源:ODataComplexValueTests.cs

示例7: ComplexWithPrimitiveValueShouldMaterialize

 public void ComplexWithPrimitiveValueShouldMaterialize()
 {
     ODataComplexValue pointComplexValue = new ODataComplexValue() {Properties = new ODataProperty[] {new ODataProperty() {Name = "X", Value = 15}, new ODataProperty() {Name = "Y", Value = 18}}};
     this.CreatePrimitiveValueMaterializationPolicy().MaterializeComplexTypeProperty(typeof(CollectionValueMaterializationPolicyTests.Point), pointComplexValue);
     pointComplexValue.HasMaterializedValue().Should().BeTrue();
     var point = pointComplexValue.GetMaterializedValue().As<CollectionValueMaterializationPolicyTests.Point>();
     point.X.Should().Be(15);
     point.Y.Should().Be(18);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:9,代码来源:ComplexValueMaterializationPolicyTests.cs

示例8: ComplexTypeRoundtripAtomTest

        public void ComplexTypeRoundtripAtomTest()
        {
            var age = new ODataProperty() { Name = "Age", Value = (Int16)18 };
            var email = new ODataProperty() { Name = "Email", Value = "[email protected]" };
            var tel = new ODataProperty() { Name = "Tel", Value = "0123456789" };
            var id = new ODataProperty() { Name = "ID", Value = Guid.Empty };

            ODataComplexValue complexValue = new ODataComplexValue() { TypeName = "NS.PersonalInfo", Properties = new[] { age, email, tel, id } };

            this.VerifyComplexTypeRoundtrip(complexValue, "NS.PersonalInfo");
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:11,代码来源:NonPrimitiveTypeRoundtripAtomTests.cs

示例9: ComplexTypeCollectionRoundtripAtomTest

        public void ComplexTypeCollectionRoundtripAtomTest()
        {
            ODataComplexValue subject0 = new ODataComplexValue() { TypeName = "NS.Subject", Properties = new[] { new ODataProperty() { Name = "Name", Value = "English" }, new ODataProperty() { Name = "Score", Value = (Int16)98 } } };
            ODataComplexValue subject1 = new ODataComplexValue() { TypeName = "NS.Subject", Properties = new[] { new ODataProperty() { Name = "Name", Value = "Math" }, new ODataProperty() { Name = "Score", Value = (Int16)90 } } };
            ODataCollectionValue complexCollectionValue = new ODataCollectionValue { TypeName = "Collection(NS.Subject)", Items = new[] { subject0, subject1 } };
            ODataFeedAndEntrySerializationInfo info = new ODataFeedAndEntrySerializationInfo() {
                NavigationSourceEntityTypeName = subject0.TypeName,
                NavigationSourceName = "Subjects",
                ExpectedTypeName = subject0.TypeName
            };

            this.VerifyTypeCollectionRoundtrip(complexCollectionValue, "Subjects", info);
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:13,代码来源:NonPrimitiveTypeRoundtripAtomTests.cs

示例10: TestBaseLine

        private void TestBaseLine(ODataComplexValue val, string resVcf, string resJson)
        {
            // Write json, compare with baseline
            Assert.AreEqual(
                TestHelper.GetResourceString(resJson),
                TestHelper.GetToplevelPropertyPayloadString(val),
                "Json baseline");

            // Write vcf, compare with baseline
            Assert.AreEqual(
                TestHelper.GetResourceString(resVcf),
                TestHelper.GetToplevelPropertyPayloadString(val, "text/x-vCard", VCardMediaTypeResolver.Instance),
                "Vcf baseline");
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:14,代码来源:ODataVCardScenarioTests.cs

示例11: PropertyGettersAndSettersTest

        public void PropertyGettersAndSettersTest()
        {
            string name1 = "ODataPrimitiveProperty";
            object value1 = "Hello world";

            ODataProperty primitiveProperty = new ODataProperty()
            {
                Name = name1,
                Value = value1,
            };

            this.Assert.AreEqual(name1, primitiveProperty.Name, "Expected equal name values.");
            this.Assert.AreSame(value1, primitiveProperty.Value, "Expected reference equal values for property 'Value'.");

            string name2 = "ODataComplexProperty";
            ODataComplexValue value2 = new ODataComplexValue()
            {
                Properties = new[]
                {
                    new ODataProperty() { Name = "One", Value = 1 },
                    new ODataProperty() { Name = "Two", Value = 2 },
                }
            };

            ODataProperty complexProperty = new ODataProperty()
            {
                Name = name2,
                Value = value2,
            };

            this.Assert.AreEqual(name2, complexProperty.Name, "Expected equal name values.");
            this.Assert.AreSame(value2, complexProperty.Value, "Expected reference equal values for property 'Value'.");

            string name3 = "ODataCollectionProperty";
            ODataCollectionValue value3 = new ODataCollectionValue()
            {
                Items = new[] { 1, 2, 3 }
            };

            ODataProperty multiValueProperty = new ODataProperty()
            {
                Name = name3,
                Value = value3,
            };

            this.Assert.AreEqual(name3, multiValueProperty.Name, "Expected equal name values.");
            this.Assert.AreSame(value3, multiValueProperty.Value, "Expected reference equal values for property 'Value'.");
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:48,代码来源:ODataPropertyTests.cs

示例12: CreateStructuredEdmValue

        internal static IEdmValue CreateStructuredEdmValue(ODataComplexValue complexValue, IEdmComplexTypeReference complexType)
        {
            if (complexType != null)
            {
                object typeAnnotation = ReflectionUtils.CreateInstance(
                    odataTypeAnnotationType,
                    new Type[] { typeof(IEdmComplexTypeReference) },
                    complexType);
                complexValue.SetAnnotation(typeAnnotation);
            }

            return (IEdmValue)ReflectionUtils.CreateInstance(
                odataEdmStructuredValueType,
                new Type[] { typeof(ODataComplexValue) },
                complexValue);
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:16,代码来源:ODataEdmValueUtils.cs

示例13: ReadInline_Calls_ReadComplexValue

        public void ReadInline_Calls_ReadComplexValue()
        {
            // Arrange
            ODataDeserializerProvider deserializerProvider = new DefaultODataDeserializerProvider();
            Mock<ODataComplexTypeDeserializer> deserializer = new Mock<ODataComplexTypeDeserializer>(deserializerProvider);
            ODataComplexValue item = new ODataComplexValue();
            ODataDeserializerContext readContext = new ODataDeserializerContext();

            deserializer.CallBase = true;
            deserializer.Setup(d => d.ReadComplexValue(item, _addressEdmType, readContext)).Returns(42).Verifiable();

            // Act
            object result = deserializer.Object.ReadInline(item, _addressEdmType, readContext);

            // Assert
            deserializer.Verify();
            Assert.Equal(42, result);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:18,代码来源:ODataComplexTypeDeserializerTests.cs

示例14: WriteEntryAndComplex

        public void WriteEntryAndComplex()
        {
            Action<ODataJsonLightOutputContext> test = outputContext =>
            {
                var entry = new ODataEntry();

                var complex = new ODataComplexValue() {Properties = new List<ODataProperty>() {new ODataProperty() {Name = "Name", Value = "ComplexName"}}};
                entry.Properties = new List<ODataProperty>() {new ODataProperty() {Name = "ID", Value = 1}, new ODataProperty() {Name = "complexProperty", Value = complex}};
                var parameterWriter = new ODataJsonLightParameterWriter(outputContext, operation: null);
                parameterWriter.WriteStart();
                var entryWriter = parameterWriter.CreateEntryWriter("entry");
                entryWriter.WriteStart(entry);
                entryWriter.WriteEnd();
                parameterWriter.WriteValue("complex", complex);
                parameterWriter.WriteEnd();
                parameterWriter.Flush();
            };

            WriteAndValidate(test, "{\"entry\":{\"ID\":1,\"complexProperty\":{\"Name\":\"ComplexName\"}},\"complex\":{\"Name\":\"ComplexName\"}}", writingResponse: false);
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:20,代码来源:ODataJsonLightParameterWriterTests.cs

示例15: ODataAvroWriterTests

        static ODataAvroWriterTests()
        {
            var type = new EdmEntityType("NS", "SimpleEntry");
            type.AddStructuralProperty("TBoolean", EdmPrimitiveTypeKind.Boolean, true);
            type.AddStructuralProperty("TInt32", EdmPrimitiveTypeKind.Int32, true);
            type.AddStructuralProperty("TCollection", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetInt64(false))));
            var cpx = new EdmComplexType("NS", "SimpleComplex");
            cpx.AddStructuralProperty("TBinary", EdmPrimitiveTypeKind.Binary, true);
            cpx.AddStructuralProperty("TString", EdmPrimitiveTypeKind.String, true);
            type.AddStructuralProperty("TComplex", new EdmComplexTypeReference(cpx, true));
            TestEntityType = type;

            binary0 = new byte[] { 4, 7 };
            complexValue0 = new ODataComplexValue()
            {
                Properties = new[]
                {
                    new ODataProperty {Name = "TBinary", Value = binary0 ,},
                    new ODataProperty {Name = "TString", Value = "iamstr",},
                },
                TypeName = "NS.SimpleComplex"
            };

            longCollection0 = new[] {7L, 9L};
            var collectionValue0 = new ODataCollectionValue { Items = longCollection0 };

            entry0 = new ODataEntry
            {
                Properties = new[]
                {
                    new ODataProperty {Name = "TBoolean", Value = true,},
                    new ODataProperty {Name = "TInt32", Value = 32,},
                    new ODataProperty {Name = "TComplex", Value = complexValue0,},
                    new ODataProperty {Name = "TCollection", Value = collectionValue0 },
                },
                TypeName = "NS.SimpleEntry"
            };
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:38,代码来源:ODataAvroWriterTests.cs


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