private static void Main(string[] args) { var form = new ClientQuenstionForm() { MonthlyIncome = 5000, MonthlyCarCosts = 500, MonthlyLivingCosts = 1500, PeopleSupported = 2, IsMan = true, ShareValue = 50000, IsITStuff = true, }; //form.GetInputData(); ICredibilityPolicy policy = new DSLCredibilityPolicy( "+ dochod * maxOkresKredytowania", "- kosztSamochodu * maxOkresKredytowania", "* (1-0.25*(osobyNaUtrzymaniu-1))", "* 0.7", "Jesli mezczyzna to * 0.95", "+ akcje * 0.4", "Jesli informatyk to * 1.1", "Jesli polityk to * 0.8" ); Money money = policy.Calculate(form); Console.WriteLine("Your credibility is: " + money); }
public static ClientQuenstionForm GetInputData(this ClientQuenstionForm form) { foreach (var property in form.GetType().GetProperties()) { var a = property.GetCustomAttributes(typeof(InputDataAttribute), true) .Cast <InputDataAttribute>().FirstOrDefault(); if (a == null) { continue; } Console.WriteLine(a.Question + ":"); var t = Console.ReadLine(); var r = Convert.ChangeType(t, property.PropertyType == typeof(Money) ? typeof(int) : property.PropertyType); if (property.PropertyType == typeof(Money)) { r = new Money((int)r); } property.SetValue(form, r, null); } return(form); }
public Money Calculate(ClientQuenstionForm data) { Console.WriteLine("Credibility calculation"); var credibility = new Money(0); foreach (var rule in _rules) { credibility = rule(credibility, data); Console.WriteLine("Rule step value: " + credibility); } return(credibility); }