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
// What is printed? | |
// 1) I am A | |
// 2) I am B | |
// 3) I am overriden B | |
// 4) None - Compiler error; Ambiguous call | |
static void Main(string[] args) | |
{ | |
var implement = new Implementation(); | |
var overloads = new A(); |
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
static void Main(string[] args) | |
{ | |
var app = new Voldermort.CommandLineApplication(); | |
app.UseServices(services => | |
{ | |
services.AddTransient<IChildFactory, A>(); | |
services.AddTransient<IChild, B.Child>(); | |
services.AddTransient<IDependencyFactory, C.DependencyFactory>(); | |
}); | |
app.OnExecute<IParent>(parent => |
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 interface IAnimal | |
{ | |
string Type { get; } | |
} | |
public abstract class Dog : IAnimal | |
{ | |
public virtual string Type { get; } = "Dog"; | |
public abstract string Breed { get; } |
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 interface IAnimal | |
{ | |
string Type { get; } | |
} | |
public interface IDog : IAnimal { } | |
public class Foo | |
{ | |
public Foo(IDog animal) |
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 Demand | |
{ | |
public static DemandResult That(Func<bool> predicate) => new DemandResult(predicate); | |
public static void That(bool predicate, string reason) | |
{ | |
if (!predicate) throw new InvalidOperationException(reason); | |
} | |
public static DemandSetup<IEnumerable<T>> That<T>(IEnumerable<T> source) => new EnumerableDemand<T>(source); |
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
using Composition; | |
using System; | |
namespace Domain | |
{ | |
public static class ApplicationExtensions | |
{ | |
/// <summary> | |
/// This extension will simply fire an <see cref="EventBusStarted"/> event. | |
/// In debug mode, the extension will also <see cref="System.Diagnostics.Debug.Assert">Assert</see> that |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>netcoreapp2.0</TargetFramework> | |
<RuntimeFrameworkVersion>2.0.3</RuntimeFrameworkVersion> | |
<IsPackable>false</IsPackable> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" /> |