BHoM / LadybugTools_Toolkit

GNU Lesser General Public License v3.0
2 stars 2 forks source link

String case changes #130

Open tg359 opened 10 months ago

tg359 commented 10 months ago

Description:

Should string case changes even be here? If so, then they could be done better using switch-cases, for example:

[Description("Convert the case of the given text.")]
[Input("str", "Text to convert the case of.")]
[Input("stringCase", "The case to convert the text to.")]
[Input("ignoreList", "A list of strings to ignore when converting the case.")]
[Output("str", "Text in the target case.")]
public static string ToCase(this string str, StringCase stringCase = StringCase.Undefined, List<string> ignoreList = null)
{
    switch (stringCase)
    {
        case StringCase.Pascal:
            return ToPascalCase(str, ignoreList);
        case StringCase.Snake:
            return ToSnakeCase(str, ignoreList);
        case StringCase.Camel:
            return ToCamelCase(str, ignoreList);
        default:
            BH.Engine.Base.Compute.RecordWarning($"No change to the input ({str}) was made");
            return str;
    }
}
Tom-Kingstone commented 10 months ago

I will do this when moving serialiser methods to the adapter. (#136)

Tom-Kingstone commented 9 months ago

On my above comment: the string case changing is not used in the adapter so can be safely removed when the adapter is fully utilised for pushing/pulling json.