Example #1
0
 private void Registration_Preparing(object sender, PreparingEventArgs e)
 {
     foreach (var param in e.Parameters)
     {
         Console.WriteLine(param.ToString());
     }
 }
Example #2
0
        private static void AddILoggerToParameters(object sender, PreparingEventArgs e)
        {
            var t = e.Component.Activator.LimitType;
            var resolvedParameter = new ResolvedParameter((p, i) => p.ParameterType == typeof(ILogger), (p, i) => new SerilogWrapper(i.Resolve<Serilog.ILogger>().ForContext(t)));

            e.Parameters = e.Parameters.Union(new[] { resolvedParameter });
        }
        static void OnComponentPreparing(object sender, PreparingEventArgs e)
        {
            var t = e.Component.Activator.LimitType;

            e.Parameters = e.Parameters.Union(new[] {
                new ResolvedParameter((p, i) => p.ParameterType == typeof(ILog), (p, i) => LogManager.GetLogger(t))
            });
        }
 void registration_Preparing(object sender, PreparingEventArgs e)
 {
     var t = e.Component.Activator.LimitType;
     e.Parameters = e.Parameters.Union(new[]
                                           {
                                               new ResolvedParameter(
                                                   (p, i) => p.ParameterType == typeof (Logger),
                                                   (p, i) => LogManager.GetLogger(t.FullName))
                                           });
 }
 static void OnComponentPreparing(object sender, PreparingEventArgs e)
 {
     var t = e.Component.Activator.LimitType;
     e.Parameters = e.Parameters.Union(new[]
     {
         // Se utiliza para inyectar una configuraciĆ³n de Log4Net sobre la clase
         // OJO, solo funciona con Constructor Injection
         new ResolvedParameter((p, i) => p.ParameterType == typeof(ILog), (p, i) => LogManager.GetLogger(t))
     });
 }
Example #6
0
 private static void OnComponentPreparing(object sender, PreparingEventArgs e)
 {
     var t = e.Component.Activator.LimitType;
     e.Parameters = e.Parameters.Union(
       new[]
       {
           new ResolvedParameter((p, i) =>
               p.ParameterType == typeof(CTPPV5.Infrastructure.Log.ILog), 
               (p, i) => new CTPPV5.Infrastructure.Log.Log4NetAdapter(LogManager.GetLogger(t))),
       });
 }
Example #7
0
 private static void OnComponentPreparing(object sender, PreparingEventArgs e)
 {
     e.Parameters =
       e.Parameters.Union(
         new[]
           {
       new ResolvedParameter(
         (p, i) => p.ParameterType == typeof(ILog),
         (p, i) => LogManager.GetLogger(p.Member.DeclaringType))
           });
 }
 private void OnComponentPreparing(object sender, PreparingEventArgs e)
 {
   Contract.Requires<ArgumentNullException>(e != null);
   Contract.Requires<ArgumentNullException>(e.Parameters != null);
   var type = e.Component.Activator.LimitType;  //  AF2.0+
   //  e.Component.Descriptor.BestKnownImplementationType;  //  AF1.2+
   e.Parameters = e.Parameters.Union(new[]
   {
     new ResolvedParameter((p, i) => (p.ParameterType == typeof(ILog)), 
       (p, i) => e.Context.Resolve<ILogProvider>().Get(type))
   });
 }
        private void InjectLoggerViaConstructor(object sender, PreparingEventArgs args)
        {
            var type = args.Component.Activator.LimitType;

            args.Parameters = args.Parameters.Union(
                new[]
                {
                    new ResolvedParameter(
                        (parameter, context) => parameter.ParameterType == typeof(Core.Logging.ILogger),
                        (p, i) => Core.Logging.Log.ForContext(type))
                });
        }
Example #10
0
 private void ComponentRegistration_Preparing(object sender, PreparingEventArgs e)
 {
     Type t = e.Component.Target.Activator.LimitType;
     e.Parameters = e.Parameters.Union(new[]
                                           {
                                               new ResolvedParameter((p, i) => p.ParameterType ==
                                                                               typeof (ILog),
                                                                     (p, i) => _logBuilder(t)),
                                               new ResolvedParameter((p, i) => p.ParameterType ==
                                                                               typeof (CoreILog),
                                                                     (p, i) => _logBuilder(t)),
                                               new ResolvedParameter((p, i) => p.ParameterType ==
                                                                               typeof (Logger),
                                                                     (p, i) => _nlogBuilder(t))
                                           });
 }
Example #11
0
 private void OnPreparing(object sender, PreparingEventArgs e)
 {
     e.Parameters = e.Parameters.Union(
         new[]
         {
             new ResolvedParameter(
                 (p, i) => p.ParameterType == typeof (ILog) || p.ParameterType == typeof (ILogger) || p.ParameterType == typeof(Logger),
                 (p, i) =>
                 {
                     var type = p.Member.DeclaringType ?? e.Component.Activator.LimitType;
                     var loggerNames = new List<string>(3) {type.Name};
                     foreach (var la in new[] {GetLA(type), GetLA(p)}.Where(la => la != null))
                     {
                         if (!la.StackNames) loggerNames.Clear();
                         loggerNames.Add(string.IsNullOrEmpty(la.Name) ? type.Name : la.Name);
                     }
                     return NLog.LogManager.GetLogger(string.Join("+", loggerNames), typeof (Logger));
                 })
         });
 }
 protected virtual void OnComponentPreparing(object sender, PreparingEventArgs e)
 {
 }
Example #13
0
 void OnComponentPreparing(object sender, PreparingEventArgs e)
 {
     Type t = e.Component.Activator.LimitType;
     e.Parameters =
         e.Parameters.Union(
             new[]
             {
                 new ResolvedParameter(
                     (p, i) => p.ParameterType == typeof(ILogger),
                     (p, i) => i.Resolve<ILogger>().ForContext(t))
             });
 }
Example #14
0
 private static void Preparing(ThreadContext context, PreparingEventArgs preparing) {
     context.Focus = context.Focus.Preparing(preparing);
     context.Chain = context.Chain.Link(preparing, context.Focus);
     context.Clock = MoveClock(context.Clock, context.Focus);
 }
Example #15
0
 public Node Link(PreparingEventArgs e, Node focus) {
     if (focus._chain != null) {
         TraceMessage("REACTIVATED: Preparing[{2}] {0} {1}", e.Component);
     }
     focus._chain = this;
     return focus;
 }
Example #16
0
            public Node Preparing(PreparingEventArgs e) {
                // move focus down a level on the tree
                // add a link in chain
                Node child;
                lock (_children) {
                    if (!_children.TryGetValue(e.Component.Id, out child)) {
                        child = new Node(this, e.Component);
                        _children[e.Component.Id] = child;
                    }
                }

                TraceMessage("Preparing[{2}] {0} {1}", e.Component);
                Interlocked.Increment(ref child._preparingCount);
                return child;
            }
 private static void OnComponentPreparing(object sender, PreparingEventArgs e)
 {
     // resolves all ILogger type parameters on constructors or functions
     var componentType = e.Component.Activator.LimitType;
     e.Parameters = e.Parameters.Union(new[]
     {
         new ResolvedParameter((p, ctx) => p.ParameterType == typeof(ILogger),
                               (p, ctx) => ctx.Resolve<ILogger>(new TypedParameter(typeof(Type), componentType)))
     });
 }
		private void RegistrationOnPreparing(object sender, PreparingEventArgs preparingEventArgs)
		{
			Debug.WriteLine("{0}Resolving  {1}", GetPrefix(), preparingEventArgs.Component);
			depth++;
		}