BlueCollar.MachineProxy.SetupandInvokeEntryPoint C# (CSharp) Метод

SetupandInvokeEntryPoint() приватный Метод

Sets up and invokes an entry point on an HttpApplication implementer found by probing the given bin path.
private SetupandInvokeEntryPoint ( ILogger logger, string binPath ) : void
logger ILogger The logger to use when probing.
binPath string The bin path to probe.
Результат void
        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();
                            }
                        }
                    }
                }
            }
        }