jellyfin/Emby.Server.Implementations/StartupOptions.cs

31 lines
679 B
C#
Raw Normal View History

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