Пример #1
0
 internal SubAppContainer(string directory, string filename, string objectName, ISubApp_V1 localSubApp)
 {
     this.directory   = directory;
     this.filename    = filename;
     this.objectName  = objectName;
     this.appDomain   = System.AppDomain.CurrentDomain;
     this.localSubApp = true;
     this.app         = localSubApp;
 }
Пример #2
0
        internal bool LoadLocal(ISubApp_V1 subApp)
        {
            System.IO.FileInfo fi = new System.IO.FileInfo(System.Reflection.Assembly.GetCallingAssembly().Location);

            SubAppContainer sac = new SubAppContainer(fi.DirectoryName, fi.Name + @"." + fi.Extension, subApp.GetType().FullName, subApp);

            if (!this.LoadedApps.ContainsKey(sac.App.ShortName))
            {
                this.LoadedApps.Add(sac.App.ShortName, sac);
                sac.App.MessageOut += new MessageOutEventHandler(App_MessageOut);
            }

            return(true);
        }
Пример #3
0
        public void Unload()
        {
            if (app != null && !this.localSubApp)
            {
                //AJ: Stop the SubApp gracefully
                this.app.Stop();
                this.app = null;

                //AJ: Remove the Remote Loader
                this.remoteLoader = null;

                //AJ: Unload the AppDomain
                AppDomain.Unload(this.appDomain);
                this.appDomain = null;
            }
        }
Пример #4
0
        public void Load()
        {
            if (app == null && !this.localSubApp)
            {
                //AJ: The base directory is the same as this appdomain because we'll need the ISubApp_V1
                this.appDomainSetup.ApplicationBase = System.AppDomain.CurrentDomain.BaseDirectory;
                this.appDomainSetup.ApplicationName = this.objectName;
                this.appDomainSetup.ShadowCopyFiles = @"true";

                //AJ: Create the new AppDomain
                this.appDomain = AppDomain.CreateDomain(this.objectName, null, this.appDomainSetup);

                //AJ: Create the Remote Loader in the new AppDomain and retrive a proxy copy of it
                this.remoteLoader = (RemoteLoader)appDomain.CreateInstanceFromAndUnwrap("TigerLoaderLib.dll", "Tiger.Loader.Lib.RemoteLoader");

                //AJ: Use the Remote Loader to load the SubApp and return a proxy copy of it
                this.app = (ISubApp_V1)this.remoteLoader.LoadObject(this.directory, this.filename, this.objectName);
                this.app.Start();
            }
        }