/// <summary>Returns expression call to <see cref="GetOrAddItemOrDefault"/>.</summary>
        public Expr Apply(Request request, Expr serviceFactoryExpr)
        {
            var itemId = request.TracksTransientDisposable ? -1 : request.FactoryID;

            return(Expr.Call(_GetOrAddOrDefaultMethod,
                             Expr.Constant(_PerTransactionScopeContextBase),
                             Expr.Constant(request),
                             Expr.Constant(itemId),
                             Expr.Lambda <CreateScopedValue>(serviceFactoryExpr)));
        }
        private static ExpressionInfo <Func <string, int> > CreateExprInfo()
        {
            var aParamExpr  = E.Parameter(typeof(string), "a");
            var exParamExpr = E.Parameter(typeof(Exception), "ex");

            return(E.Lambda <Func <string, int> >(
                       E.TryCatch(
                           E.Call(typeof(int).GetTypeInfo()
                                  .DeclaredMethods.First(m => m.Name == nameof(int.Parse)),
                                  aParamExpr),
                           E.Catch(exParamExpr,
                                   E.Property(
                                       E.Property(exParamExpr, typeof(Exception).GetTypeInfo()
                                                  .DeclaredProperties.First(p => p.Name == nameof(Exception.Message))),
                                       typeof(string).GetTypeInfo()
                                       .DeclaredProperties.First(p => p.Name == nameof(string.Length))
                                       )
                                   )
                           ),
                       aParamExpr
                       ));
        }
Example #3
0
 public Expr Apply(Request request, Expr serviceFactoryExpr)
 {
     return(GetInnerReuse(request).Apply(request, serviceFactoryExpr));
 }
 public Expr Apply(Request request, Expr serviceFactoryExpr)
 {
     return(serviceFactoryExpr);
 }
 public Expr Apply(Request request, Expr serviceFactoryExpr)
 {
     return(Reuse.Singleton.Apply(request, serviceFactoryExpr));
 }