Ejemplo n.º 1
0
        public void Serialize_Enum_UnquotedEnum()
        {
            var jsonSettingConverter = JsonSettingConverterFactory.CreateDefault();

            var result = jsonSettingConverter.Serialize(TestEnum.Bar, new HashSet <Type>());

            Assert.AreEqual("Bar", result);
        }
Ejemplo n.º 2
0
        public void Deserialize_QuotedEnumString_Enum()
        {
            var jsonSettingConverter = JsonSettingConverterFactory.CreateDefault();

            var result = jsonSettingConverter.Deserialize(@"""bar""", typeof(TestEnum));

            Assert.AreEqual(TestEnum.Bar, result);
        }
Ejemplo n.º 3
0
        public static IConfigurationProperties UseJsonConverter([NotNull] this IConfigurationProperties properties, [NotNull] Action <JsonSettingConverter> jsonSettingConverterAction)
        {
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }
            if (jsonSettingConverterAction == null)
            {
                throw new ArgumentNullException(nameof(jsonSettingConverterAction));
            }

            var converter = JsonSettingConverterFactory.CreateDefault();

            jsonSettingConverterAction.Invoke(converter);
            properties.Converter = converter;
            return(properties);
        }