本文整理汇总了C#中Application.Check方法的典型用法代码示例。如果您正苦于以下问题:C# Application.Check方法的具体用法?C# Application.Check怎么用?C# Application.Check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application.Check方法的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)
{
//.........这里部分代码省略.........
示例2: HasUpdateSingle
private bool HasUpdateSingle(string localPath)
{
this.m_DualLog.WriteEntry("Checking whether updates exist for " + localPath + ".");
Cache c = new Cache(false);
ApplicationInstanceList list = c.Get<ApplicationInstanceList>("instances");
for (int i = 0; i < list.Count; i++)
{
if (list[i].FilesystemPath == localPath)
{
// Perform update check.
Application a = new Application(c, new Uri(list[i].UpdateUrl), list[i].FilesystemPath);
list[i].LastCheckTime = DateTime.Now;
try
{
if (a.Check())
{
this.m_DualLog.WriteEntry("Updates exist for " + localPath + ".");
return true;
}
else
{
this.m_DualLog.WriteEntry("No updates available for " + localPath + ".");
return false;
}
}
catch (WebException)
{
this.m_DualLog.WriteEntry("Unable to check " + list[i].UpdateUrl + " for updates. The server is not responding.", EventLogEntryType.Warning);
}
}
}
return false;
}