static void Main(string[] args) { var callable = DynamicProxy.CreateProxyOfRealize <ICallable, Person>(); callable.Call(); Console.Read(); }
// [Fact] //[Trait("desc", "实现方式动态代理")] public void FaultTolerantOfRealize() { IBusinessClass Instance = DynamicProxy.CreateProxyOfRealize <IBusinessClass, BusinessClass>(); //IBusinessClass Instance = new BusinessClassProxy(); Instance.Test(); Instance.GetInt(123); Instance.NoArgument(); Instance.ThrowException(); Instance.ArgumentVoid(123, "123"); Instance.GetBool(false); Instance.GetString("123"); Instance.GetFloat(123f); Instance.GetDouble(123.123); Instance.GetObject(null); Instance.GetOperateResult(123, "123"); Instance.GetOperateResults(new List <OperateResult>()); Instance.GetDecimal(123.123m); Instance.GetDateTime(DateTime.Now); }
public void Test2() { var instance = DynamicProxy.CreateProxyOfRealize <IAService, AService>(); instance.ServiceTest(); }
//[Fact] // [Trait("desc", "Exception")] public void ExceptionFilter() { IBusinessClass Instance = DynamicProxy.CreateProxyOfRealize <IBusinessClass, BusinessClass>(); Instance.ThrowException(); }
public static IServiceCollection AddScopedWithAop <TService, TImplementation>(this IServiceCollection services) where TService : class where TImplementation : class, TService, new() { services.Add(typeof(TImplementation), typeof(TImplementation), ServiceLifetime.Scoped); services.Add(typeof(TService), typeof(TImplementation), p => DynamicProxy.CreateProxyOfRealize <TService, TImplementation>(), ServiceLifetime.Scoped); return(services); }