04-Refactoring/Refactoring/20-Extract_and_inline_method.cs [1:58]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - using System; using System.Collections.Generic; using System.Linq; namespace JetBrains.ReSharper.Koans.Refactoring { // Extract Method // // Creates a new method based on a selected code fragment // // Ctrl+R, M (VS) // // Inline Method // // Replaces the call site of a method call with the contents of the method, // optionally removing the original method definition // // Ctrl+R, I (VS) // public class ExtractMethod { public List LongMethod(IEnumerable items) { var results = new List(); foreach (var item in items) { // 1. Extract method, with parameters and return value // Select the next two lines of code. Note that it uses "item" and creates the "result" variable // Invoke Extract Method - confirm name, select return value, parameters, make static/virtual, etc. var result = item.ToUpperInvariant(); result = new string(result.Reverse().ToArray()); // Don't select this line results.Add(result); } return results; } } public class InlineMethod { private const string Name = "Fred"; public void SayHello() { // 2. Inline Method // Place the text caret on the method name // Invoke Inline Method // Confirm to inline all instances, and remove original method definition Console.WriteLine("Hello " + GetName()); Console.WriteLine("Hi " + GetName()); } public string GetName() { return Name; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - localized/ja/04-Refactoring/Refactoring/20-Extract_and_inline_method.cs [1:58]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - using System; using System.Collections.Generic; using System.Linq; namespace JetBrains.ReSharper.Koans.Refactoring { // Extract Method // // Creates a new method based on a selected code fragment // // Ctrl+R, M (VS) // // Inline Method // // Replaces the call site of a method call with the contents of the method, // optionally removing the original method definition // // Ctrl+R, I (VS) // public class ExtractMethod { public List LongMethod(IEnumerable items) { var results = new List(); foreach (var item in items) { // 1. Extract method, with parameters and return value // Select the next two lines of code. Note that it uses "item" and creates the "result" variable // Invoke Extract Method - confirm name, select return value, parameters, make static/virtual, etc. var result = item.ToUpperInvariant(); result = new string(result.Reverse().ToArray()); // Don't select this line results.Add(result); } return results; } } public class InlineMethod { private const string Name = "Fred"; public void SayHello() { // 2. Inline Method // Place the text caret on the method name // Invoke Inline Method // Confirm to inline all instances, and remove original method definition Console.WriteLine("Hello " + GetName()); Console.WriteLine("Hi " + GetName()); } public string GetName() { return Name; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -