コード例 #1
0
        public AquaContractResolver(IContractResolver?decorated = null)
        {
            if (decorated is AquaContractResolver self)
            {
                decorated = self._decorated;
            }

            _decorated = decorated?.GetType() == typeof(DefaultContractResolver) ? null : decorated;
        }
コード例 #2
0
        public AquaContractResolver(KnownTypesRegistry knownTypes, IContractResolver?decorated = null)
        {
            if (decorated is AquaContractResolver self)
            {
                decorated = self._decorated;
            }

            _knownTypes = knownTypes.CheckNotNull(nameof(knownTypes));
            _decorated  = decorated?.GetType() == typeof(DefaultContractResolver) ? null : decorated;
        }
コード例 #3
0
        private static string ToCamelCaseIfNeeded(string input, IContractResolver resolver)
        {
            if (resolver == null)
            {
                return(input);
            }

            if (resolver.GetType().IsAssignableFrom(typeof(CamelCasePropertyNamesContractResolver)))
            {
                return(ToCamelCase(input));
            }
            else
            {
                return(input);
            }
        }
コード例 #4
0
        public void Initialize_CamelCaseFormatterIsSet()
        {
            IContractResolver contractResolver = controller.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver;

            Assert.AreEqual(contractResolver.GetType(), typeof(CamelCasePropertyNamesContractResolver));
        }