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


C# Command.Failure方法代码示例

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


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

示例1: ExecuteRequestProc

        public static CmdResult ExecuteRequestProc(CmdRequest args, Command thizcmd)
        {
            var TheBotClient = thizcmd.TheBotClient;
            OutputDelegate WriteLine = thizcmd.WriteLine;
            bool thread = args.IsTrue("--thread");
            bool queue = args.IsTrue("--queue");
            bool all = args.IsTrue("--all");
            bool kill = args.IsTrue("--kill");
            bool asyc = args.IsTrue("--async") || thread;
            TimeSpan wait;
            ManualResetEvent mre = null;
            if (args.TryGetValue("--wait", out wait))
            {
                mre = new ManualResetEvent(false);
            }
            bool newDebug = args.IsTrue("--debug");
            bool changeDebug = newDebug || args.IsTrue("--nodebug");

            bool createFresh = false;
            string id = args.Length == 0 ? "list" : GetTaskID(args, out createFresh);
            id = (id == "list") ? "" : id;
            int n = 0;
            int found = 0;
            if (id == "" || kill || changeDebug)
            {
                List<string> list = new List<string>();
                lock (TaskQueueHandler.TaskQueueHandlers)
                {
                    var atq = TheBotClient != null
                                  ? TheBotClient.AllTaskQueues()
                                  : ClientManager.SingleInstance.AllTaskQueues();
                    foreach (var queueHandler in atq)
                    {
                        if (!queueHandler.MatchesId(id)) continue;
                        bool isQueue = queueHandler.Impl == queueHandler;
                        if (isQueue) found++;
                        else n++;
                        if (changeDebug) queueHandler.DebugQueue = newDebug;
                        if (queueHandler.IsAlive)
                        {
                            string str = queueHandler.ToDebugString(true);
                            if (kill)
                            {
                                if (!all)
                                {
                                    if (!isQueue && !thread || isQueue && !queue)
                                    {
                                        WriteLine("Not killing " + str);
                                        continue;
                                    }
                                }
                                queueHandler.Abort();
                                str = "Killing " + str;
                                thizcmd.IncrResult("killed", 1);
                            }

                            WriteLine(str);
                        }
                        else
                        {
                            list.Add(queueHandler.ToDebugString(true));
                        }
                    }
                }
                foreach (var s in list)
                {
                    WriteLine(s);
                }
            }

            if (kill && createFresh)
            {
                return thizcmd.Failure("Cannot create and kill in the same operation");
            }
            string[] cmdS;
            args.TryGetValue("command", out cmdS);
            thizcmd.IncrResult("taskqueues", found);
            thizcmd.IncrResult("threads", n);
            if (cmdS == null || cmdS.Length == 0)
            {
                return thizcmd.Success("TaskQueueHandlers: " + found + ", threads: " + n);
            }

            /// task is killed if request.. now making a new one
            string cmd = Parser.Rejoin(cmdS, 0);
            bool needResult = mre != null;
            CmdResult[] result = null;
            if (createFresh) needResult = false;
            if (needResult)
            {
                result = new CmdResult[1];
            }
            CMDFLAGS flags = needResult ? CMDFLAGS.ForceResult : CMDFLAGS.Inherit;
            if (asyc) flags |= CMDFLAGS.ForceAsync;

            ThreadStart task = () =>
                                   {
                                       try
                                       {
                                           var res = TheBotClient.ExecuteCommand(cmd, args.CallerAgent, args.Output,
//.........这里部分代码省略.........
开发者ID:drzo,项目名称:opensim4opencog,代码行数:101,代码来源:ThreadCommand.cs

示例2: ExecuteRequestProc

        public static CmdResult ExecuteRequestProc(CmdRequest args, Command cmd)
        {
            if (!args.ContainsKey("to"))
                args.SetValue("to", "verb");

            ;
            if (!cmd.Client.IsLoggedInAndReady)
            {
                return cmd.Failure("Not yet logged in!");
            }
            var TheSimAvatar = cmd.WorldSystem.TheSimAvatar;

            if (TheSimAvatar.IsSitting && !TheSimAvatar.IsDrivingVehical)
            {
                cmd.WriteLine("$bot is standing up before moving.");
                TheSimAvatar.StandUp();
                // WriteLine("$bot is sitting, Please stand up to move.");
            }
            SimPosition position;
            if (!args.TryGetValue("to", out position))
            {
                return cmd.Failure("I don't understand how to move " + args.str);
            }
            if (position == null)
            {
                return cmd.Failure("Coulnd not resolve location: " + args.str);
            }
            if (!position.IsRegionAttached)
            {
                return cmd.Failure("!IsRegionAttached: " + position);
            }
            if (position.SimPosition == Vector3.Zero)
            {
                return cmd.Failure("SimPosition.Zero: " + position);
            }
            Vector3d delta0 = position.GlobalPosition - TheSimAvatar.GlobalPosition;
            Vector3 delta = new Vector3((float) delta0.X, (float) delta0.Y, (float) delta0.Z);

            float fnd;
            if (args.TryGetValue("dist", out fnd))
            {
                delta.Normalize();
                delta = delta*fnd;
                position = new SimOffsetPosition(TheSimAvatar, delta);
            }

            MovementProceedure proc;
            bool salientProc = args.TryGetValue("sproc", out proc);
            if (salientProc)
            {
                TheSimAvatar.SalientMovementProceedure = proc;
            }

            if (args.TryGetValue("proc", out proc))
            {
                TheSimAvatar.SimpleMoveToMovementProceedure = proc;
            }

            Vector3d g = position.GlobalPosition;
            TheSimAvatar.SetClient(cmd.TheBotClient);
            if (salientProc)
            {
                return cmd.Result(string.Format("SalientGoto: {0},{1},{2}", position, g, position.SimPosition),
                                  TheSimAvatar.SalientGoto(position));
            }
            else
            {
                TheSimAvatar.SetMoveTarget(position, position.GetSizeDistance());
            }
            //Client.Self.AutoPilot(g.X, g.Y, g.Z);
            // MoveThread = new Thread(MoveProc);
            return cmd.Success(string.Format("SetMoveTarget: {0},{1},{2}", position, g, position.SimPosition));
        }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:73,代码来源:MoveToCommand.cs


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