private IResultData Deserialize <T>(IResource <T> resource, ISubject subject, ITimes times) where T : class { times = resource.Multiply(times); IPayload payload = subject.Create <T>(resource); IRoutine routine = new Routine <T>(subject, payload); TimeSpan started = AppDomain.CurrentDomain.MonitoringTotalProcessorTime; times.Execute(routine); TimeSpan ended = AppDomain.CurrentDomain.MonitoringTotalProcessorTime; return(new MeasuredDurationResult(ended - started)); }
private IResultData Validate <T>(IResource <T> resource, ISubject subject) where T : class { IPayload payload = subject.Create <T>(resource); T template = resource.GetInstance(); ICompareLogic comparer = new CompareLogic(new ComparisonConfig { MaxDifferences = 100 }); T deserialized = subject.Deserialize <T>(payload); IResultData result = null; ComparisonResult comparision = comparer.Compare(template, deserialized); if (comparision.AreEqual == false) { result = new InvalidComparisionResult(comparision.DifferencesString); } return(result); }