Пример #1
0
        public static IApplicationHost Create(HostedAppInfo appInfo)
        {
            AppDomain domain = AppDomain.CreateDomain(appInfo.Name, null, new AppDomainSetup
            {
                ApplicationBase                = AppDomain.CurrentDomain.BaseDirectory,
                PrivateBinPathProbe            = null,
                DisallowApplicationBaseProbing = true,
                //TODO: use plugin app.config
                ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
            });
            var appDomainInitializer =
                (AppDomainInitializer)
                domain.CreateInstanceFromAndUnwrap(typeof(AppDomainInitializer).Assembly.Location, typeof(AppDomainInitializer).FullName, false, BindingFlags.Default, null, null, null, null);

            appDomainInitializer.Initialize(appInfo.AssembliesToLoad, appInfo.NativeDllToLoad.ToArray());

            var applicationHost =
                (ApplicationHost)domain.CreateInstanceFromAndUnwrap(typeof(ApplicationHost).Assembly.Location, typeof(ApplicationHost).FullName, false, BindingFlags.Default, null, null, null, null);

            return(new ApplicationHostProxy(applicationHost.load(appInfo), domain));
        }
Пример #2
0
        private IApplicationHost load(HostedAppInfo appInfo)
        {
            Type hostType = typeof(ApplicationHost <>).MakeGenericType(Type.GetType(appInfo.AppType));

            return((IApplicationHost)Activator.CreateInstance(hostType, appInfo));
        }
Пример #3
0
 /// <summary>
 /// Extracted for testing purposes.
 /// </summary>
 internal virtual IApplicationHost CreateApplicationHost(HostedAppInfo appInfo)
 {
     return(ApplicationHost.Create(appInfo));
 }