mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-17 17:23:48 -05:00
* Add linting for copyright and unused usings * Add one more + comment * Enforce in build and fix errors * Fix build
77 lines
2.9 KiB
C#
77 lines
2.9 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using Microsoft.SqlTools.Hosting.Utility;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.Utility
|
|
{
|
|
class ServiceLayerCommandOptions : CommandOptions
|
|
{
|
|
internal const string ServiceLayerServiceName = "MicrosoftSqlToolsServiceLayer.exe";
|
|
|
|
private static readonly string[] serviceLayerCommandArgs = { "-d", "--developers", "--parent-pid" };
|
|
|
|
/**
|
|
* List of contributors to this project, used as part of the onboarding process.
|
|
*/
|
|
private readonly string[] contributors = new string[] {
|
|
// Put your Github username here!
|
|
"Charles-Gagnon"
|
|
};
|
|
|
|
public int? ParentProcessId { get; private set; }
|
|
|
|
public ServiceLayerCommandOptions(string[] args) : base(args.Where(arg => !serviceLayerCommandArgs.Contains(arg)).ToArray(), ServiceLayerServiceName)
|
|
{
|
|
for (int i = 0; i < args.Length; ++i)
|
|
{
|
|
string arg = args[i]?.ToLowerInvariant();
|
|
|
|
switch (arg)
|
|
{
|
|
case "-d":
|
|
case "--developers":
|
|
Console.WriteLine();
|
|
Console.WriteLine("**********************************************************************************");
|
|
Console.WriteLine("These are some of the developers who have contributed to this project - thank you!");
|
|
Console.WriteLine("**********************************************************************************");
|
|
Console.WriteLine();
|
|
Console.WriteLine(string.Join(Environment.NewLine, contributors.Select(contributor => $"\t{contributor}")));
|
|
this.ShouldExit = true;
|
|
break;
|
|
case "--parent-pid":
|
|
string nextArg = args[++i];
|
|
if (Int32.TryParse(nextArg, out int parsedInt))
|
|
{
|
|
ParentProcessId = parsedInt;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void SetLocale(string locale)
|
|
{
|
|
try
|
|
{
|
|
LocaleSetter(locale);
|
|
|
|
// Setting our internal SR culture to our global culture
|
|
SR.Culture = CultureInfo.CurrentCulture;
|
|
}
|
|
catch (CultureNotFoundException)
|
|
{
|
|
// Ignore CultureNotFoundException since it only is thrown before Windows 10. Windows 10,
|
|
// along with macOS and Linux, pick up the default culture if an invalid locale is passed
|
|
// into the CultureInfo constructor.
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|