public GenericInterfaceAopProxy() { _classGenericArgumentT = GenericArgumentInfo.Create( typeof(T), nameof(T), ClassGenericArgumentTIndex, Variance.Covariant, GenericSource.Class, new[] { GenericArgumentRestriction.Create(GenericArgumentRestrictionType.Class), GenericArgumentRestriction.Create(typeof(IDisposable)), GenericArgumentRestriction.Create(GenericArgumentRestrictionType.New) }); _classGenericArgumentTa = GenericArgumentInfo.Create( typeof(TA), nameof(TA), ClassGenericArgumentTaIndex, Variance.Covariant, GenericSource.Class, new[] { GenericArgumentRestriction.Create(GenericArgumentRestrictionType.Struct) }); _classGenericArguments = new[] { _classGenericArgumentT, _classGenericArgumentTa }; }
public void Swap <T>(ref T v1, ref T v2) { var genericArgumentT = GenericArgumentInfo.Create(typeof(T), nameof(T)); var invocationInfo = InvocationInfo.Create( typeof(RefUtilsAopProxy), nameof(Swap), new[] { ArgumentInfo.Create(typeof(T), nameof(v1), v1, ArgumentSpecialType.Ref, genericArgumentT), ArgumentInfo.Create(typeof(T), nameof(v2), v2, ArgumentSpecialType.Ref, genericArgumentT) }, new[] { genericArgumentT }, Swap <T>); var result = _interceptionHandler.Invoke(invocationInfo); const int v1Index = 0; const int v2Index = 1; v1 = (T)result.Arguments[v1Index].Value; v2 = (T)result.Arguments[v2Index].Value; }
public List <T> GetGenericList <T>() { var genericArgumentT = GenericArgumentInfo.Create(typeof(T), nameof(T)); var invocationInfo = InvocationInfo.Create( typeof(ContainerAopProxy), nameof(GetGenericList), new[] { genericArgumentT }, ResultInfo.Create(typeof(List <T>), genericArgumentT), GetGenericList <T>); var result = _interceptionHandler.Invoke(invocationInfo); return((List <T>)result.Result.Value); }
public void SetGenericValue <T>(T value) { var genericArgumentT = GenericArgumentInfo.Create(typeof(T), nameof(T)); var invocationInfo = InvocationInfo.Create( typeof(ContainerAopProxy), nameof(GetGenericList), new[] { ArgumentInfo.Create(typeof(T), nameof(value), value, genericArgumentT), }, new[] { genericArgumentT }, SetGenericValue <T>); _interceptionHandler.Invoke(invocationInfo); }
public void SetElement <T>(int index, T value) { var genericArgumentT = GenericArgumentInfo.Create(typeof(T), nameof(T)); var invocationInfo = InvocationInfo.Create( typeof(ContainerAopProxy), nameof(SetElement), new[] { ArgumentInfo.Create(typeof(int), nameof(index), index), ArgumentInfo.Create(typeof(T), nameof(value), value, genericArgumentT) }, new[] { genericArgumentT }, SetElement <T>); _interceptionHandler.Invoke(invocationInfo); }
public T GetBar <T>() where T : struct { var genericArgumentT = GenericArgumentInfo.Create( typeof(T), nameof(T), new[] { GenericArgumentRestriction.Create(GenericArgumentRestrictionType.Struct) }); var invocationInfo = InvocationInfo.Create( typeof(InterfaceWithGenericMethodAopProxy), nameof(GetBar), new[] { genericArgumentT }, ResultInfo.Create(typeof(T), genericArgumentT), GetBar <T>); var result = _interceptionHandler.Invoke(invocationInfo); return((T)result.Result.Value); }
public T GetElement <T>(int index) { var genericArgumentT = GenericArgumentInfo.Create(typeof(T), nameof(T)); var invocationInfo = InvocationInfo.Create( typeof(ContainerAopProxy), nameof(GetElement), new[] { ArgumentInfo.Create(typeof(int), nameof(index), index, genericArgumentT) }, new[] { genericArgumentT }, ResultInfo.Create(typeof(T), genericArgumentT), GetElement <T>); var result = _interceptionHandler.Invoke(invocationInfo); return((T)result.Result.Value); }
public void SetBoo <T, TA>(T t, TA a) where T : class, IDisposable, new() where TA : new() { var genericArgumentT = GenericArgumentInfo.Create( typeof(T), nameof(T), new[] { GenericArgumentRestriction.Create(GenericArgumentRestrictionType.Class), GenericArgumentRestriction.Create(typeof(IDisposable)), GenericArgumentRestriction.Create(GenericArgumentRestrictionType.New) }); var genericArgumentTa = GenericArgumentInfo.Create( typeof(TA), nameof(TA), new[] { GenericArgumentRestriction.Create(GenericArgumentRestrictionType.New) }); var invocationInfo = InvocationInfo.Create( typeof(InterfaceWithGenericMethodAopProxy), nameof(GetBar), new[] { ArgumentInfo.Create(typeof(T), nameof(t), t, genericArgumentT), ArgumentInfo.Create(typeof(TA), nameof(a), a, genericArgumentTa), }, new[] { genericArgumentT, genericArgumentTa }, SetBoo <T, TA>); _interceptionHandler.Invoke(invocationInfo); }