Skip to content

Commit 48b4e79

Browse files
committed
StringExtensions.Unquote methods
1 parent 6ab967e commit 48b4e79

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

Main/src/CodeJam.Main.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<Compile Include="Collections\EnumerableExtensions.Slice.cs" />
107107
<Compile Include="Collections\QueryableExtensions.ApplyOrder.cs" />
108108
<Compile Include="Collections\QueryableExtensions.cs" />
109-
<Compile Include="Option.cs" />
109+
<Compile Include="Structures\Option.cs" />
110110
<Compile Include="Reflection\InfoOf`1.cs" />
111111
<Compile Include="Reflection\ParamInfo.cs" />
112112
<Compile Include="Services\IServicePublisher.cs" />
@@ -165,7 +165,7 @@
165165
<Compile Include="Structures\ObjectPools\SharedPoolExtensions.cs" />
166166
<Compile Include="Structures\ObjectPools\PooledObject.cs" />
167167
<Compile Include="Structures\ObjectPools\ObjectPool.cs" />
168-
<Compile Include="Option`1.cs" />
168+
<Compile Include="Structures\Option`1.cs" />
169169
<Compile Include="Properties\AssemblyInfo.cs" />
170170
<Compile Include="Reflection\EnumHelper.cs" />
171171
<Compile Include="Reflection\ExpressionHelper.cs" />

Main/src/Strings/StringExtensions.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,5 +268,33 @@ public static unsafe string ToHexString([NotNull] this byte[] data, [CanBeNull]
268268

269269
return result;
270270
}
271+
272+
/// <summary>
273+
/// Remove one set of leading and trailing double quote characters, if both are present.
274+
/// </summary>
275+
public static string Unquote(this string arg)
276+
{
277+
bool quoted;
278+
return Unquote(arg, out quoted);
279+
}
280+
281+
/// <summary>
282+
/// Remove one set of leading and trailing double quote characters, if both are present.
283+
/// </summary>
284+
public static string Unquote(this string arg, out bool quoted) => Unquote(arg, '"', out quoted);
285+
286+
/// <summary>
287+
/// Remove one set of leading and trailing d<paramref name="quotationChar"/>, if both are present.
288+
/// </summary>
289+
public static string Unquote(this string arg, char quotationChar, out bool quoted)
290+
{
291+
if (arg.Length > 1 && arg[0] == quotationChar && arg[arg.Length - 1] == quotationChar)
292+
{
293+
quoted = true;
294+
return arg.Substring(1, arg.Length - 2);
295+
}
296+
quoted = false;
297+
return arg;
298+
}
271299
}
272300
}
File renamed without changes.
File renamed without changes.

NuGet/Readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CodeJam 1.0.0-beta10 Release Notes
44
What's new in 1.0.0-beta10
55
------------------------
66
* InterlockedOperations.Initialize and Update methods
7+
* StringExtensions.Unquote methods
78
* Add defaultValue parameter to all Min/MaxByOrDefault overloads
89
* Additional overloads for Algorithms.EqualRange/UpperBound/LowerBound
910
* Memoize extended up to 8 arguments

0 commit comments

Comments
 (0)