Beispiel #1
0
    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());
        }
Beispiel #3
0
 public static TImplementation ToImplementation <TImplementation>([CanBeNull] this IAbstraction <TImplementation> abstraction)
 {
     return(ReferenceEquals(abstraction, null) ? default : abstraction.UnsafeConvert());
 }
Beispiel #4
0
 public RequiresAbstraction(IAbstraction abstraction)
 {
     Dependency = abstraction;
 }
Beispiel #5
0
 /// <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;
 }
Beispiel #7
0
 public static IAbstractionLayer Network(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
Beispiel #8
0
 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();
Beispiel #14
0
 public Client(IAbstraction abstraction)
 {
     _abstraction = abstraction;
 }
Beispiel #15
0
 public static IAbstractionLayer Business(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
Beispiel #16
0
 public static IAbstractionLayer Infrastructure(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
 public static IAbstractionLayer Network(this IAbstraction abstraction) => new AbstractionLayer();
Beispiel #18
0
 public static IAbstractionLayer Database(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
Beispiel #19
0
 public HighLevelModule(IAbstraction message)
 {
     _message = message;
 }
 public CompositeConcrete(IAbstraction inner)
 {
     this.Inner = inner;
 }
Beispiel #21
0
 public static TImplementation?ToImplementation <TImplementation>(this IAbstraction <TImplementation>?abstraction)
     where TImplementation : notnull
 {
     return(ReferenceEquals(abstraction, null) ? default : abstraction.UnsafeConvert());
 }