-
Notifications
You must be signed in to change notification settings - Fork 242
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 #1279 from microsoft/vnext
Master refresh
- Loading branch information
Showing
52 changed files
with
1,791 additions
and
481 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
19 changes: 19 additions & 0 deletions
19
src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.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,19 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
|
||
namespace Microsoft.OpenApi.Hidi.Extensions | ||
{ | ||
internal static class CommandExtensions | ||
{ | ||
public static void AddOptions(this Command command, IReadOnlyList<Option> options) | ||
{ | ||
foreach (var option in options) | ||
{ | ||
command.AddOption(option); | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.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,24 @@ | ||
using Microsoft.OpenApi.Any; | ||
using Microsoft.OpenApi.Interfaces; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.OpenApi.Hidi.Extensions | ||
{ | ||
internal static class OpenApiExtensibleExtensions | ||
{ | ||
/// <summary> | ||
/// Gets an extension value from the extensions dictionary. | ||
/// </summary> | ||
/// <param name="extensions">A dictionary of <see cref="IOpenApiExtension"/>.</param> | ||
/// <param name="extensionKey">The key corresponding to the <see cref="IOpenApiExtension"/>.</param> | ||
/// <returns>A <see cref="string"/> value matching the provided extensionKey. Return null when extensionKey is not found. </returns> | ||
public static string GetExtension(this IDictionary<string, IOpenApiExtension> extensions, string extensionKey) | ||
{ | ||
if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiString castValue) | ||
{ | ||
return castValue.Value; | ||
} | ||
return default; | ||
} | ||
} | ||
} |
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,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.OpenApi.Hidi.Extensions | ||
{ | ||
/// <summary> | ||
/// Extension class for <see cref="string"/>. | ||
/// </summary> | ||
internal static class StringExtensions | ||
{ | ||
/// <summary> | ||
/// Checks if the specified searchValue is equal to the target string based on the specified <see cref="StringComparison"/>. | ||
/// </summary> | ||
/// <param name="target">The target string to commpare to.</param> | ||
/// <param name="searchValue">The search string to seek.</param> | ||
/// <param name="comparison">The <see cref="StringComparison"/> to use. This defaults to <see cref="StringComparison.OrdinalIgnoreCase"/>.</param> | ||
/// <returns>true if the searchValue parameter occurs within this string; otherwise, false.</returns> | ||
public static bool IsEquals(this string target, string searchValue, StringComparison comparison = StringComparison.OrdinalIgnoreCase) | ||
{ | ||
if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(searchValue)) | ||
{ | ||
return false; | ||
} | ||
return target.Equals(searchValue, comparison); | ||
} | ||
|
||
/// <summary> | ||
/// Splits the target string in substrings based on the specified char separator. | ||
/// </summary> | ||
/// <param name="target">The target string to split by char. </param> | ||
/// <param name="separator">The char separator.</param> | ||
/// <returns>An <see cref="IList{String}"/> containing substrings.</returns> | ||
public static IList<string> SplitByChar(this string target, char separator) | ||
{ | ||
if (string.IsNullOrWhiteSpace(target)) | ||
{ | ||
return new List<string>(); | ||
} | ||
return target.Split(new char[] { separator }, StringSplitOptions.RemoveEmptyEntries).ToList(); | ||
} | ||
} | ||
} |
Oops, something went wrong.