public IDecoder GetDecoder()
        {
            var jsonReader = new JsonReader(new DataReaderSettings(DefaultEncoderDecoderConfiguration.CombinedResolverStrategy()
                , new TeamCityDateFilter()), new[] { "application/.*json", "text/.*json" });

            var readers = new List<IDataReader> { jsonReader };
            var dataReaderProvider = new RegExBasedDataReaderProvider(readers);
            var defaultDecoder = new DefaultDecoder(dataReaderProvider)
            {
                ShouldRemoveAtSign = true
            };
            return defaultDecoder;
        }
Ejemplo n.º 2
0
            public void BecauseOf()
            {
                input =
                    "[{\"intAuthorID\":\"8\",\"strText\":\"test1\"},{\"intAuthorID\":\"5\",\"strText\":\"This message\"}]";

                IEnumerable <IDataReader> readers = new List <IDataReader>
                {
                    new JsonReader(
                        new DataReaderSettings(DefaultEncoderDecoderConfiguration.CombinedResolverStrategy()),
                        "application/.*json")
                };

                decoder = new DefaultDecoder(new RegExBasedDataReaderProvider(readers));
            }
Ejemplo n.º 3
0
            public void BecauseOf()
            {
                input =
                    "{\"html_attributions\": [],\"result\": {\"address_components\": [{\"long_name\": \"Church Street\",\"short_name\": \"Church Street\",\"types\": [\"route\"]},{\"long_name\": \"Wilmslow\",\"short_name\": \"Wilmslow\",\"types\": [\"locality\",\"political\"]},{\"long_name\": \"GB\",\"short_name\": \"GB\",\"types\": [\"country\",\"political\"]},{\"long_name\": \"SK9 1\",\"short_name\": \"SK9 1\",\"types\": [\"postal_code\"]}],\"formatted_address\": \"Church Street, Wilmslow, SK9 1, United Kingdom\",\"formatted_phone_number\": \"01625 538831\",\"geometry\": {\"location\": {\"lat\": 53.328908,\"lng\": -2.229191}},\"icon\": \"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png\",\"id\": \"51155a69bc03041b926e44f03a5bbe9feafb5035\",\"international_phone_number\": \"+44 1625 538831\",\"name\": \"Waitrose\",\"reference\": \"CmRfAAAAUZ4dYk9VpNJd1mFxa970TxVGgp9QTGeEa1BaU_wTWdTHNLCcB-9YyNu5LjgIewxo_oOna0KI9f_Z-Xff4CxvTf9wFHTHgE1wRGyCLLJo2BPjkGHo5Qem-Z-2_FKiY3gmEhA_Qs0jcQyFgVEs1BZAt_bdGhRerV30JziD2x7ZOMgxQTKlnH0yAQ\",\"types\": [\"grocery_or_supermarket\",\"food\",\"store\",\"establishment\"],\"url\": \"http://maps.google.com/maps/place?cid=14979720525476796445\",\"vicinity\": \"Church Street, Wilmslow\",\"website\": \"http://www.waitrose.com/wilmslow\"},\"status\": \"OK\"}";

                IEnumerable <IDataReader> readers = new List <IDataReader>
                {
                    new JsonReader(
                        new DataReaderSettings(DefaultEncoderDecoderConfiguration.CombinedResolverStrategy()),
                        "application/.*json")
                };

                decoder = new DefaultDecoder(new RegExBasedDataReaderProvider(readers));
            }
Ejemplo n.º 4
0
            public void BecauseOf()
            {
                input = "{\"LockedOutUntil\":\"/Date(1289073014137)/\"}";

                IEnumerable <IDataReader> readers = new List <IDataReader>
                {
                    new
                    JsonReader(new DataReaderSettings(DefaultEncoderDecoderConfiguration.CombinedResolverStrategy(),
                                                      new MSAjaxDateFilter(),
                                                      new Iso8601DateFilter()
                                                      ), "application/.*json")
                };

                decoder = new DefaultDecoder(new RegExBasedDataReaderProvider(readers));
            }
        public IDecoder GetDecoder()
        {
            var jsonReader = new JsonReader(new DataReaderSettings(DefaultEncoderDecoderConfiguration.CombinedResolverStrategy()
                                                                   , new TeamCityDateFilter()), new[] { "application/.*json", "text/.*json" });

            var readers = new List <IDataReader> {
                jsonReader
            };
            var dataReaderProvider = new RegExBasedDataReaderProvider(readers);
            var defaultDecoder     = new DefaultDecoder(dataReaderProvider)
            {
                ShouldRemoveAtSign = true
            };

            return(defaultDecoder);
        }
Ejemplo n.º 6
0
        public void when_decoding_an_object_with_custom_naming_of_property_should_decode_taking_into_account_custom_property_name()
        {
            var combinedResolverStrategy = new CombinedResolverStrategy(
                new JsonResolverStrategy(),
                new DataContractResolverStrategy(),
                new XmlResolverStrategy(),
                new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.PascalCase),
                new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.CamelCase),
                new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.Lowercase, "-"),
                new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.Uppercase, "_"));

            IEnumerable <IDataReader> readers = new List <IDataReader>
            {
                new JsonReader(new DataReaderSettings(combinedResolverStrategy), HttpContentTypes.ApplicationJson)
            };

            var decoder = new DefaultDecoder(new RegExBasedDataReaderProvider(readers));

            var obj = decoder.DecodeToStatic <CustomNaming>("{\"abc\":\"def\"}", "application/json");

            Assert.AreEqual("def", obj.PropertyName);
        }