コード例 #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();
        }
    }
コード例 #2
0
        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());
        }
コード例 #3
0
 public static TImplementation ToImplementation <TImplementation>([CanBeNull] this IAbstraction <TImplementation> abstraction)
 {
     return(ReferenceEquals(abstraction, null) ? default : abstraction.UnsafeConvert());
 }
コード例 #4
0
 public RequiresAbstraction(IAbstraction abstraction)
 {
     Dependency = abstraction;
 }
コード例 #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));
 }
コード例 #6
0
 // concretion is known
 // runtime decision
 public ConcretionDecorator(IAbstraction abstraction)
 {
     _abstraction = abstraction;
 }
コード例 #7
0
 public static IAbstractionLayer Network(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
コード例 #8
0
 public static IAbstractionLayer Presentation(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
コード例 #9
0
 public static IAbstractionLayer Database(this IAbstraction abstraction) => new AbstractionLayer();
コード例 #10
0
 public static IAbstractionLayer IO(this IAbstraction abstraction) => new AbstractionLayer();
コード例 #11
0
 public static IAbstractionLayer Presentation(this IAbstraction abstraction) => new AbstractionLayer();
コード例 #12
0
 public static IAbstractionLayer Infrastructure(this IAbstraction abstraction) => new AbstractionLayer();
コード例 #13
0
 public static IAbstractionLayer Business(this IAbstraction abstraction) => new AbstractionLayer();
コード例 #14
0
 public Client(IAbstraction abstraction)
 {
     _abstraction = abstraction;
 }
コード例 #15
0
 public static IAbstractionLayer Business(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
コード例 #16
0
 public static IAbstractionLayer Infrastructure(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
コード例 #17
0
 public static IAbstractionLayer Network(this IAbstraction abstraction) => new AbstractionLayer();
コード例 #18
0
 public static IAbstractionLayer Database(this IAbstraction abstraction) => AbstractionFactory.CreateWithCallerName();
コード例 #19
0
 public HighLevelModule(IAbstraction message)
 {
     _message = message;
 }
コード例 #20
0
 public CompositeConcrete(IAbstraction inner)
 {
     this.Inner = inner;
 }
コード例 #21
0
 public static TImplementation?ToImplementation <TImplementation>(this IAbstraction <TImplementation>?abstraction)
     where TImplementation : notnull
 {
     return(ReferenceEquals(abstraction, null) ? default : abstraction.UnsafeConvert());
 }