FindApplicationAssemblies() public method

Finds Assembly instances in the current bin path that contain types that implement HttpApplication.
public FindApplicationAssemblies ( ) : IEnumerable
return IEnumerable
Example #1
0
        /// <summary>
        /// Sets up and invokes an entry point on an <see cref="HttpApplication"/> implementer found
        /// by probing the given bin path.
        /// </summary>
        /// <param name="logger">The logger to use when probing.</param>
        /// <param name="binPath">The bin path to probe.</param>
        private void SetupandInvokeEntryPoint(ILogger logger, string binPath)
        {
            if (Directory.Exists(binPath))
            {
                HttpApplicationProbe probe = new HttpApplicationProbe(logger, binPath);
                Type type = HttpApplicationProbe.FindApplicationTypes(probe.FindApplicationAssemblies()).FirstOrDefault();

                if (type != null)
                {
                    logger.Info("Found an HTTP application requiring startup: {0}.", type.FullName);
                    HttpApplication httpApplication = null;

                    try
                    {
                        httpApplication = (HttpApplication)Activator.CreateInstance(type);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex, "Failed to create an instance of the HTTP application {0}.", type.FullName);
                    }

                    if (httpApplication != null)
                    {
                        try
                        {
                            MethodInfo entryPoint = HttpApplicationProbe.FindEntryPoint(type);

                            if (entryPoint != null)
                            {
                                logger.Info("Invoking entry point for HTTP application {0}.", type.FullName);
                                this.InvokeEventHandler(httpApplication, entryPoint);
                            }
                            else
                            {
                                logger.Info("No entry point found for HTTP application {0}.", type.FullName);
                            }

                            this.httpApplication = httpApplication;
                            httpApplication      = null;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex, "Failed to invoke the entry point for HTTP application {0}.", type.FullName);

                            if (ex.InnerException != null)
                            {
                                logger.Error(ex.InnerException);
                            }
                        }
                        finally
                        {
                            if (httpApplication != null)
                            {
                                httpApplication.Dispose();
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Sets up and invokes an entry point on an <see cref="HttpApplication"/> implementer found
        /// by probing the given bin path.
        /// </summary>
        /// <param name="logger">The logger to use when probing.</param>
        /// <param name="binPath">The bin path to probe.</param>
        private void SetupandInvokeEntryPoint(ILogger logger, string binPath)
        {
            if (Directory.Exists(binPath))
            {
                HttpApplicationProbe probe = new HttpApplicationProbe(logger, binPath);
                Type type = HttpApplicationProbe.FindApplicationTypes(probe.FindApplicationAssemblies()).FirstOrDefault();

                if (type != null)
                {
                    logger.Info("Found an HTTP application requiring startup: {0}.", type.FullName);
                    HttpApplication httpApplication = null;

                    try
                    {
                        httpApplication = (HttpApplication)Activator.CreateInstance(type);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex, "Failed to create an instance of the HTTP application {0}.", type.FullName);
                    }

                    if (httpApplication != null)
                    {
                        try
                        {
                            MethodInfo entryPoint = HttpApplicationProbe.FindEntryPoint(type);

                            if (entryPoint != null)
                            {
                                logger.Info("Invoking entry point for HTTP application {0}.", type.FullName);
                                this.InvokeEventHandler(httpApplication, entryPoint);
                            }
                            else
                            {
                                logger.Info("No entry point found for HTTP application {0}.", type.FullName);
                            }

                            this.httpApplication = httpApplication;
                            httpApplication = null;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex, "Failed to invoke the entry point for HTTP application {0}.", type.FullName);

                            if (ex.InnerException != null)
                            {
                                logger.Error(ex.InnerException);
                            }
                        }
                        finally
                        {
                            if (httpApplication != null)
                            {
                                httpApplication.Dispose();
                            }
                        }
                    }
                }
            }
        }