jellyfin/Emby.Server.Implementations/StartupOptions.cs

31 lines
676 B
C#
Raw Normal View History

using System;
2014-09-14 17:26:33 +02:00
using System.Linq;
2016-11-18 22:06:00 +01:00
namespace Emby.Server.Implementations
2014-09-14 17:26:33 +02:00
{
public class StartupOptions
{
2019-01-01 16:27:11 +01:00
private readonly string[] _options;
2016-11-18 22:06:00 +01:00
public StartupOptions(string[] commandLineArgs)
{
2019-01-01 16:27:11 +01:00
_options = commandLineArgs;
2016-11-18 22:06:00 +01:00
}
2014-09-14 17:26:33 +02:00
public bool ContainsOption(string option)
2019-01-01 16:27:11 +01:00
=> _options.Contains(option, StringComparer.OrdinalIgnoreCase);
2014-09-14 17:26:33 +02:00
public string GetOption(string name)
{
2019-01-01 16:27:11 +01:00
int index = Array.IndexOf(_options, name);
2014-09-14 17:26:33 +02:00
2019-01-01 16:27:11 +01:00
if (index == -1)
2014-09-14 17:26:33 +02:00
{
2019-01-01 16:27:11 +01:00
return null;
2014-09-14 17:26:33 +02:00
}
2019-01-01 16:27:11 +01:00
return _options.ElementAtOrDefault(index + 1);
2014-09-14 17:26:33 +02:00
}
}
}