static void Main(string[] args) { var math = new Math(); int i = 0; #region CalCulationHandler //Creating the instance of the delegate class var sumHandler = new CalculationHandler(math.Sum); //invoke the delegate int result = sumHandler(10, 20); Console.WriteLine("Result of the sum is => {0}", result); Console.WriteLine(); #endregion #region DoubleOp DoubleOp[] operations = { math.MultiplyByTwo, math.Square }; for (; i < operations.Length; i++) { Console.WriteLine("Using operations[{0}] : ", i); ProcessAndDisplayNumbers(operations[i], 2.40); ProcessAndDisplayNumbers(operations[i], 7.23); ProcessAndDisplayNumbers(operations[i], 10.20); Console.WriteLine(); } #endregion Console.ReadKey(); }
public void Ok(int a, int b, int r) { var handler = new CalculationHandler(); var result = handler.Add(a, b); Assert.True(result == r); }
public void RenderCalendar_RenderLevelIsGreateThenOneAndUserSelectorIsFalse_ReturnsCalenderHtmlContent() { // Arrange _calendar = CreateCalendarObject(); _calendar.SelectedDate = DateTime.MinValue; _calendar.Enabled = false; _privateObject = new PrivateObject(_calendar); var stringWriter = new StringWriter(); var output = new HtmlTextWriter(stringWriter); _privateObject.SetFieldOrProperty("_autoPostBack", true); ShimControl.AllInstances.EventsGet = (x) => { var eventHandlerList = new EventHandlerList(); CalculationHandler sumHandler = new CalculationHandler(Sum); eventHandlerList.AddHandler("click", sumHandler); return(eventHandlerList); }; // Act _privateObject.Invoke(RenderCalendar, output); // Assert output.ShouldSatisfyAllConditions( () => output.ShouldNotBeNull(), () => output.InnerWriter.ShouldNotBeNull() ); }
/// <summary> /// Initialize a new instance of the <see cref="App"/> class. /// </summary> /// <param name="appResourcesService">A service with access to local resources.</param> /// <param name="logger">A logger from the built in LoggingFactory.</param> /// <param name="dataService">A service with access to data storage.</param> /// <param name="processService">A service with access to the process.</param> /// <param name="pdfService">A service with access to the PDF generator.</param> /// <param name="profileService">A service with access to profile information.</param> /// <param name="registerService">A service with access to register information.</param> /// <param name="prefillService">A service with access to prefill mechanisms.</param> /// <param name="instanceService">A service with access to instances</param> /// <param name="settings">General settings</param> /// <param name="textService">A service with access to text</param> /// <param name="httpContextAccessor">A context accessor</param> public App( IAppResources appResourcesService, ILogger <App> logger, IData dataService, IProcess processService, IPDF pdfService, IProfile profileService, IRegister registerService, IPrefill prefillService, IInstance instanceService, IOptions <GeneralSettings> settings, IText textService, IHttpContextAccessor httpContextAccessor) : base( appResourcesService, logger, dataService, processService, pdfService, prefillService, instanceService, registerService, settings, profileService, textService, httpContextAccessor) { _logger = logger; _validationHandler = new ValidationHandler(httpContextAccessor); _calculationHandler = new CalculationHandler(); _instantiationHandler = new InstantiationHandler(profileService, registerService); _pdfHandler = new PdfHandler(); }
public App( IAppResources appResourcesService, ILogger <App> logger, IData dataService, IProcess processService, IPDF pdfService, IProfile profileService, IRegister registerService ) : base(appResourcesService, logger, dataService, processService, pdfService) { _logger = logger; _validationHandler = new ValidationHandler(); _calculationHandler = new CalculationHandler(); _instantiationHandler = new InstantiationHandler(profileService, registerService); }
public App( IAppResources appResourcesService, ILogger <App> logger, IData dataService, IProcess processService, IPDF pdfService, IProfile profileService, IRegister registerService, IPrefill prefillService, IInstance instanceService, ISiriusApi siriusService, IHttpContextAccessor accessor) : base(appResourcesService, logger, dataService, processService, pdfService, prefillService, instanceService) { _logger = logger; _validationHandler = new ValidationHandler(instanceService); _calculationHandler = new CalculationHandler(); _instantiationHandler = new InstantiationHandler(profileService, registerService); _dataService = dataService; _siriusApi = siriusService; }
public void CalculateNumbers(double value1, double value2, CalculationHandler calc) { Timer timer = new Timer(5000); MathPerformed(calc(value1, value2)); }
public void Calculate(double value1, double value2, CalculationHandler calculate) { MathPerformed(calculate(value1, value2)); }
public void CalculateNumbers(double first, double second, CalculationHandler calculationHandler) { MathPerformedCustom(calculationHandler(first, second)); }
//with the method below implementation details can be assigned later to the delegate internal void CalculateNumbers(double value1, double value2, CalculationHandler calc) { Timer timer = new Timer(5000); MathPerformed?.Invoke(calc(value1, value2)); }