jellyfin/Emby.Server.Implementations/StartupOptions.cs

31 lines
679 B
C#
Raw Normal View History

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