public static string FunctionHandler(string actionRequest, ILambdaContext context) { Console.WriteLine($"Received Action: {actionRequest}"); using (var scope = DependencyInjection.Init()) { var configJsonPath = FileUtils.GetAbsolutePathFromCurrentDirectory("stacks.json"); var allStacks = StackFactory.CreateStacksFromJson(configJsonPath); var mediatorRequest = StackRequestFactory.CreateMediatorRequest(allStacks, actionRequest); Console.WriteLine("Stacks affected:"); Array.ForEach(allStacks, stack => Console.WriteLine(stack.Name)); scope.Resolve <IMediator>().Send(mediatorRequest).Wait(); } Console.WriteLine("Command executed successfully."); return("Command executed successfully."); }
/// <summary> /// Create an UndoService. /// </summary> /// <param name="getState">Method to get the state of the tracked object</param> /// <param name="setState">Method to set the state of the tracked object</param> /// <param name="cap">Capacity of Undo history</param> public UndoService(GetState <T> getState, SetState <T> setState, int?cap = null) { GetState = getState ?? throw new ArgumentNullException(nameof(getState)); SetState = setState ?? throw new ArgumentNullException(nameof(setState)); var stackFactory = new StackFactory <StateRecord <T> >(); _undoStack = stackFactory.MakeStack(cap); // T currentState; GetState(out T currentState); _originalState = currentState; _currentState = new StateRecord <T> { State = currentState }; _redoStack = new StandardStack <StateRecord <T> >(); _undoServiceValidator = new UndoServiceValidator <StateRecord <T> >(_undoStack, _redoStack); _undoStack.HasItemsChanged += UndoStack_HasItemsChanged; _redoStack.HasItemsChanged += RedoStack_HasItemsChanged; }
static void Main(string[] args) { try { if (args.Length < 1) { throw new ArgumentException("Expected argument action. eg:- start, stop"); } using (var scope = DependencyInjection.Init()) { var configJsonPath = FileUtils.GetAbsolutePathFromCurrentDirectory("stacks.json"); var allStacks = StackFactory.CreateStacksFromJson(configJsonPath); var mediatorRequest = StackRequestFactory.CreateMediatorRequest(allStacks, args[0]); scope.Resolve <IMediator>().Send(mediatorRequest).Wait(); Console.WriteLine("Command executed successfully."); } } catch (Exception ex) { Console.WriteLine("An exception occured with message below:"); Console.WriteLine("----------------------------------------"); Console.WriteLine(ex.Message); Console.WriteLine("Stack Trace:"); Console.WriteLine("------------"); Console.WriteLine(ex.StackTrace); if (ex.InnerException != null) { Console.WriteLine("Inner Exception:"); Console.WriteLine("---------------"); Console.WriteLine(ex.InnerException.Message); } } Console.WriteLine("---------------------------"); Console.WriteLine("Please enter key to terminate."); Console.ReadLine(); }
public AdminController(UserFactory uf, CompetitionFactory cf, StackFactory sf) { _userFactory = uf; _compFactory = cf; _stackFactory = sf; }
private void Set_Pancakes_Click(object sender, EventArgs e) { stack = StackFactory.GenerateStack(Convert.ToInt32(numUDCount.Value), pnlPancakes.Height, pnlPancakes.Width); Visualise(stack.Pancakes); }