private void ButtonSubmit_Click(object sender, EventArgs e) { try { LabelTriangleTypeResult.Text = @"..."; _triangle = new TriangleFactory <TriangleRepository>().GetInstance(); _triangle.TriangleEntity = new TriangleEntity { Length = double.Parse(TextBoxTriangleWidth.Text), Height = double.Parse(TextBoxTriangleHeight.Text), Base = double.Parse(TextBoxTriangleBase.Text) }; var validationRes = _triangle.ValidateTriangleValues(); if (!string.IsNullOrEmpty(validationRes)) { MessageBox.Show(validationRes); } else { LabelTriangleTypeResult.Text = _triangle.GetTriangleType().ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <inheritdoc /> /// <summary> /// Instantiates implementer object. /// </summary> /// <returns>Returns implementer object.</returns> public T GetInstance() { ITriangleRepository unityContainer = null; try { if (_container != null) { return((T)_container.Resolve <ITriangleRepository>()); } _container = new UnityContainer(); _container.RegisterType <ITriangleRepository, T>(new InjectionConstructor( new NumbericValidation(), new TriangleAxisesValidation()) ); unityContainer = _container.Resolve <ITriangleRepository>(); return((T)unityContainer); } catch (ResolutionFailedException) { return(default(T)); } catch (Exception ex) { throw ex; } }
public UnitTestInputValidation() { try { _triangle = new TriangleFactory <TriangleRepository>().GetInstance(); } catch (NullReferenceException nullRefEx) { throw nullRefEx; } catch (Exception ex) { throw ex; } }
public TriangleService(ITriangleRepository triangleItemRepository, ICellService cellService) { _triangleItemRepository = triangleItemRepository; _cellService = cellService; }
public TriangleService(ITriangleRepository triangleRepository) { _triangleRepository = triangleRepository; }
public TriangleService(ITriangleRepository repository, ITriangleMessageQueue triangleMessageQueue) { _triangleRepository = repository; _triangleMessageQueue = triangleMessageQueue; }