Skip to content

Commit

Permalink
Completing a basic IGreeter service and configuring ASP.NET Core to i…
Browse files Browse the repository at this point in the history
…nstantiate a Greeter class any time an IGreeter is injected
  • Loading branch information
gorohoroh committed Jul 3, 2018
1 parent a5219b1 commit 972408e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion OdeToFoodRider/OdeToFoodRider/IGreeter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Greeter : IGreeter
{
public string GetMessageOfTheDay()
{
throw new System.NotImplementedException();
return "Greetings from Rider!";

}
}
Expand Down
2 changes: 2 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class Startup
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IGreeter, Greeter>();

}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
2 changes: 1 addition & 1 deletion OdeToFoodVisualStudio/OdeToFoodVisualStudio/IGreeter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Greeter : IGreeter
{
public string GetMessageOfTheDay()
{
throw new System.NotImplementedException();
return "Greetings from Visual Studio!";
}
}
}
7 changes: 5 additions & 2 deletions OdeToFoodVisualStudio/OdeToFoodVisualStudio/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class Startup
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
// RDVS: Rider's completion works better with this generic method as it additionally adds the parentheses; additionally, VS overlaps the completion list inside the generic brackets
// with with parameter info
services.AddSingleton<IGreeter, Greeter>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -26,8 +29,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter
{
// Configuration sources by descending priority: 1. command-line parameter, 2. environment variable, 3. appsettings.json (enables storing dev settings in appsettings.json and overriding them in production wtih environment variables for example)
// VsvsRider: doesn look like there's an action to add a new comment (there are actions to comment/decomment existing code; and to add documentation comment)
// VsvsRider: VS create from usage isn't quite on par right now: given the undeclared IGreeter interface in method parameteres and the below line that uses an undeclared method,
// RDVS: doesn look like there's an action to add a new comment (there are actions to comment/decomment existing code; and to add documentation comment)
// RDVS: VS create from usage isn't quite on par right now: given the undeclared IGreeter interface in method parameteres and the below line that uses an undeclared method,
// <strike>1. You must create the interface from usage first, and only then can you create the method - so there's no chaining in Create from Usage;</strike> - same in Rider :(
// 2. The created symbol doesn't get focus: both when it's created in a separate file and when it's created in the same file
// 3. Roslyn doesn't infer that the generated method should return a string, not an object
Expand Down

0 comments on commit 972408e

Please sign in to comment.