Exemplo n.º 1
0
        //**************************************************************
        // Load()
        // This static method is the way to instantiate manifest objects
        //**************************************************************
        public static AppManifest Load(string manifestFilePath)
        {
            Stream stream = null;

            try
            {
                if (!File.Exists(manifestFilePath))
                {
                    return(new AppManifest(manifestFilePath));
                }

                IFormatter formatter = new SoapFormatter();
                stream = new FileStream(manifestFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                AppManifest Manifest = (AppManifest)formatter.Deserialize(stream);
                Manifest.FilePath = manifestFilePath;
                stream.Close();
                return(Manifest);
            }
            catch (Exception e)
            {
                if (stream != null)
                {
                    stream.Close();
                }

                Debug.WriteLine("APPMANAGER:  ERROR loading app manifest, creating a new manifest.");
                Debug.WriteLine("APPMANAGER:  " + e.ToString());
                return(new AppManifest(manifestFilePath));
            }
        }
Exemplo n.º 2
0
        //**************************************************************
        // Initialize()
        // - Sets up the updater, generates the default manifest,
        //   starts the threads, etc...
        //**************************************************************
        public void Initialize()
        {
            //Load the Manifest Config File
            string AppManifestPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\";
            string AppManifestName = Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location);

            AppManifestName += ".xml";
            AppManifestPath  = Path.Combine(AppManifestPath, AppManifestName);
            Manifest         = AppManifest.Load(AppManifestPath);

            if (ChangeDetectionMode == ChangeDetectionModes.DirectFileCheck)
            {
                EnableManifestGeneration();
            }

            if (AutoFileLoad == true)
            {
                EnableFileAutoLoad();
            }

            if (Poller.AutoStart == true)
            {
                Poller.Start();
            }

            Downloader.OnDownloadProgress += new Alchemi.Updater.AppDownloader.DownloadProgressEventHandler(Downloader_OnDownloadProgress);
            Downloader.OnUpdateComplete   += new Alchemi.Updater.AppDownloader.UpdateCompleteEventHandler(Downloader_OnUpdateComplete);
            Application.ApplicationExit   += new EventHandler(OnApplicationExit);

            EventControl = new Control();
            //Access the control handle to make sure it's bound to this thread
            IntPtr h = EventControl.Handle;

            //If an update was in progress when the app was shut down,
            //continue the download now that the app has restarted.
            if (Manifest.State.Phase != UpdatePhases.Complete)
            {
                Debug.WriteLine("APPMANAGER:  Continuing update already in progress");
                Downloader.Start();
            }
        }
Exemplo n.º 3
0
        //**************************************************************
        // Initialize()
        // - Sets up the updater, generates the default manifest,
        //   starts the threads, etc...
        //**************************************************************
        public void Initialize()
        {
            //Load the Manifest Config File
            string AppManifestPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\";
            string AppManifestName = Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location);
            AppManifestName += ".xml";
            AppManifestPath = Path.Combine(AppManifestPath,AppManifestName);
            Manifest = AppManifest.Load(AppManifestPath);

            if (ChangeDetectionMode == ChangeDetectionModes.DirectFileCheck)
                EnableManifestGeneration();

            if (AutoFileLoad == true)
                EnableFileAutoLoad();

            if (Poller.AutoStart == true)
                Poller.Start();

            Downloader.OnDownloadProgress += new Alchemi.Updater.AppDownloader.DownloadProgressEventHandler(Downloader_OnDownloadProgress);
            Downloader.OnUpdateComplete += new Alchemi.Updater.AppDownloader.UpdateCompleteEventHandler(Downloader_OnUpdateComplete);
            Application.ApplicationExit += new EventHandler(OnApplicationExit);

            EventControl = new Control();
            //Access the control handle to make sure it's bound to this thread
            IntPtr h = EventControl.Handle;

            //If an update was in progress when the app was shut down,
            //continue the download now that the app has restarted.
            if (Manifest.State.Phase != UpdatePhases.Complete)
            {
                Debug.WriteLine("APPMANAGER:  Continuing update already in progress");
                Downloader.Start();
            }
        }