-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from marknn3/add-target-netstandard20
Add Target Framework netstandard2.0
- Loading branch information
Showing
4 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Markdig.Renderers.Docx/Polyfills/NetStandard20Polyfills.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Markdig.Renderers.Docx; | ||
|
||
internal static class NetStandard20Polyfills | ||
{ | ||
public static TValue GetValueOrDefault<TKey, TValue>( | ||
this IReadOnlyDictionary<TKey, TValue> target, | ||
TKey key, | ||
TValue defaultValue = default!) | ||
{ | ||
if (target.TryGetValue(key, out var result)) | ||
{ | ||
return result!; | ||
} | ||
|
||
return defaultValue; | ||
} | ||
|
||
public static bool TryPeek<T>(this Stack<T> stack, out T result) | ||
{ | ||
if (stack.Count == 0) | ||
{ | ||
result = default!; | ||
return false; | ||
} | ||
|
||
result = stack.Peek(); | ||
return true; | ||
} | ||
|
||
public static string[] Split(this string str, string separator, StringSplitOptions options = StringSplitOptions.None) | ||
{ | ||
return str.Split(separator.ToCharArray(), options); | ||
} | ||
} |