private static IEnumerable <T> GetEnumerableOfType <T>(IFraudDetector fraudDetector) where T : class
        {
            List <T> objects = new List <T>();

            foreach (Type type in Assembly.GetAssembly(typeof(T)).GetTypes()
                     .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))))
            {
                var constructorWithFraudDetector = type.GetConstructor(new[] { fraudDetector.GetType() });
                if (constructorWithFraudDetector != null)
                {
                    objects.Add((T)constructorWithFraudDetector.Invoke(new[] { fraudDetector }));
                }
                else
                {
                    objects.Add((T)Activator.CreateInstance(type));
                }
            }
            return(objects);
        }
Ejemplo n.º 2
0
 public FraudRule(IFraudDetector fraudDetector) => _fraudDetector = fraudDetector;
 public static IEnumerable <Rule> GetRules(IFraudDetector fraudDetector)
 {
     return(GetEnumerableOfType <Rule>(fraudDetector));
 }
 public ContractAnalyzer(IFraudDetector fraudDetector)
 {
     _fraudDetector = fraudDetector;
     ResetRules();
 }