当前位置: 首页>>代码示例>>C#>>正文


C# Application.Update方法代码示例

本文整理汇总了C#中Application.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Application.Update方法的具体用法?C# Application.Update怎么用?C# Application.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application的用法示例。


在下文中一共展示了Application.Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("must have at least 1 argument.");
                return;
            }

            switch (args[0])
            {
                case "update-local":
                    {
                        if (args.Length < 2)
                        {
                            Console.WriteLine("must have at least 2 arguments (patch <uri>).");
                            return;
                        }

                        Uri uri = new Uri(args[1]);
                        Cache c = new Cache(true);

                        Application a = new Application(c, uri, Environment.CurrentDirectory);
                        int opers = 0;
                        a.Update((status, info) =>
                            {
                                switch (status)
                                {
                                    case Application.UpdateStatus.RetrievingFileList:
                                        Console.Write("requesting current state.. ");
                                        break;
                                    case Application.UpdateStatus.RetrievedFileList:
                                        Console.WriteLine(info + " files to scan.");
                                        break;
                                    case Application.UpdateStatus.DeletionStart:
                                        Console.Write("deleting " + info + ".. ");
                                        break;
                                    case Application.UpdateStatus.PatchStart:
                                        Console.Write("patching " + info + ".. ");
                                        break;
                                    case Application.UpdateStatus.PatchApplied:
                                        Console.Write(a + ". ");
                                        break;
                                    case Application.UpdateStatus.DownloadNewStart:
                                    case Application.UpdateStatus.DownloadFreshStart:
                                        Console.Write("downloading " + info + ".. ");
                                        break;
                                    case Application.UpdateStatus.DeletionFinish:
                                    case Application.UpdateStatus.PatchFinish:
                                    case Application.UpdateStatus.DownloadNewFinish:
                                    case Application.UpdateStatus.DownloadFreshFinish:
                                        Console.WriteLine("done.");
                                        opers++;
                                        break;
                                    case Application.UpdateStatus.Complete:
                                        Console.WriteLine("patch complete (" + opers + " operations).");
                                        break;
                                }
                            });

                        return;
                    }
                case "check-local":
                    {
                        if (args.Length < 2)
                        {
                            Console.WriteLine("must have at least 2 arguments (patch <uri>).");
                            return;
                        }

                        Uri uri = new Uri(args[1]);
                        Cache c = new Cache(true);

                        Application a = new Application(c, uri, Environment.CurrentDirectory);
                        if (a.Check())
                            Console.WriteLine("there are updates available.");
                        else
                            Console.WriteLine("there are no updates.");

                        return;
                    }
                case "register":
                    {
                        if (args.Length < 2)
                        {
                            Console.WriteLine("must have at least 2 arguments (register <uri>).");
                            return;
                        }
                        
                        Uri uri = new Uri(args[1]);
                        if (API.Register(uri))
                            Console.WriteLine("registration complete.");
                        else
                            Console.WriteLine("registration failed.");

                        return;
                    }
                case "check":
                    {
                        if (args.Length != 1)
                        {
//.........这里部分代码省略.........
开发者ID:hach-que,项目名称:Pivot.Update,代码行数:101,代码来源:Program.cs

示例2: PerformUpdateSingle

        private void PerformUpdateSingle(string localPath, string restartPath = null)
        {
            Cache c = new Cache(false);
            c.Set<bool>("locked", true);
            ApplicationInstanceList list = c.Get<ApplicationInstanceList>("instances");
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].FilesystemPath == localPath)
                {
                    this.m_DualLog.WriteEntry("Now checking " + list[i].UpdateUrl + " for updates.");

                    // Perform update check.
                    string result = "";
                    Application a = new Application(c, new Uri(list[i].UpdateUrl), list[i].FilesystemPath);
                    list[i].LastCheckTime = DateTime.Now;
                    try
                    {
                        a.Update((status, info) =>
                        {
                            switch (status)
                            {
                                case Application.UpdateStatus.Starting:
                                    result += "Update is starting...\r\n";
                                    break;
                                case Application.UpdateStatus.RetrievingFileList:
                                    result += "Retrieving file list... ";
                                    break;
                                case Application.UpdateStatus.RetrievedFileList:
                                    result += "done (" + info + " files to scan).\r\n";
                                    break;
                                case Application.UpdateStatus.DeletionStart:
                                    result += "Deleting " + info + "... ";
                                    break;
                                case Application.UpdateStatus.DownloadNewStart:
                                case Application.UpdateStatus.DownloadFreshStart:
                                    result += "Downloading " + info + "... ";
                                    break;
                                case Application.UpdateStatus.PatchStart:
                                    result += "Patching " + info + "... ";
                                    break;
                                case Application.UpdateStatus.PatchApplied:
                                    result += info + ". ";
                                    break;
                                case Application.UpdateStatus.Complete:
                                    result += "Update is complete.\r\n";
                                    break;
                                case Application.UpdateStatus.DeletionFinish:
                                case Application.UpdateStatus.DownloadNewFinish:
                                case Application.UpdateStatus.DownloadFreshFinish:
                                case Application.UpdateStatus.PatchFinish:
                                    result += "done.\r\n";
                                    break;
                            }
                        });

                        this.m_DualLog.WriteEntry(list[i].UpdateUrl + " has been checked for updates.\r\n\r\n" + result);
                    }
                    catch (WebException)
                    {
                        this.m_DualLog.WriteEntry("Unable to check " + list[i].UpdateUrl + " for updates.  The server is not responding.", EventLogEntryType.Warning);
                    }
                }
            }
            c.Set<ApplicationInstanceList>("instances", list);
            c.Set<bool>("locked", false);

            // Restart game if possible.
            if (restartPath != null)
                WindowsNative.LaunchPathAsUser(restartPath);
        }
开发者ID:hach-que,项目名称:Pivot.Update,代码行数:70,代码来源:Manager.cs


注:本文中的Application.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。