Beispiel #1
0
        private static string BuildName(MemberInfo member, TypeOptions options)
        {
            var customName = member.GetCustomAttribute <JsonPropertyAttribute>()?.Name;

            if (!string.IsNullOrEmpty(customName))
            {
                return(customName);
            }
            if (options.HasFlag(TypeOptions.CamelCase))
            {
                return(CamelCase.ToCamelCase(member.Name));
            }
            return(member.Name);
        }
Beispiel #2
0
        private static IEnumerable <string> JsonNames(MemberInfo property)
        {
            var customName = property.GetCustomAttribute <JsonPropertyAttribute>()?.Name;

            if (!string.IsNullOrEmpty(customName))
            {
                yield return(customName);

                yield break;
            }

            yield return(property.Name);

            yield return(CamelCase.ToCamelCase(property.Name));

            yield return(property.Name.ToLower());
        }