/// <summary> /// Causes Raygun4Net to listen for exceptions. /// </summary> /// <param name="config">The HttpConfiguration to attach to.</param> /// <param name="generateRaygunClient">An optional function to provide a custom RaygunWebApiClient instance to use for reporting exceptions.</param> public static void Attach(HttpConfiguration config, Func <RaygunWebApiClient> generateRaygunClient = null) { Detach(config); var clientCreator = new RaygunWebApiClientProvider(generateRaygunClient); config.Services.Add(typeof(IExceptionLogger), new RaygunWebApiExceptionLogger(clientCreator)); _exceptionFilter = new RaygunWebApiExceptionFilter(clientCreator); config.Filters.Add(_exceptionFilter); _actionFilter = new RaygunWebApiActionFilter(clientCreator); config.Filters.Add(_actionFilter); var concreteActivator = config.Services.GetHttpControllerActivator(); config.Services.Replace(typeof(IHttpControllerActivator), new RaygunWebApiControllerActivator(concreteActivator, clientCreator)); var concreteControllerSelector = config.Services.GetHttpControllerSelector() ?? new DefaultHttpControllerSelector(config); config.Services.Replace(typeof(IHttpControllerSelector), new RaygunWebApiControllerSelector(concreteControllerSelector, clientCreator)); var concreteActionSelector = config.Services.GetActionSelector() ?? new ApiControllerActionSelector(); config.Services.Replace(typeof(IHttpActionSelector), new RaygunWebApiActionSelector(concreteActionSelector, clientCreator)); }
private static void AttachInternal(HttpConfiguration config, Func <HttpRequestMessage, RaygunWebApiClient> generateRaygunClientWithMessage, string applicationVersionFromAttach) { Detach(config); string applicationVersion; if (!string.IsNullOrEmpty(RaygunSettings.Settings.ApplicationVersion)) { applicationVersion = RaygunSettings.Settings.ApplicationVersion; } else { applicationVersion = applicationVersionFromAttach; } var owinAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName.StartsWith("Owin")); if (owinAssembly == null) { config.MessageHandlers.Add(new RaygunWebApiDelegatingHandler()); } var clientCreator = new RaygunWebApiClientProvider(generateRaygunClientWithMessage, applicationVersion); config.Services.Add(typeof(IExceptionLogger), new RaygunWebApiExceptionLogger(clientCreator)); _exceptionFilter = new RaygunWebApiExceptionFilter(clientCreator); config.Filters.Add(_exceptionFilter); _actionFilter = new RaygunWebApiActionFilter(clientCreator); config.Filters.Add(_actionFilter); var concreteActivator = config.Services.GetHttpControllerActivator(); config.Services.Replace(typeof(IHttpControllerActivator), new RaygunWebApiControllerActivator(concreteActivator, clientCreator)); var concreteControllerSelector = config.Services.GetHttpControllerSelector() ?? new DefaultHttpControllerSelector(config); config.Services.Replace(typeof(IHttpControllerSelector), new RaygunWebApiControllerSelector(concreteControllerSelector, clientCreator)); var concreteActionSelector = config.Services.GetActionSelector() ?? new ApiControllerActionSelector(); config.Services.Replace(typeof(IHttpActionSelector), new RaygunWebApiActionSelector(concreteActionSelector, clientCreator)); }
private static void AttachInternal(HttpConfiguration config, Func <HttpRequestMessage, RaygunWebApiClient> generateRaygunClientWithMessage, string applicationVersionFromAttach) { Detach(config); string applicationVersion; if (!string.IsNullOrEmpty(RaygunSettings.Settings.ApplicationVersion)) { applicationVersion = RaygunSettings.Settings.ApplicationVersion; } else { applicationVersion = applicationVersionFromAttach; } if (RaygunSettings.Settings.IsRawDataIgnored == false) { _delegatingHandler = new RaygunWebApiDelegatingHandler(); config.MessageHandlers.Add(_delegatingHandler); } var clientCreator = new RaygunWebApiClientProvider(generateRaygunClientWithMessage, applicationVersion); config.Services.Add(typeof(IExceptionLogger), new RaygunWebApiExceptionLogger(clientCreator)); _exceptionFilter = new RaygunWebApiExceptionFilter(clientCreator); config.Filters.Add(_exceptionFilter); _actionFilter = new RaygunWebApiActionFilter(clientCreator); config.Filters.Add(_actionFilter); var concreteActivator = config.Services.GetHttpControllerActivator(); config.Services.Replace(typeof(IHttpControllerActivator), new RaygunWebApiControllerActivator(concreteActivator, clientCreator)); var concreteControllerSelector = config.Services.GetHttpControllerSelector() ?? new DefaultHttpControllerSelector(config); config.Services.Replace(typeof(IHttpControllerSelector), new RaygunWebApiControllerSelector(concreteControllerSelector, clientCreator)); var concreteActionSelector = config.Services.GetActionSelector() ?? new ApiControllerActionSelector(); config.Services.Replace(typeof(IHttpActionSelector), new RaygunWebApiActionSelector(concreteActionSelector, clientCreator)); }
/// <summary> /// Causes Raygun4Net to listen for exceptions. /// </summary> /// <param name="config">The HttpConfiguration to attach to.</param> /// <param name="generateRaygunClient">An optional function to provide a custom RaygunWebApiClient instance to use for reporting exceptions.</param> public static void Attach(HttpConfiguration config, Func <RaygunWebApiClient> generateRaygunClient = null) { Detach(config); string applicationVersion; if (!string.IsNullOrEmpty(RaygunSettings.Settings.ApplicationVersion)) { applicationVersion = RaygunSettings.Settings.ApplicationVersion; } else { var entryAssembly = Assembly.GetCallingAssembly(); applicationVersion = entryAssembly.GetName().Version.ToString(); } config.MessageHandlers.Add(new RaygunWebApiDelegatingHandler()); var clientCreator = new RaygunWebApiClientProvider(generateRaygunClient, applicationVersion); config.Services.Add(typeof(IExceptionLogger), new RaygunWebApiExceptionLogger(clientCreator)); _exceptionFilter = new RaygunWebApiExceptionFilter(clientCreator); config.Filters.Add(_exceptionFilter); _actionFilter = new RaygunWebApiActionFilter(clientCreator); config.Filters.Add(_actionFilter); var concreteActivator = config.Services.GetHttpControllerActivator(); config.Services.Replace(typeof(IHttpControllerActivator), new RaygunWebApiControllerActivator(concreteActivator, clientCreator)); var concreteControllerSelector = config.Services.GetHttpControllerSelector() ?? new DefaultHttpControllerSelector(config); config.Services.Replace(typeof(IHttpControllerSelector), new RaygunWebApiControllerSelector(concreteControllerSelector, clientCreator)); var concreteActionSelector = config.Services.GetActionSelector() ?? new ApiControllerActionSelector(); config.Services.Replace(typeof(IHttpActionSelector), new RaygunWebApiActionSelector(concreteActionSelector, clientCreator)); }
/// <summary> /// Causes Raygun4Net to listen for exceptions. /// </summary> /// <param name="config">The HttpConfiguration to attach to.</param> /// <param name="generateRaygunClient">An optional function to provide a custom RaygunWebApiClient instance to use for reporting exceptions.</param> public static void Attach(HttpConfiguration config, Func<RaygunWebApiClient> generateRaygunClient = null) { Detach(config); var clientCreator = new RaygunWebApiClientProvider(generateRaygunClient); config.Services.Add(typeof(IExceptionLogger), new RaygunWebApiExceptionLogger(clientCreator)); _exceptionFilter = new RaygunWebApiExceptionFilter(clientCreator); config.Filters.Add(_exceptionFilter); _actionFilter = new RaygunWebApiActionFilter(clientCreator); config.Filters.Add(_actionFilter); var concreteActivator = config.Services.GetHttpControllerActivator(); config.Services.Replace(typeof(IHttpControllerActivator), new RaygunWebApiControllerActivator(concreteActivator, clientCreator)); var concreteControllerSelector = config.Services.GetHttpControllerSelector() ?? new DefaultHttpControllerSelector(config); config.Services.Replace(typeof(IHttpControllerSelector), new RaygunWebApiControllerSelector(concreteControllerSelector, clientCreator)); var concreteActionSelector = config.Services.GetActionSelector() ?? new ApiControllerActionSelector(); config.Services.Replace(typeof(IHttpActionSelector), new RaygunWebApiActionSelector(concreteActionSelector, clientCreator)); }
private static void AttachInternal(HttpConfiguration config, Func<HttpRequestMessage, RaygunWebApiClient> generateRaygunClientWithMessage, string applicationVersionFromAttach) { Detach(config); string applicationVersion; if (!string.IsNullOrEmpty(RaygunSettings.Settings.ApplicationVersion)) { applicationVersion = RaygunSettings.Settings.ApplicationVersion; } else { applicationVersion = applicationVersionFromAttach; } var owinAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName.StartsWith("Owin")); if (owinAssembly == null) { config.MessageHandlers.Add(new RaygunWebApiDelegatingHandler()); } var clientCreator = new RaygunWebApiClientProvider(generateRaygunClientWithMessage, applicationVersion); config.Services.Add(typeof(IExceptionLogger), new RaygunWebApiExceptionLogger(clientCreator)); _exceptionFilter = new RaygunWebApiExceptionFilter(clientCreator); config.Filters.Add(_exceptionFilter); _actionFilter = new RaygunWebApiActionFilter(clientCreator); config.Filters.Add(_actionFilter); var concreteActivator = config.Services.GetHttpControllerActivator(); config.Services.Replace(typeof(IHttpControllerActivator), new RaygunWebApiControllerActivator(concreteActivator, clientCreator)); var concreteControllerSelector = config.Services.GetHttpControllerSelector() ?? new DefaultHttpControllerSelector(config); config.Services.Replace(typeof(IHttpControllerSelector), new RaygunWebApiControllerSelector(concreteControllerSelector, clientCreator)); var concreteActionSelector = config.Services.GetActionSelector() ?? new ApiControllerActionSelector(); config.Services.Replace(typeof(IHttpActionSelector), new RaygunWebApiActionSelector(concreteActionSelector, clientCreator)); }