예제 #1
0
        protected override void OnInitializing()
        {
            //保证下次从主目录启动
            VersionBase.RegApp();

            var domain = AppDomain.CurrentDomain;

            domain.AssemblyResolve += assemblyResolve;
            CurrSystem              =
                domain.SetupInformation.ApplicationName.ToLower() == "accoreconsole.exe" ?
                "acore" : HostAppName;

            _plugins       = new Dictionary <string, PluginBase>();
            _plugins[Name] = Root = this;
            Assembly       = Assembly.GetExecutingAssembly();

            _searchpaths =
                new List <string>
            {
                DirectoryEx.Bin.FullName,
                DirectoryEx.Support.FullName,
            };

            var infos =
                DirectoryEx
                .Plugins
                .GetDirectories()
                .Select(d => new PluginInfo(d))
                .Where(i => i.Name != Name);

            StartPluginTree(infos.Where(p => p.Preload), true);
            StartPluginTree(infos.Where(p => !p.Preload));
        }
예제 #2
0
        protected override void OnTerminated()
        {
            //如果有文件更新, 下一次从备份目录启动
            var file = DirectoryEx.Update.GetFile("package.xml");

            if (file != null)
            {
                if (!DirectoryEx.StartFromMain)
                {
                    VersionBase.RegApp(DirectoryEx.MainBackup);
                }
                XElement xe = XElement.Load(file.FullName);
                foreach (var e in xe.Elements())
                {
                    if (e.Name == "File")
                    {
                        string name     = e.Attribute("Name").Value;
                        var    mainfile = DirectoryEx.Update.GetFile(name);
                        mainfile.CopyTo(DirectoryEx.MainBackup.GetFileFullName(name));
                        mainfile.Delete();
                    }
                }
            }
        }