jellyfin/Emby.Server.Implementations/StartupOptions.cs

31 lines
676 B
C#
Raw Normal View History

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