ToTitleCase() static private method

static private ToTitleCase ( string str ) : string
str string
return string
Ejemplo n.º 1
0
        private static JsonTypeEnum GetFirstTypeEnum(JToken token)
        {
            JTokenType type = token.HasValues
                ? token.Type
                : (JTokenType)Enum.Parse(typeof(JTokenType),
                                         JsonClassGenerator.ToTitleCase(token.Value <string>()));

            switch (type)
            {
            case JTokenType.Array: return(JsonTypeEnum.Array);

            case JTokenType.Boolean: return(JsonTypeEnum.Boolean);

            case JTokenType.Float: return(JsonTypeEnum.Float);

            case JTokenType.Integer: return(JsonTypeEnum.Integer);

            case JTokenType.Null: return(JsonTypeEnum.NullableSomething);

            case JTokenType.Undefined: return(JsonTypeEnum.NullableSomething);

            case JTokenType.String: return(JsonTypeEnum.String);

            case JTokenType.Object: return(JsonTypeEnum.Object);

            case JTokenType.Date: return(JsonTypeEnum.Date);

            default: return(JsonTypeEnum.Anything);
            }
        }
Ejemplo n.º 2
0
 public FieldInfo(IJsonClassGeneratorConfig generator, string jsonMemberName, JsonType type, bool usePascalCase, IList <object> Examples)
 {
     this.generator      = generator;
     this.JsonMemberName = jsonMemberName;
     this.MemberName     = JsonClassGenerator.ToTitleCase(jsonMemberName);
     this.Type           = type;
     this.Examples       = Examples;
 }
Ejemplo n.º 3
0
 public FieldInfo(IJsonClassGeneratorConfig generator, string jsonMemberName, JsonType type, bool usePascalCase, IList <object> Examples)
 {
     this.generator      = generator;
     this.JsonMemberName = jsonMemberName;
     this.MemberName     = Regex.Replace(jsonMemberName, "[^\\w]", "");
     if (usePascalCase)
     {
         MemberName = JsonClassGenerator.ToTitleCase(MemberName);
     }
     this.Type     = type;
     this.Examples = Examples;
 }
Ejemplo n.º 4
0
 public FieldInfo(IJsonClassGeneratorConfig generator, string jsonMemberName, JsonType type, bool usePascalCase, IList <object> Examples)
 {
     this.generator      = generator;
     this.JsonMemberName = jsonMemberName;
     this.MemberName     = jsonMemberName;
     if (usePascalCase)
     {
         // This does nothing if the json is already in Title case
         // which may confuse some people when it's turned off
         MemberName = JsonClassGenerator.ToTitleCase(MemberName);
     }
     this.Type     = type;
     this.Examples = Examples;
 }
Ejemplo n.º 5
0
        public FieldInfo(IJsonClassGeneratorConfig generator, string jsonMemberName, JsonType type, bool usePascalCase, bool useJsonAttributes, bool useJsonPropertyName, IList <object> Examples)
        {
            this.generator      = generator;
            this.JsonMemberName = jsonMemberName;
            this.MemberName     = jsonMemberName;
            bool constainsSpecialChars = isContainsSpecialChars(MemberName);

            ContainsSpecialChars = constainsSpecialChars;
            if (usePascalCase || useJsonAttributes || useJsonPropertyName || constainsSpecialChars)
            {
                MemberName = JsonClassGenerator.ToTitleCase(MemberName);
            }
            this.Type     = type;
            this.Examples = Examples;
        }
        public FieldInfo(
            IJsonClassGeneratorConfig generator,
            string jsonMemberName,
            JsonType type,
            bool usePascalCase,
            IReadOnlyList <object> examples
            )
        {
            this.generator            = generator ?? throw new ArgumentNullException(nameof(generator));
            this.JsonMemberName       = jsonMemberName ?? throw new ArgumentNullException(nameof(jsonMemberName));
            this.MemberName           = jsonMemberName;
            this.ContainsSpecialChars = IsContainsSpecialChars(this.MemberName);

            if (usePascalCase || this.ContainsSpecialChars)
            {
                this.MemberName = JsonClassGenerator.ToTitleCase(this.MemberName);
            }

            this.Type     = type ?? throw new ArgumentNullException(nameof(type));
            this.Examples = examples ?? Array.Empty <object>();
        }
Ejemplo n.º 7
0
 public void AssignName(string name, string originalName)
 {
     AssignedName = JsonClassGenerator.ToTitleCase(name);
     OriginalName = originalName;
 }