Injects selected methods into the containing class. You can choose to simply convert a method in an injected Action or Func or convert the method and initialize the new Action or Func from the constructor. Use it when you need to implement the dependency injection pattern. Inject option: C# Edit|Remove csharpclass Test { private void TestMethod() { } } class Test { private void TestMethod() { } } refactors to: C# Edit|Remove csharpclass Test{ private Action TestMethodInjected; private void TestMethod() { TestMethodInjected(); } } class Test { private Action TestMethodInjected; private void TestMethod() { TestMethodInjected(); } } Inject and initialize option: C# Edit|Remove csharpclass Test{ private string TestMethod(int i, char c, double d) { } } class Test { private string TestMethod(int i, char c, double d) { } } refactors to: C# Edit|Remove csharpclass Test{ private readonly Func<int, char, double, String> TestMethodInjected; public Test(Func<int, char, double, String> TestMethodInjected) { this.TestMethodInjected = TestMethodInjected; } private string TestMethod(int i, char c, double d) { return TestMethodInjected(i, c, d); } } class Test { private readonly Func<int, char, double, String> TestMethodInjected; public Test(Func<int, char, double, String> TestMethodInjected) { this.TestMethodInjected = TestMethodInjected; } private string TestMethod(int i, char c, double d) { return TestMethodInjected(i, c, d); } } |