diff --git a/src/WireMock.Net.StandAlone/SimpleCommandLineParser.cs b/src/WireMock.Net.StandAlone/SimpleCommandLineParser.cs index 11bfeba4..8ff982ca 100644 --- a/src/WireMock.Net.StandAlone/SimpleCommandLineParser.cs +++ b/src/WireMock.Net.StandAlone/SimpleCommandLineParser.cs @@ -7,7 +7,7 @@ namespace WireMock.Net.StandAlone // Based on http://blog.gauffin.org/2014/12/simple-command-line-parser/ internal class SimpleCommandLineParser { - public IDictionary Arguments { get; private set; } = new Dictionary(); + private IDictionary Arguments { get; } = new Dictionary(); public void Parse(string[] args) { @@ -58,7 +58,7 @@ namespace WireMock.Net.StandAlone public bool GetBoolValue(string name, bool defaultValue = false) { - return GetValue(name, (values) => + return GetValue(name, values => { string value = values.FirstOrDefault(); return !string.IsNullOrEmpty(value) ? bool.Parse(value) : defaultValue; @@ -67,7 +67,7 @@ namespace WireMock.Net.StandAlone public int? GetIntValue(string name, int? defaultValue = null) { - return GetValue(name, (values) => + return GetValue(name, values => { string value = values.FirstOrDefault(); return !string.IsNullOrEmpty(value) ? int.Parse(value) : defaultValue; @@ -76,10 +76,7 @@ namespace WireMock.Net.StandAlone public string GetStringValue(string name, string defaultValue = null) { - return GetValue(name, (values) => - { - return values.FirstOrDefault() ?? defaultValue; - }, defaultValue); + return GetValue(name, values => values.FirstOrDefault() ?? defaultValue, defaultValue); } } } \ No newline at end of file diff --git a/src/WireMock.Net.StandAlone/StandAloneApp.CommandLineParser.cs b/src/WireMock.Net.StandAlone/StandAloneApp.CommandLineParser.cs deleted file mode 100644 index 43191fda..00000000 --- a/src/WireMock.Net.StandAlone/StandAloneApp.CommandLineParser.cs +++ /dev/null @@ -1,142 +0,0 @@ -// using System; -// using System.Collections.Generic; -// using System.Linq; -// using CommandLineParser.Arguments; -// using CommandLineParser.Exceptions; -// using WireMock.Server; -// using WireMock.Settings; -// using WireMock.Validation; -// using JetBrains.Annotations; -// using Newtonsoft.Json; - -// namespace WireMock.Net.StandAlone -// { -// /// -// /// The StandAloneApp -// /// -// public static class StandAloneApp -// { -// private class Options -// { -// [ValueArgument(typeof(int?), "Port", Description = "Port to listen on.", Optional = true)] -// public int? Port { get; set; } - -// [ValueArgument(typeof(string), "Urls", Description = "URL(s) to listen on.", Optional = true, AllowMultiple = true)] -// public List Urls { get; set; } - -// [SwitchArgument("AllowPartialMapping", false, Description = "Allow Partial Mapping (default set to false).", Optional = true)] -// public bool AllowPartialMapping { get; set; } - -// [SwitchArgument("StartAdminInterface", true, Description = "Start the AdminInterface (default set to true).", Optional = true)] -// public bool StartAdminInterface { get; set; } - -// [SwitchArgument("ReadStaticMappings", true, Description = "Read StaticMappings from ./__admin/mappings (default set to true).", Optional = true)] -// public bool ReadStaticMappings { get; set; } - -// [ValueArgument(typeof(string), "ProxyURL", Description = "The ProxyURL to use.", Optional = true)] -// public string ProxyURL { get; set; } - -// [SwitchArgument("SaveProxyMapping", true, Description = "Save the proxied request and response mapping files in ./__admin/mappings. (default set to true).", Optional = true)] -// public bool SaveMapping { get; set; } - -// [ValueArgument(typeof(string), "X509Certificate2ThumbprintOrSubjectName", Description = "The X509Certificate2 Thumbprint or SubjectName to use.", Optional = true)] -// public string X509Certificate2ThumbprintOrSubjectName { get; set; } - -// [ValueArgument(typeof(string), "AdminUsername", Description = "The username needed for __admin access.", Optional = true)] -// public string AdminUsername { get; set; } - -// [ValueArgument(typeof(string), "AdminPassword", Description = "The password needed for __admin access.", Optional = true)] -// public string AdminPassword { get; set; } - -// [ValueArgument(typeof(int?), "RequestLogExpirationDuration", Description = "The RequestLog expiration in hours.", Optional = true)] -// public int? RequestLogExpirationDuration { get; set; } - -// [ValueArgument(typeof(int?), "MaxRequestLogCount", Description = "The MaxRequestLog count.", Optional = true)] -// public int? MaxRequestLogCount { get; set; } -// } - -// /// -// /// Start WireMock.Net standalone based on the FluentMockServerSettings. -// /// -// /// The FluentMockServerSettings -// [PublicAPI] -// public static FluentMockServer Start([NotNull] FluentMockServerSettings settings) -// { -// Check.NotNull(settings, nameof(settings)); - -// return FluentMockServer.Start(settings); -// } - -// /// -// /// Start WireMock.Net standalone based on the commandline arguments. -// /// -// /// The commandline arguments -// [PublicAPI] -// public static FluentMockServer Start([NotNull] string[] args) -// { -// Check.NotNull(args, nameof(args)); - -// // Console.WriteLine("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'"))); - -// var options = new Options(); -// var parser = new CommandLineParser.CommandLineParser(); -// parser.ExtractArgumentAttributes(options); - -// try -// { -// parser.ParseCommandLine(args); - -// Console.WriteLine("WireMock.Net server options {0}", JsonConvert.SerializeObject(options, Formatting.Indented)); - -// var settings = new FluentMockServerSettings -// { -// StartAdminInterface = options.StartAdminInterface, -// ReadStaticMappings = options.ReadStaticMappings, -// AllowPartialMapping = options.AllowPartialMapping, -// AdminUsername = options.AdminUsername, -// AdminPassword = options.AdminPassword, -// MaxRequestLogCount = options.MaxRequestLogCount, -// RequestLogExpirationDuration = options.RequestLogExpirationDuration -// }; - -// if (options.Port != null) -// { -// settings.Port = options.Port; -// } -// else if (options.Urls != null && options.Urls.Any()) -// { -// settings.Urls = options.Urls.ToArray(); -// } -// else -// { -// settings.Urls = new [] { "http://*:9091/" }; -// } - -// if (!string.IsNullOrEmpty(options.ProxyURL)) -// { -// settings.ProxyAndRecordSettings = new ProxyAndRecordSettings -// { -// Url = options.ProxyURL, -// SaveMapping = options.SaveMapping, -// X509Certificate2ThumbprintOrSubjectName = options.X509Certificate2ThumbprintOrSubjectName -// }; -// } - -// Console.WriteLine("WireMock.Net server settings {0}", JsonConvert.SerializeObject(settings, Formatting.Indented)); - -// FluentMockServer server = Start(settings); - -// Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls)); - -// return server; -// } -// catch (CommandLineException e) -// { -// Console.WriteLine(e.Message); -// parser.ShowUsage(); - -// throw; -// } -// } -// } -// } \ No newline at end of file diff --git a/src/WireMock.Net.StandAlone/StandAloneApp.cs b/src/WireMock.Net.StandAlone/StandAloneApp.cs index 39afd651..9bd1f26f 100644 --- a/src/WireMock.Net.StandAlone/StandAloneApp.cs +++ b/src/WireMock.Net.StandAlone/StandAloneApp.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using WireMock.Server; using WireMock.Settings;