public GenericInterfaceAopProxy( IGenericInterface <T, TA> realInstance, InterceptionHandler interceptionHandler) : this() { _realInstance = realInstance; _interceptionHandler = interceptionHandler; }
public void GenericInterfaceExportInRegistrationBuilder() { CompositionContainer container = CreateRegistrationBuilderContainer(typeof(ClassExportingInterface <>)); IGenericInterface <string> v = container.GetExportedValue <IGenericInterface <string> >(); Assert.IsAssignableFrom <IGenericInterface <string> >(v); }
public ImportGeneric(IGenericInterface <T> importGenericInterface) { if (importGenericInterface == null) { throw new ArgumentNullException("importGenericInterface"); } Instances++; }
public void SetUp() { this.mockInterface3 = Mock.Create <IInterface3>(); this.mockGenericInterfaceListInt = Mock.Create <IGenericInterface <List <int> > >(); this.mockGenericInterfaceListSomeOtherInterface = Mock.Create <IGenericInterface <List <ISomeOtherInterface> > >(); this.mockGenericInterfaceBool = Mock.Create <IGenericInterface <bool> >(); this.mockGenericInterfaceListString = Mock.Create <IGenericInterface <List <string> > >(); this.mockSomeInterface = Mock.Create <ISomeInterface>(); }
public ImportGeneric(IGenericInterface <T> importGenericInterface) { if (importGenericInterface == null) { throw new ArgumentNullException(nameof(importGenericInterface)); } System.Threading.Interlocked.Increment(ref counter); }
public void TestInitialize() { this.fakeInterface3 = A.Fake <IInterface3>(); this.fakeGenericInterfaceListInt = A.Fake <IGenericInterface <List <int> > >(); this.fakeGenericInterfaceListSomeOtherInterface = A.Fake <IGenericInterface <List <ISomeOtherInterface> > >(); this.fakeGenericInterfaceBool = A.Fake <IGenericInterface <bool> >(); this.fakeGenericInterfaceListString = A.Fake <IGenericInterface <List <string> > >(); this.fakeSomeInterface = A.Fake <ISomeInterface>(); }
public ClassWithGenericInterfaceTests() { this.subInterface3 = Substitute.For <IInterface3>(); this.subGenericInterfaceListInt = Substitute.For <IGenericInterface <List <int> > >(); this.subGenericInterfaceListSomeOtherInterface = Substitute.For <IGenericInterface <List <ISomeOtherInterface> > >(); this.subGenericInterfaceBool = Substitute.For <IGenericInterface <bool> >(); this.subGenericInterfaceListString = Substitute.For <IGenericInterface <List <string> > >(); this.subSomeInterface = Substitute.For <ISomeInterface>(); }
public void SetUp() { this.stubInterface3 = MockRepository.GenerateStub <IInterface3>(); this.stubGenericInterfaceListInt = MockRepository.GenerateStub <IGenericInterface <List <int> > >(); this.stubGenericInterfaceListSomeOtherInterface = MockRepository.GenerateStub <IGenericInterface <List <ISomeOtherInterface> > >(); this.stubGenericInterfaceBool = MockRepository.GenerateStub <IGenericInterface <bool> >(); this.stubGenericInterfaceListString = MockRepository.GenerateStub <IGenericInterface <List <string> > >(); this.stubSomeInterface = MockRepository.GenerateStub <ISomeInterface>(); }
public void TestInitialize() { this.subInterface3 = Substitute.For <IInterface3>(); this.subGenericInterfaceListInt = Substitute.For <IGenericInterface <List <int> > >(); this.subGenericInterfaceListSomeOtherInterface = Substitute.For <IGenericInterface <List <ISomeOtherInterface> > >(); this.subGenericInterfaceBool = Substitute.For <IGenericInterface <bool> >(); this.subGenericInterfaceListString = Substitute.For <IGenericInterface <List <string> > >(); this.subSomeInterface = Substitute.For <ISomeInterface>(); }
public ClassWithGenericInterfaceTests() { this.fakeInterface3 = A.Fake <IInterface3>(); this.fakeGenericInterfaceListInt = A.Fake <IGenericInterface <List <int> > >(); this.fakeGenericInterfaceListSomeOtherInterface = A.Fake <IGenericInterface <List <ISomeOtherInterface> > >(); this.fakeGenericInterfaceBool = A.Fake <IGenericInterface <bool> >(); this.fakeGenericInterfaceListString = A.Fake <IGenericInterface <List <string> > >(); this.fakeSomeInterface = A.Fake <ISomeInterface>(); }
public void GenericWithOneTypeParameter() { IServiceProvider serviceProvider = Build(services => services.AddSingleton(typeof(IGenericInterface <>), typeof(GenericInterface <>))); IGenericInterface <T1> simpleInterface = serviceProvider.GetRequiredService <IGenericInterface <T1> >(); Assert.NotNull(simpleInterface); Assert.Equal(typeof(T1), actual: simpleInterface.ItemType); }
public NonGenericWrapper(IGenericInterface remote) { instance = remote; // wrap generic methods getDefaultHolder = new GenericMethodHolder(typeof(IGenericInterface), "GetDefault", 1, new Type[0]); equalsHolder = new GenericMethodHolder(typeof(IGenericInterface), "Equals", 1, new Type[] { null, null }); doSomethingHolder = new GenericMethodHolder(typeof(IGenericInterface), "DoSomething", 3, new Type[] { null, null, null }); computeHolder = new GenericMethodHolder(typeof(IGenericInterface), "Compute", 2, new Type[] { null, typeof(int), typeof(string) }); }
public static bool GenericTest8() { GenericClassTest <int> genericObject = new GenericClassTest <int>(); genericObject.value = 10; IGenericInterface <int> genericInterface = genericObject; return(genericInterface.ReturnIt() == 10); }
public static bool GenericTest10() { var genericObject = new GenericClassTest <TestObjectInherit>(); genericObject.SetValue(new TestObjectInherit(5, 9, 6)); IGenericInterface <TestObject> genericInterface = genericObject; TestObject objBase = genericInterface.ReturnIt(); TestObjectInherit objDerived = (TestObjectInherit)objBase; return(objDerived.A == 5 && objDerived.B == 9 && objDerived.C == 6); }
//https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/covariance-contravariance/using-variance-in-delegates //https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/covariance-contravariance/using-variance-for-func-and-action-generic-delegates static void Main(string[] args) { //Delegate Covariance / Contrvariance { Action <A> f1 = ProcessA; //Contrvariance - function which accepts less derived type, can be assigned to more derived type delegate //All Action delegate are contrvariant Action <B> f2 = f1; ContrvariantDelegate <A> f3 = ProcessA; //Direct contrvariant assignment is always supported (because it is basically wrapping in new Action()) ContrvariantDelegate <B> f5 = ProcessA; //This won't compile if "in" keyword is missing in Delegate definition ContrvariantDelegate <B> f6 = f3; CovariantDelegate <B> f7 = ReturnB; //Direct covariant assignment is always supported (because it is basically wrapping in new Action()) CovariantDelegate <A> f8 = ReturnB; //This won't compile if "out" keyword is missing in Delegate definition CovariantDelegate <A> f9 = f7; } //Collection Invariance //Those lines won't compile //List<A> list = new List<B>(); //IList<A> list1 = new List<B>(); //IEnumerable though supports covariance because you can not change it var list2 = new List <B>(); IEnumerable <A> list3 = list2; //Arrays support variance but can emmit runtime exception A[] array = new B[1]; //Like in this case array[0] = new A(); //Interface Covariance Contrvariance //https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/covariance-contravariance/creating-variant-generic-interfaces ICovariant <B> interfaceExample = null; //This won't compile without "out" keyword ICovariant <A> i = interfaceExample; IContrvariant <A> interfaceExample2 = null; //This won't compile without "in" keyword IContrvariant <B> i2 = interfaceExample2; //Accepts A, returns B IGenericInterface <A, B> interfaceExample3 = null; //Accepts B, returns A IGenericInterface <B, A> i3 = interfaceExample3; //Basically Contrvariance allows to accept more derived arguments and covariance to return less derived arguments }
public void SelectorWorksForGenericMethods() { ProxyGenerationOptions options = new ProxyGenerationOptions(); CallCountingInterceptor countingInterceptor = new CallCountingInterceptor(); options.Selector = new TypeInterceptorSelector <CallCountingInterceptor>(); IGenericInterface target = generator.CreateInterfaceProxyWithTarget(typeof(IGenericInterface), new GenericClass(), options, new AddTwoInterceptor(), countingInterceptor) as IGenericInterface; Assert.IsNotNull(target); int result = target.GenericMethod <int>(); Assert.AreEqual(1, countingInterceptor.Count); Assert.AreEqual(0, result); string result2 = target.GenericMethod <string>(); Assert.AreEqual(2, countingInterceptor.Count); Assert.AreEqual(default(string), result2); }
public ClosedGenericDecorator(IGenericInterface <SimpleImplementation1> d) { this.Inner = d; }
public OpenGenericDecorator(IGenericInterface <T> d) { Inner = d; }
public void SetUp() { this.subGenericInterfaceBool = Substitute.For <IGenericInterface <bool> >(); this.subGenericInterfaceListString = Substitute.For <IGenericInterface <List <string> > >(); this.subSomeInterface = Substitute.For <ISomeInterface>(); }
public ClassWithGenericInterfaceTests() { this.stubGenericInterfaceBool = MockRepository.GenerateStub <IGenericInterface <bool> >(); this.stubGenericInterfaceListString = MockRepository.GenerateStub <IGenericInterface <List <string> > >(); this.stubSomeInterface = MockRepository.GenerateStub <ISomeInterface>(); }
public UoWData() { context = new CentisoftContext(); CustomerRepo = new GenericRepo <Customer>(context); DeveloperRepo = new GenericRepo <Developer>(context); }
public GenericInterfaceAdapter(IGenericInterface <T> inner) { this.inner = inner; }
public ClassWithGenericInterfaceTests() { this.mockGenericInterfaceBool = Mock.Create <IGenericInterface <bool> >(); this.mockGenericInterfaceListString = Mock.Create <IGenericInterface <List <string> > >(); this.mockSomeInterface = Mock.Create <ISomeInterface>(); }
public void TestInitialize() { this.stubGenericInterfaceBool = MockRepository.GenerateStub <IGenericInterface <bool> >(); this.stubGenericInterfaceListString = MockRepository.GenerateStub <IGenericInterface <List <string> > >(); this.stubSomeInterface = MockRepository.GenerateStub <ISomeInterface>(); }
public void TestInitialize() { this.mockGenericInterfaceBool = Mock.Create <IGenericInterface <bool> >(); this.mockGenericInterfaceListString = Mock.Create <IGenericInterface <List <string> > >(); this.mockSomeInterface = Mock.Create <ISomeInterface>(); }
public ClassWithGenericInterface(IGenericInterface <bool> theGenericInterface, IGenericInterface <List <string> > theOtherGenericInterface, ISomeInterface someInterface) { }
private static void Foo(IGenericInterface <Ford> o) { }
public CtorOrderProcessor(IGenericInterface <string> orderRepository) { OrderRepository = orderRepository; }
public ClosedGenericAdapter(IGenericInterface <SimpleImplementation2> inner) { Inner = inner; }
public GenericConsumerB(IGenericInterface <object> _) { Console.WriteLine("{0} got {1}", nameof(NonGenericConsumerA), _.GetType().Name); }