public void Rate() { _logger.Log("Starting rate."); _logger.Log("Loading policy."); string policyJson = _policySource.GetPolicyFromSource(); var policy = _policySerializer.GetPolicyFromString(policyJson); var rater = _raterFactory.Create(policy); Rating = rater.Rate(policy); _logger.Log("Rating completed."); }
public Rater CreateByReflection(Policy policy) { try { return((Rater)Activator.CreateInstance(Type.GetType($"OpenClosedPrinciple.OCP.{policy.Type}PolicyRater"), new object[] { })); } catch (Exception e) { _logger.Log(e.Message); return(null); } }
public void Rate() { context = new DefaultRatingContext(); _logger.Log("Starting rate."); _logger.Log("Loading policy."); var policyJson = FilePolicySource.GetPolicyFromSource(); var policy = JsonPolicySerializer.GetPolicyFromJsonString(policyJson); var rater = new RaterFactory().Create(policy, context); rater.Rate(policy); var rater2 = new RaterFactory().CreateByReflection(policy, context); rater2.Rate(policy); _logger.Log("Rating completed."); }