/// <summary>
        /// Returns the service decorated with performance logging on all public
        /// methods and properties
        /// </summary>
        /// <param name="service"></param>
        /// <returns></returns>
        public T Decorate <T>(T service) where T : class
        {
            var generator         = GetGenerator();
            var loggerSelector    = new PerformanceLoggerSelector(_logger);
            var decoratorSelector = new DecoratorSelector(loggerSelector);
            var options           = new ProxyGenerationOptions
            {
                Selector = decoratorSelector
            };

            if (typeof(T).IsInterface)
            {
                return((T)generator.CreateInterfaceProxyWithTarget(typeof(T), service, options));
            }
            return((T)generator.CreateClassProxyWithTarget(typeof(T), service, options));
        }
Пример #2
0
 public DecoratorSelector(PerformanceLoggerSelector loggerSelector)
 {
     _loggerSelector = loggerSelector;
 }