コード例 #1
0
ファイル: ServerManifest.cs プロジェクト: e2tox/topbit
        //**************************************************************
        // Load()
        //**************************************************************
        public void Load(string url)
        {
            _url = url;
            String LocalManifestPath = AppDomain.CurrentDomain.BaseDirectory +
                                       Path.GetFileName((new Uri(_url)).LocalPath);

            WebFileLoader.UpdateFile(_url, LocalManifestPath);

            _manifest = new XmlDocument();
            _manifest.Load(LocalManifestPath);

            ApplicationUrl   = _manifest.GetElementsByTagName("ApplicationUrl")[0].InnerText;
            AvailableVersion = _manifest.GetElementsByTagName("AvailableVersion")[0].InnerText;
        }
コード例 #2
0
        //**************************************************************
        // UpdateFileList()
        // - A multi-file UpdateFile
        //**************************************************************
        public static void UpdateFileList(SortedList fileList, string sourceUrl, string destPath)
        {
            Resource currentResource;

            //If the directory doesn't exist, create it first
            if (!Directory.Exists(destPath))
            {
                Directory.CreateDirectory(destPath);
            }

            foreach (Object o in fileList)
            {
                currentResource = (Resource)(((DictionaryEntry)o).Value);

                string url      = sourceUrl + currentResource.Name;
                string FilePath = destPath + currentResource.Name;
                WebFileLoader.UpdateFile(url, FilePath);
            }
        }
コード例 #3
0
        //**************************************************************
        // OnAssemblyResolve()
        // - This code is what does the auto-download of missing files
        //**************************************************************
        private Assembly OnAssemblyResolve(Object sender, ResolveEventArgs args)
        {
            //Check to see if the AssemblyLoad in this event is what caused the
            //event to fire again.  If so, the load failed.
            if (LoadingAssembly == true)
            {
                return(null);
            }

            LoadingAssembly = true;

            string[] AssemblyNameParts = args.Name.Split(new Char[] { ',' }, 2);
            string   AssemblyName      = AssemblyNameParts[0] + ".dll";
            string   FilePath          = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AssemblyName);

            string url;

            if (ChangeDetectionMode == ChangeDetectionModes.DirectFileCheck)
            {
                url = UpdateUrl + AssemblyName;
            }
            else
            {
                ServerManifest SM = new ServerManifest();
                SM.Load(UpdateUrl);
                url = Path.Combine(SM.ApplicationUrl, AssemblyName);
            }

            Debug.WriteLine("APPMANAGER:  Auto-downloading assembly:  " + AssemblyName + ".  From:  " + url);

            try
            {
                WebFileLoader.UpdateFile(url, FilePath);
            }
            catch (Exception e)
            {
                Debug.WriteLine("APPMANAGER:  Failed to download the missing assembly from the web server.");
                Debug.WriteLine("APPMANAGER:  " + e.ToString());
                if (ShowDefaultUI)
                {
                    MessageBox.Show("Unable to auto-download the missing parts of the application from:\r\n"
                                    + url + "\r\n\r\n"
                                    + "Make sure your connected to the network.  If the problem persists re-install the application.");
                }
                return(null);
            }

            Assembly assembly;

            try
            {
                assembly = Assembly.Load(args.Name);
            }
            catch (Exception e)
            {
                Debug.WriteLine("APPMANAGER:  Failed to load the auto-downloaded assembly.");
                Debug.WriteLine("APPMANAGER:  " + e.ToString());
                return(null);
            }
            finally
            {
                LoadingAssembly = false;
            }

            return(assembly);
        }