View 0_reuse_code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
View DependencyExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IServiceCollection Named<TService, TImplementation>(this IServiceCollection services, string name) | |
{ | |
var implementationToBeNamed = services.FirstOrDefault(s => s.ImplementationType == typeof(TImplementation) && | |
s.ServiceType == typeof(TService)); | |
return services; | |
} |
View animals.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace LongRunningApp.Animals | |
{ | |
public interface ICow | |
{ | |
void Speak(); | |
} | |
public class Cow : ICow | |
{ | |
public void Speak() |
View speak.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task WorkAsync() | |
{ | |
while (true) | |
{ | |
Console.WriteLine("The animals will now speak..."); | |
_cow.Speak(); | |
_cat.Speak(); | |
_mouse.Speak(); | |
Thread.Sleep(TimeSpan.FromSeconds(3)); | |
} |
View application.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Application : IApplication | |
{ | |
private readonly ICat _cat; | |
private readonly ICow _cow; | |
private readonly IMouse _mouse; | |
public Application(ICat cat, ICow cow, IMouse mouse) | |
{ | |
_cat = cat; | |
_mouse = mouse; |
View registrations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddTransient<ICow, Cow>(); | |
services.AddTransient<IMouse, Mouse>(); | |
services.AddTransient<ICat, Cat>(); |
View registration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run(IServiceCollection services) | |
{ | |
services.Scan(scan => scan | |
.FromAssemblyOf<ICat>() | |
.AddClasses() | |
.AsImplementedInterfaces() | |
.WithTransientLifetime()); | |
services.AddSingleton<IApplication, Application>(); | |
} |
View RegistrationsInNamespace.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Run(IServiceCollection services) | |
{ | |
services.Scan(scan => scan | |
.FromAssemblyOf<ICat>() | |
.AddClasses(classes => classes.InNamespaceOf<ICat>()) | |
.AsImplementedInterfaces() | |
.WithTransientLifetime()); | |
services.AddSingleton<IApplication, Application>(); | |
} |
View gist:801b184dbda862d8c3e9613db353599f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet publish --runtime win10-x64 -o C:\TestPublish -f netcoreapp2.0 -c debug |
View AzureCreds.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string _subscriptionId = ""; | |
private static string _clientId = ""; | |
private static string _clientSecret = ""; | |
private static string _tenantId = ""; |
OlderNewer