public ResultCode Start(AppletSession normalSession, AppletSession interactiveSession) { _normalSession = normalSession; _commonArguments = IApplet.ReadStruct <CommonArguments>(_normalSession.Pop()); Logger.Info?.PrintMsg(LogClass.ServiceAm, $"ErrorApplet version: 0x{_commonArguments.AppletVersion:x8}"); _errorStorage = _normalSession.Pop(); _errorCommonHeader = IApplet.ReadStruct <ErrorCommonHeader>(_errorStorage); _errorStorage = _errorStorage.Skip(Marshal.SizeOf(typeof(ErrorCommonHeader))).ToArray(); switch (_errorCommonHeader.Type) { case ErrorType.ErrorCommonArg: { ParseErrorCommonArg(); break; } case ErrorType.ApplicationErrorArg: { ParseApplicationErrorArg(); break; } default: throw new NotImplementedException($"ErrorApplet type {_errorCommonHeader.Type} is not implemented."); } AppletStateChanged?.Invoke(this, null); return(ResultCode.Success); }
public override void InitializeArguments(IArgsManager argsManager) { Arguments.AddRange(CommonArguments.Create("AwesomeLogger", "5501")); Arguments.AddRange(new List <Argument> { new Argument { Name = Constants.File, ShortName = "f", Description = "The log file.", Example = "{name}=c:\\logs\\log.txt", DefaultValue = Assembly.GetExecutingAssembly().Location + ".log", Action = (value) => { Console.WriteLine(value); } }, new Argument { Name = Constants.AlsoLogOnConsole, ShortName = "c", Description = "This will log to both a file and the console window.", Example = "{name}=true", DefaultValue = "true", AllowedValues = CommonAllowedValues.TrueFalse, Action = (value) => { Console.WriteLine(value); } }, new ConfigFileArgument(argsManager) // This is a special Argument type to allow for args in a file }); Arguments.RemoveAt(3); // Remove common logger endpoint as this is logger }
//------------------------------------------------------------------------------ /// <summary> /// A helper method for checking the bearer token /// </summary> //------------------------------------------------------------------------------ void Authorize(CommonArguments args) { // Naturally, you will put your own real authorization code here. if (args.BearerToken != "funbucket") { throw new ServiceOperationException(ServiceOperationError.AuthorizationError, "The bearer token is supposed to be 'funbucket'"); } }
public override void InitializeArguments(IArgsManager argsManager) { Arguments.AddRange(CommonArguments.Create("HealthDistrict", "5552")); Arguments.AddRange(new List <Argument> { new Argument { Name = Constants.PublisherEndpoints, ShortName = "p", Description = "A comma separated array of endpoints for the publishers.", Example = "{name}=tcp://127.0.0.1:5553,tcp://127.0.0.1:5554", DefaultValue = "tcp://127.0.0.1:5553,tcp://127.0.0.1:5554", Action = (value) => { Console.WriteLine(value); } } }); }
public override void InitializeArguments(IArgsManager argsManager) { Arguments.AddRange(CommonArguments.Create("NameServer", "6001")); Arguments.AddRange(new List <Argument> { // Add more args here new Argument { Name = "UseLocalHost", ShortName = "ulh", Description = "Use localhost, 127.0.0.1 for all registrations.", Example = "{name}=true", DefaultValue = "false", AllowedValues = CommonAllowedValues.TrueFalse }, new ConfigFileArgument(argsManager) // This is a special Argument type to allow for args in a file }); Arguments.RemoveAt(2); // Remove common NameServer endpoint from comon as this is Name Server, so Enpoint is used. }
public ResultCode Start(AppletSession normalSession, AppletSession interactiveSession) { _normalSession = normalSession; _interactiveSession = interactiveSession; _commonArguments = IApplet.ReadStruct <CommonArguments>(_normalSession.Pop()); Logger.Stub?.PrintStub(LogClass.ServiceAm, $"WebApplet version: 0x{_commonArguments.AppletVersion:x8}"); ReadOnlySpan <byte> webArguments = _normalSession.Pop(); (_shimKind, _arguments) = BrowserArgument.ParseArguments(webArguments); Logger.Stub?.PrintStub(LogClass.ServiceAm, $"Web Arguments: {_arguments.Count}"); foreach (BrowserArgument argument in _arguments) { Logger.Stub?.PrintStub(LogClass.ServiceAm, $"{argument.Type}: {argument.GetValue()}"); } if ((_commonArguments.AppletVersion >= 0x80000 && _shimKind == ShimKind.Web) || (_commonArguments.AppletVersion >= 0x30000 && _shimKind == ShimKind.Share)) { List <BrowserOutput> result = new List <BrowserOutput>(); result.Add(new BrowserOutput(BrowserOutputType.ExitReason, (uint)WebExitReason.ExitButton)); _normalSession.Push(BuildResponseNew(result)); } else { WebCommonReturnValue result = new WebCommonReturnValue() { ExitReason = WebExitReason.ExitButton, }; _normalSession.Push(BuildResponseOld(result)); } AppletStateChanged?.Invoke(this, null); return(ResultCode.Success); }
public override void InitializeArguments(IArgsManager argsManager) { Arguments.AddRange(CommonArguments.Create("OutbreakAnalyzer", "5555")); Arguments.AddRange(new List <Argument> { new Argument { Name = Constants.PublisherName, ShortName = "pn", Description = "The name of the publisher server.", Example = "{name}=Publisher1", DefaultValue = "Publisher1", Action = (value) => { Console.WriteLine(value); } }, new Argument { Name = Constants.PublisherEndpoint, ShortName = "p", Description = "The endpoint for the server service.", Example = "{name}=tcp://127.0.0.1:5556", DefaultValue = "tcp://127.0.0.1:5556", Action = (value) => { Console.WriteLine(value); } }, new Argument { Name = Constants.Disease, ShortName = "d", Description = "The disease this service analyzes.", DefaultValue = "Influenza", Example = "{name}=Influenza" }, new Argument { Name = Constants.Threshold, ShortName = "t", Description = "The number of diseases per day that indicate an outbreak.", DefaultValue = "200", Example = "{name}=200" } }); }
public override void InitializeArguments(IArgsManager argsManager) { Arguments.AddRange(CommonArguments.Create("Simulator", "5552")); Arguments.AddRange(new List <Argument> { new Argument { Name = Constants.TimeMultiplier, ShortName = "t", Description = "This is how long 1 second simulates. For example: 3600 simulates 1 hour every second.", DefaultValue = "3600", Example = "{name}=3600", CustomValidation = (val) => { return(Regex.IsMatch(val, CommonAllowedValues.Digits)); } }, new Argument { Name = Constants.Duration, ShortName = "u", Description = "The length of time in days the simulation runs. Max time simulation is 9999 days.", DefaultValue = "31", Example = "{name}=31", CustomValidation = (val) => { return(Regex.IsMatch(val, "[1-9][0-9]{0,4}")); } }, new Argument { Name = Constants.Year, ShortName = "y", Description = "The year the simulation starts.", DefaultValue = "2018", Example = "{name}=2018", CustomValidation = (val) => { return(Regex.IsMatch(val, "[1-9][0-9]{3}")); } }, new Argument { Name = Constants.Month, ShortName = "m", Description = "The month the simulation starts.", DefaultValue = "01", Example = "{name}=01", CustomValidation = (val) => { return(Regex.IsMatch(val, "[0]?[1-9]|[1][0-2]")); } }, new Argument { Name = Constants.Day, ShortName = "d", Description = "The day the simulation starts.", DefaultValue = "01", Example = "{name}=01", CustomValidation = (val) => { return(Regex.IsMatch(val, "[0]?[1-9]|[1-2][0-9]|[3][0-1]")); } }, new ConfigFileArgument(argsManager) }); }
public ShowCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory, CommonArguments args) : base(renderer, config, controllerFactory, args) { }
public GetCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller, CommonArguments args) : base(renderer, config, controller, args) { }
public GitDiffArguments(DiffMode mode, CommonArguments commonArgs, object specialArgs) { Mode = mode; CommonArgs = commonArgs; SpecialArgs = specialArgs; }
protected CommandBase(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory, CommonArguments args) { Renderer = renderer; Config = GetConfig(config, args.VaM); Logger = args.Log == LogLevel.Disabled ? (ILogger) new NullLogger() : new AccumulatorLogger(args.Log); Controller = controllerFactory.Create(Config, Logger, !args.Force); }
protected CommandBase(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller, CommonArguments args) { Renderer = renderer; Config = GetConfig(config, args.VaM); Controller = controller; Controller.ChecksEnabled = args.Force; }