private static ODataProperty ReadStringPropertyUnderServerKnob(string payload)
 {
     MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(payload));
     ODataMessageReaderSettings settings = new ODataMessageReaderSettings();
     settings.EnableODataServerBehavior();
     ODataAtomInputContext context = new ODataAtomInputContext(ODataFormat.Atom, memoryStream, Encoding.UTF8, settings, false /*readingResponse*/, true /*sync*/, EdmModel, null);
     var deserializer = new ODataAtomPropertyAndValueDeserializer(context);
     return deserializer.ReadTopLevelProperty(StringProperty, StringProperty.Type);
 }
        private static ODataProperty ReadStringPropertyUnderServerKnob(string payload)
        {
            MemoryStream memoryStream           = new MemoryStream(Encoding.UTF8.GetBytes(payload));
            ODataMessageReaderSettings settings = new ODataMessageReaderSettings();

            settings.EnableODataServerBehavior();
            ODataAtomInputContext context = new ODataAtomInputContext(ODataFormat.Atom, memoryStream, Encoding.UTF8, settings, false /*readingResponse*/, true /*sync*/, EdmModel, null);
            var deserializer = new ODataAtomPropertyAndValueDeserializer(context);

            return(deserializer.ReadTopLevelProperty(StringProperty, StringProperty.Type));
        }
Esempio n. 3
0
        public void SetBehaviorTest()
        {
            ODataMessageReaderSettings settings = new ODataMessageReaderSettings();

            settings.EnableWcfDataServicesClientBehavior(null);
            this.CompareReaderBehavior(
                settings,
                /*formatBehaviorKind*/ ODataBehaviorKind.WcfDataServicesClient,
                /*apiBehaviorKind*/ ODataBehaviorKind.WcfDataServicesClient,
                true,
                /*typeResolver*/ null);

            Func <IEdmType, string, IEdmType> customTypeResolver = (expectedType, typeName) => expectedType;

            settings.EnableWcfDataServicesClientBehavior(customTypeResolver);
            this.CompareReaderBehavior(
                settings,
                /*formatBehaviorKind*/ ODataBehaviorKind.WcfDataServicesClient,
                /*apiBehaviorKind*/ ODataBehaviorKind.WcfDataServicesClient,
                true,
                customTypeResolver);

            settings.EnableODataServerBehavior();
            this.CompareReaderBehavior(
                settings,
                /*formatBehaviorKind*/ ODataBehaviorKind.ODataServer,
                /*apiBehaviorKind*/ ODataBehaviorKind.ODataServer,
                true,
                /*typeResolver*/ null);

            settings.EnableDefaultBehavior();
            this.CompareReaderBehavior(
                settings,
                /*formatBehaviorKind*/ ODataBehaviorKind.Default,
                /*apiBehaviorKind*/ ODataBehaviorKind.Default,
                false,
                /*typeResolver*/ null);
        }