Skip to content

Commit 095b64a

Browse files
committed
Add support for deserializing properties with an underscore prefix
1 parent 4059ae6 commit 095b64a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

RestSharp/Extensions/StringExtensions.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,16 @@ public static string AddDashes(this string pascalCasedWord)
304304
"$1-$2"), @"[\s]", "-");
305305
}
306306

307+
/// <summary>
308+
/// Add an undescore prefix to a pascasl-cased string
309+
/// </summary>
310+
/// <param name="pascalCasedWord"></param>
311+
/// <returns></returns>
312+
public static string AddUnderscorePrefix(this string pascalCasedWord)
313+
{
314+
return string.Format("_{0}", pascalCasedWord);
315+
}
316+
307317
/// <summary>
308318
/// Return possible variants of a name for name matching.
309319
/// </summary>
@@ -334,6 +344,13 @@ public static IEnumerable<string> GetNameVariants(this string name, CultureInfo
334344

335345
// try name with dashes with lower case
336346
yield return name.AddDashes().ToLower(culture);
337-
}
347+
348+
// try name with underscore prefix
349+
yield return name.AddUnderscorePrefix();
350+
351+
// try name with underscore prefix with lower case
352+
yield return name.AddUnderscorePrefix().ToLower(culture);
353+
354+
}
338355
}
339356
}

0 commit comments

Comments
 (0)