Exemple #1
0
        /// <summary>
        /// sets the initial data for an application
        /// </summary>
        /// <param name="variables">All variables needed to run the application.</param>
        public void ConfigureApplication(ApplicationVariable[] variables)
        {
            try
            {
                ApplicationParsedData parsedData = PluginHelper.GetParsedData(variables);
                this.startupLogger = new FileLogger(parsedData.StartupLogFilePath);

                this.appName = RemoveSpecialCharacters(parsedData.AppInfo.Name) + parsedData.AppInfo.Port.ToString(CultureInfo.InvariantCulture);
                this.appPath = parsedData.AppInfo.Path;

                this.applicationInfo = parsedData.AppInfo;

                this.autoWireTemplates = parsedData.AutoWireTemplates;

                this.aspDotNetVersion = this.GetAppVersion(this.applicationInfo);

                this.AutowireApp(parsedData.AppInfo, variables, parsedData.GetServices(), parsedData.LogFilePath, parsedData.ErrorLogFilePath);

                this.cpuTarget = this.GetCpuTarget(this.applicationInfo);
            }
            catch (Exception ex)
            {
                this.startupLogger.Error(ex.ToString());
                throw;
            }
        }
        /// <summary>
        /// Detects the platform.
        /// </summary>
        /// <param name="assemblyPath">The assembly path.</param>
        /// <returns>CPU target</returns>
        public static CpuTarget DetectPlatform(string assemblyPath)
        {
            if (string.IsNullOrEmpty(assemblyPath))
            {
                throw new ArgumentException("Argument null or empty", "assemblyPath");
            }

            AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;

            setup.ApplicationBase = Path.GetDirectoryName(assemblyPath);
            string    domainName = Guid.NewGuid().ToString();
            AppDomain domain     = AppDomain.CreateDomain(domainName, null, setup);

            try
            {
                LoadAssemblyHelper obj = (LoadAssemblyHelper)domain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, "Uhuru.Utilities.LoadAssemblyHelper");

                CpuTarget target = obj.DetectPlatform(assemblyPath);

                return(target);
            }
            catch (System.BadImageFormatException)
            {
                return(CpuTarget.Unknown);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                AppDomain.Unload(domain);
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the cpu target for the application.
        /// </summary>
        /// <param name="appInfo">The application info structure.</param>
        /// <returns>CPU target</returns>
        private CpuTarget GetCpuTarget(ApplicationInfo appInfo)
        {
            this.startupLogger.Info(Strings.DetectingCpuTarget);

            string[] allAssemblies = Directory.GetFiles(appInfo.Path, "*.dll", SearchOption.AllDirectories);

            CpuTarget target = CpuTarget.X64;

            foreach (string assembly in allAssemblies)
            {
                target = PlatformTarget.DetectPlatform(assembly);
                if (target == CpuTarget.X86)
                {
                    break;
                }
            }

            this.startupLogger.Info(Strings.DetectedCpuTarget, target.ToString());

            return(target);
        }
        /// <summary>
        /// sets the initial data for an application
        /// </summary>
        /// <param name="variables">All variables needed to run the application.</param>
        public void ConfigureApplication(ApplicationVariable[] variables)
        {
            try
            {
                ApplicationParsedData parsedData = PluginHelper.GetParsedData(variables);
                this.startupLogger = new FileLogger(parsedData.StartupLogFilePath);

                this.appName = RemoveSpecialCharacters(parsedData.AppInfo.Name) + parsedData.AppInfo.Port.ToString(CultureInfo.InvariantCulture);
                this.appPath = parsedData.AppInfo.Path;

                this.applicationInfo = parsedData.AppInfo;

                this.autoWireTemplates = parsedData.AutoWireTemplates;

                this.aspDotNetVersion = this.GetAppVersion(this.applicationInfo);

                this.cpuTarget = this.GetCpuTarget(this.applicationInfo);

                this.AutowireApp(parsedData.AppInfo, variables, parsedData.GetServices(), parsedData.LogFilePath, parsedData.ErrorLogFilePath);
            }
            catch (Exception ex)
            {
                this.startupLogger.Error(ex.ToString());
                throw;
            }
        }