public static void Main(string[] args) { IAbstraction[] abstractions = new IAbstraction[] { new AbstractionA(new ImplementorA()), new AbstractionA(new ImplementorB()), new AbstractionB(new ImplementorA()), new AbstractionB(new ImplementorB()), }; foreach (IAbstraction abstraction in abstractions) { abstraction.Operation(); } }
public void TestStupid() { var implTypes = new[] { typeof(string), typeof(byte) }; implementationTypesCollection.Expect(mock => mock.GetImplementationTypes(typeof(int))).Return(implTypes); var expectedImpls = new[] { GetMock <IImplementation>(), GetMock <IImplementation>() }; implementationCache.Expect(mock => mock.GetOrCreate(implTypes[0])).Return(expectedImpls[0]); implementationCache.Expect(mock => mock.GetOrCreate(implTypes[1])).Return(expectedImpls[1]); IAbstraction abstraction = abstractionsCollection.Get(typeof(int)); Assert.That(abstraction, Is.InstanceOf <Abstraction>()); CollectionAssert.AreEqual(expectedImpls, abstraction.GetImplementations()); CollectionAssert.AreEqual(expectedImpls, abstraction.GetImplementations()); }
public static TImplementation ToImplementation <TImplementation>([CanBeNull] this IAbstraction <TImplementation> abstraction) { return(ReferenceEquals(abstraction, null) ? default : abstraction.UnsafeConvert()); }
public RequiresAbstraction(IAbstraction abstraction) { Dependency = abstraction; }
/// <summary> /// Converts provided abstraction to implementation. /// </summary> /// <param name="abstraction">Abstraction to convert.</param> /// <returns>Converted abstraction.</returns> public static TImplementation ToImplementation <TImplementation>(this IAbstraction <TImplementation> abstraction) { return(abstraction != null?abstraction.UnsafeConvert() : default(TImplementation)); }
// concretion is known // runtime decision public ConcretionDecorator(IAbstraction abstraction) { _abstraction = abstraction; }
public static IAbstractionLayer Network(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
public static IAbstractionLayer Presentation(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
public static IAbstractionLayer Database(this IAbstraction abstraction) => new AbstractionLayer();
public static IAbstractionLayer IO(this IAbstraction abstraction) => new AbstractionLayer();
public static IAbstractionLayer Presentation(this IAbstraction abstraction) => new AbstractionLayer();
public static IAbstractionLayer Infrastructure(this IAbstraction abstraction) => new AbstractionLayer();
public static IAbstractionLayer Business(this IAbstraction abstraction) => new AbstractionLayer();
public Client(IAbstraction abstraction) { _abstraction = abstraction; }
public static IAbstractionLayer Business(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
public static IAbstractionLayer Infrastructure(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
public static IAbstractionLayer Network(this IAbstraction abstraction) => new AbstractionLayer();
public static IAbstractionLayer Database(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
public HighLevelModule(IAbstraction message) { _message = message; }
public CompositeConcrete(IAbstraction inner) { this.Inner = inner; }
public static TImplementation?ToImplementation <TImplementation>(this IAbstraction <TImplementation>?abstraction) where TImplementation : notnull { return(ReferenceEquals(abstraction, null) ? default : abstraction.UnsafeConvert()); }