/// <summary> /// Creates the proxy generic. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="target">The target.</param> /// <returns>T.</returns> public T CreateProxyGeneric <T>(T target) where T : class { return(Proxy.CreateProxy(target, async invocation => { var flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy; var targetMethod = target.GetType().GetMember(invocation.Method.Name, flags).First(); if (IsMarkedNonTransactional(invocation, targetMethod)) { return await invocation.Proceed(); } else { object result = null; if (DynamicExecutionStrategyDbConfiguration.SuspendExecutionStrategy) { using (var trans = _transactionScopeFactory.GetTransactionScope()) { result = await invocation.Proceed(); trans.Complete(); } } else { DynamicExecutionStrategyDbConfiguration.SuspendExecutionStrategy = true; var executionStrategy = new SqlAzureExecutionStrategy(3, TimeSpan.FromMilliseconds(200)); await executionStrategy.ExecuteAsync(async() => { using (var trans = _transactionScopeFactory.GetTransactionScope()) { result = await invocation.Proceed(); trans.Complete(); } }, new System.Threading.CancellationToken()); DynamicExecutionStrategyDbConfiguration.SuspendExecutionStrategy = false; } return result; } })); }