本文整理汇总了C#中Robot.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Robot.Reset方法的具体用法?C# Robot.Reset怎么用?C# Robot.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Robot
的用法示例。
在下文中一共展示了Robot.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public void Register(Robot robot)
{
robot.Respond(@"PING$",msg => msg.Send("PONG"));
robot.Respond(@"ECHO (.*)$", msg => msg.Send(msg.Match[1]));
robot.Respond(@"TIME$", msg => msg.Send(string.Format("Server time is: {0} {1}", DateTime.Now.ToString("U"), TimeZoneInfo.Local.DisplayName)));
robot.Respond(@"DIE$", msg => Environment.Exit(0));
robot.Respond(@"RESPAWN$", msg => robot.Reset());
}
示例2: Register
public void Register(Robot robot)
{
RememberConfiguredSources(robot);
RememberConfiguredAliases(robot);
RememberConfiguredAutoReset(robot);
robot.Respond(BuildCommand(new[] {List, Package, Source}),
msg => msg.Send(GetRememberedSources(robot).ToArray()));
robot.Respond(BuildCommand(new []{Add, Package, Source, ParamWithNoSpaces}), msg =>
{
var source = msg.Match[4].ToString(CultureInfo.InvariantCulture);
msg.Send(!AddSource(source, robot)
? "I already know about this one."
: "Consider it done.");
});
robot.Respond(BuildCommand(new []{Remove, Package, Source, ParamWithNoSpaces}), msg =>
{
var source = msg.Match[4].ToString(CultureInfo.InvariantCulture);
msg.Send(RemoveSource(source, robot)
? "I'll forget it immediately."
: "It's easy to forget what you never knew.");
});
robot.Respond(BuildCommand(new[] { Update, Package, ParamWithNoSpaces, Restart}, new[] {3}), msg =>
{
//ID of the package to be looked up
var packageId = msg.Match[3].ToString(CultureInfo.InvariantCulture);
string unaliasedPackageId;
var knownAliases = GetRememberedAliases(robot);
if (!knownAliases.TryGetValue(packageId.ToLower(), out unaliasedPackageId))
{
unaliasedPackageId = packageId;
}
msg.Send("Building repositories...");
IPackageRepository repo = BuildPackagesRepository(robot);
//Get the list of all NuGet packages with ID 'EntityFramework'
msg.Send("Finding package...");
List<IPackage> packages = repo.FindPackagesById(unaliasedPackageId).ToList();
IPackage latestPackageVersion;
if (packages.Any())
{
//try to get the "absolute latest version" and fall back to packages.Last() if none are marked as such
latestPackageVersion = packages.Any(p => p.IsAbsoluteLatestVersion)
? packages.First(p => p.IsAbsoluteLatestVersion)
: packages.Last();
msg.Send("Found it! Downloading...");
}
else
{
msg.Send("I couldn't find it...sorry!");
return;
}
//Initialize the package manager
string path = GetPackagesPath();
var packageManager = new PackageManager(repo, path);
//Download and unzip the package
packageManager.InstallPackage(latestPackageVersion, false, true);//TODO: allow these flags to be configurable? allow user to specify version?
msg.Send("Finished downloading...");
if (ShouldAutoResetAfterUpdate(robot) || (msg.Match.Length >= 5 && Regex.IsMatch(msg.Match[4], Restart)))
{
//They submitted the reset parameter or auto-reset is on.
msg.Send("Resetting...please wait.");
robot.Reset();
}
});
robot.Respond(BuildCommand(new []{List, Package, Alias}),
msg => msg.Send(GetRememberedAliases(robot).Select(kvp => string.Format("{0} = {1}", kvp.Key, kvp.Value)).ToArray()));
robot.Respond(BuildCommand(new []{Add, Package, Alias, ParamWithNoSpaces}), msg =>
{
var alias = msg.Match[4].ToString(CultureInfo.InvariantCulture);
AddAlias(alias, robot);
msg.Send("I'll be sure to remember that.");
});
robot.Respond(BuildCommand(new []{Remove, Package, Alias, ParamWithNoSpaces}), msg =>
{
var alias = msg.Match[4].ToString(CultureInfo.InvariantCulture);
RemoveAlias(alias, robot);
msg.Send("As you wish.");
});
}