-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DataMinerProjectType to Project (Parsers.Common) (#48)
* Add DataMinerProjectType enum and necessary logic to parse it. * Actually add it to the project properly * Change location of the DataMinerType * Small cleanup * Add unknown * no message * Move back to the PropertyGroup>DataMinerType tag * Add other useful properties to Project * Fix SonarCloud
- Loading branch information
1 parent
a989010
commit 3458299
Showing
7 changed files
with
192 additions
and
7 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
Parsers.Common/VisualStudio/Projects/DataMinerProjectType.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,94 @@ | ||
namespace Skyline.DataMiner.CICD.Parsers.Common.VisualStudio.Projects | ||
{ | ||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Represents the DataMiner project type. | ||
/// </summary> | ||
public enum DataMinerProjectType | ||
{ | ||
/// <summary> | ||
/// Unknown value. | ||
/// </summary> | ||
Unknown, | ||
|
||
/// <summary> | ||
/// Represents a DataMiner Install Package project. | ||
/// </summary> | ||
Package, | ||
|
||
/// <summary> | ||
/// Represents a DataMiner Automation Script project. | ||
/// </summary> | ||
AutomationScript, | ||
|
||
/// <summary> | ||
/// Represents a DataMiner Automation Script project that will be a library. | ||
/// </summary> | ||
AutomationScriptLibrary, | ||
|
||
/// <summary> | ||
/// Represents a DataMiner Ad Hoc Data Source project. | ||
/// </summary> | ||
AdHocDataSource, | ||
|
||
/// <summary> | ||
/// Represents a DataMiner User-Defined API project. | ||
/// </summary> | ||
UserDefinedApi, | ||
} | ||
|
||
/// <summary> | ||
/// Class to convert from and to the <see cref="DataMinerProjectType"/> enum. | ||
/// </summary> | ||
public static class DataMinerProjectTypeConverter | ||
{ | ||
private static readonly Dictionary<string, DataMinerProjectType> StringToEnum = new Dictionary<string, DataMinerProjectType> | ||
{ | ||
["Package"] = DataMinerProjectType.Package, | ||
["AutomationScript"] = DataMinerProjectType.AutomationScript, | ||
["AutomationScriptLibrary"] = DataMinerProjectType.AutomationScriptLibrary, | ||
["AdHocDataSource"] = DataMinerProjectType.AdHocDataSource, | ||
["UserDefinedApi"] = DataMinerProjectType.UserDefinedApi, | ||
}; | ||
|
||
private static readonly Dictionary<DataMinerProjectType, string> EnumToString = new Dictionary<DataMinerProjectType, string> | ||
{ | ||
[DataMinerProjectType.Package] = "Package", | ||
[DataMinerProjectType.AutomationScript] = "AutomationScript", | ||
[DataMinerProjectType.AutomationScriptLibrary] = "AutomationScriptLibrary", | ||
[DataMinerProjectType.AdHocDataSource] = "AdHocDataSource", | ||
[DataMinerProjectType.UserDefinedApi] = "UserDefinedApi", | ||
}; | ||
|
||
/// <summary> | ||
/// Tries to convert the specified value to the <see cref="DataMinerProjectType"/> enum. | ||
/// </summary> | ||
/// <param name="value">Value to convert.</param> | ||
/// <returns>Converted value when successful, Unknown when not.</returns> | ||
public static DataMinerProjectType ToEnum(string value) | ||
{ | ||
if (StringToEnum.TryGetValue(value, out DataMinerProjectType t)) | ||
{ | ||
return t; | ||
} | ||
|
||
return DataMinerProjectType.Unknown; | ||
} | ||
|
||
/// <summary> | ||
/// Tries to convert the specified <see cref="DataMinerProjectType"/> value to the string version for the project. Will return null when unable to convert to enum. | ||
/// </summary> | ||
/// <param name="value">Value to convert.</param> | ||
/// <returns>Converted value when successful, null when not.</returns> | ||
public static string ToString(DataMinerProjectType value) | ||
{ | ||
if (EnumToString.TryGetValue(value, out string s)) | ||
{ | ||
return s; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
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
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