I am currently using the .NET Core built in Dependency Injection (DI).

My application is using the Rules Engine Design Pattern.

One of my rules, has a dependency, which has a dependency. So, I have to keep on "newing up" instances of the dependencies. I feel as though there has be a better way.

Here is an example of my code.

This works but I don't like that I have to new up the DataService and the Repository.

```
var rules = new List<IRule>
   {
      new Rule1(),
      new Rule2(new DataService(new Repository(CnnStr))) //This is what I don't like
   };
s.AddTransient<IRulesEngine>(sp => new RulesEngine(rules));

```

I started setting this up:

```
s.AddTransient<IRepository>(sp => new Repository(CnnStr));
s.AddTransient<IDataService>(sp => sp.GetRequiredService<DataService>());

```

Which seem to get me a little closer to what I want. But, I have no idea how to populate the rules list with a list of instances of the rules with out having to have to new up the dependencies (DataService and Repo).

Something like this, but I know this code is not right.

```
var rules = new List<IRule>
   {
      s.AddTransient<IRule>(sp => sp.GetRequiredService<Rule1>())
      s.AddTransient<IRule>(sp => sp.GetRequiredService<Rule2>())
   };
s.AddTransient<IRulesEngine>(sp => new RulesEngine(rules));

```

Any help would be appreciated.

Thank you.