/// <remarks>Never run a cell process entry point more than once per AppDomain.</remarks>
        public void Run(CellDefinition cellDefinition, IDeploymentReader deploymentReader, ApplicationEnvironment environment)
        {
            // Load Assemblies into AppDomain
            var assemblies = deploymentReader.GetAssembliesAndSymbols(cellDefinition.Assemblies).ToList();
            var loader = new AssemblyLoader();
            loader.LoadAssembliesIntoAppDomain(assemblies, environment);

            // Create the EntryPoint
            var entryPointTypeName = cellDefinition.EntryPointTypeName;
            if (string.IsNullOrEmpty(entryPointTypeName))
            {
                entryPointTypeName = "Lokad.Cloud.Services.AppEntryPoint.EntryPoint, Lokad.Cloud.Services.AppEntryPoint";
            }

            var entryPointType = Type.GetType(entryPointTypeName);
            if (entryPointType == null)
            {
                throw new InvalidOperationException("Type " + entryPointTypeName + " not found.");
            }

            _appEntryPoint = (IApplicationEntryPoint)Activator.CreateInstance(entryPointType);

            var settings = string.IsNullOrEmpty(cellDefinition.SettingsXml) ? new XElement("Settings") : XElement.Parse(cellDefinition.SettingsXml);

            // Run
            _appEntryPoint.Run(settings, deploymentReader, environment, _externalCancellationTokenSource.Token);
        }
示例#2
0
        /// <remarks>Never run a cell process entry point more than once per AppDomain.</remarks>
        public void Run(CellDefinition cellDefinition, IDeploymentReader deploymentReader, ApplicationEnvironment environment)
        {
            // Load Assemblies into AppDomain
            var assemblies = deploymentReader.GetAssembliesAndSymbols(cellDefinition.Assemblies).ToList();
            var loader     = new AssemblyLoader();

            loader.LoadAssembliesIntoAppDomain(assemblies, environment);

            // Create the EntryPoint
            var entryPointTypeName = cellDefinition.EntryPointTypeName;

            if (string.IsNullOrEmpty(entryPointTypeName))
            {
                entryPointTypeName = "Lokad.Cloud.Services.AppEntryPoint.EntryPoint, Lokad.Cloud.Services.AppEntryPoint";
            }

            var entryPointType = Type.GetType(entryPointTypeName);

            if (entryPointType == null)
            {
                throw new InvalidOperationException("Type " + entryPointTypeName + " not found.");
            }

            _appEntryPoint = (IApplicationEntryPoint)Activator.CreateInstance(entryPointType);

            var settings = string.IsNullOrEmpty(cellDefinition.SettingsXml) ? new XElement("Settings") : XElement.Parse(cellDefinition.SettingsXml);

            // Run
            _appEntryPoint.Run(settings, deploymentReader, environment, _externalCancellationTokenSource.Token);
        }
示例#3
0
        public static void Start(this Application application, string executionPath, string mainAssemblyName, string typeNameOrFullName = null, params object[] arguments)
        {
            var mainAssemblyPath = Path.Combine(executionPath, string.Concat(mainAssemblyName, ".dll"));

            var mainAssembly = Assembly.LoadFrom(mainAssemblyPath);

            if (typeNameOrFullName == null)
            {
                typeNameOrFullName = "ApplicationEntryPoint";
            }

            if (!typeNameOrFullName.Contains("."))
            {
                typeNameOrFullName = string.Concat(mainAssemblyName, ".", typeNameOrFullName);
            }

            var entryPointType = mainAssembly.GetType(typeNameOrFullName, true);

            var constructors = entryPointType.GetConstructors();

            IApplicationEntryPoint entryPoint = null;

            if (constructors.Length == 1)
            {
                var parameters = constructors[0].GetParameters();

                switch (parameters.Length)
                {
                case 0:
                    entryPoint = (IApplicationEntryPoint)Activator.CreateInstance(entryPointType);
                    break;

                case 1:
                    if (parameters[0].ParameterType == typeof(Application))
                    {
                        entryPoint = (IApplicationEntryPoint)Activator.CreateInstance(entryPointType, application);
                    }
                    break;
                }
            }
            else
            {
                entryPoint = entryPointType.CreateInstance <IApplicationEntryPoint>(arguments);
            }

            entryPoint.Start();

            if (application.MainWindow != null)
            {
                application.Run();
            }
        }
示例#4
0
        public ConsoleApplicationEntryPoint(
            [NotNull] IApplicationEntryPoint applicationEntryPoint, [NotNull] ILogger logger,
            [NotNull] IBackgroundServicesManager backgroundServicesManager,
            [NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] IConfiguration configuration,
            [NotNull] IConsoleApplicationHelpTextPresenter consoleApplicationHelpTextPresenter, [NotNull] IBus bus)
            : base(logger, bus, applicationLifetimeManager)
        {
            _ApplicationEntryPoint = applicationEntryPoint ?? throw new ArgumentNullException(nameof(applicationEntryPoint));

            _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager));

            _Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            _ConsoleApplicationHelpTextPresenter = consoleApplicationHelpTextPresenter
                                                   ?? throw new ArgumentNullException(nameof(consoleApplicationHelpTextPresenter));

            _BackgroundServicesManager = backgroundServicesManager ?? throw new ArgumentNullException(nameof(backgroundServicesManager));
        }