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


C# Robot.Reset方法代码示例

本文整理汇总了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());
        }
开发者ID:nardin,项目名称:mmbot,代码行数:12,代码来源:Ping.cs

示例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.");
            });
        }
开发者ID:jvanzella,项目名称:mmbot,代码行数:93,代码来源:NuGetScripts.cs


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