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


C# AgentType.GetMethods方法代码示例

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


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

示例1: parseMethodString

        public static MethodDef parseMethodString(List<Nodes.Node.ErrorCheck> result, DefaultObject node, AgentType agentType, MethodType methodType, string str)
        {
            try {
                if (agentType != null) {
                    int pos = str.IndexOf('(');

                    if (pos < 0)
                    { return null; }

                    string ownerName = agentType.ToString();
                    int pointIndex = str.IndexOf('.');

                    if (pointIndex > -1 && pointIndex < pos) {
                        ownerName = str.Substring(0, pointIndex);
                        Nodes.Behavior behavior = node.Behavior as Nodes.Behavior;

                        if (ownerName != VariableDef.kSelf && !Plugin.IsInstanceName(ownerName, behavior))
                        {
                            throw new Exception("The instance does not exist.");
                        }

                        str = str.Substring(pointIndex + 1, str.Length - pointIndex - 1);
                        agentType = Plugin.GetInstanceAgentType(ownerName, behavior, agentType);
                        //if (agentType == node.Behavior.AgentType)
                        //    ownerName = VariableDef.kSelf;
                        pos = str.IndexOf('(');
                    }

                    IList<MethodDef> actions = agentType.GetMethods(methodType);
                    string actionName = str.Substring(0, pos);
                    foreach(MethodDef actionTypeIt in actions) {
                        if (actionTypeIt.Name == actionName
#if BEHAVIAC_NAMESPACE_FIX
                            || actionTypeIt.Name.EndsWith(actionName)
#endif
                           ) {
                            MethodDef method = new MethodDef(actionTypeIt);
                            method.Owner = ownerName;

                            List<string> paras = parseParams(str.Substring(pos + 1, str.Length - pos - 2));
                            //Debug.Check((paras.Count == actionTypeIt.Params.Count));

                            //if (paras.Count == actionTypeIt.Params.Count)
                            {
                                for (int i = 0; i < paras.Count; ++i) {
                                    if (i >= method.Params.Count) {
                                        break;
                                    }

                                    string param = paras[i];
                                    MethodDef.Param par = method.Params[i];
                                    bool bOk = parseParam(result, node, method, par, param);

                                    if (!bOk) {
                                        throw new Exception(string.Format(Resources.ExceptionDesignerAttributeIllegalFloatValue, str));
                                    }
                                }
                            }

                            return method;
                        }
                    }
                }

            } catch (Exception) {
                //System.Windows.Forms.MessageBox.Show(str, Resources.LoadError, System.Windows.Forms.MessageBoxButtons.OK);
                if (result != null)
                {
                    Nodes.Node n = node as Nodes.Node;
                    string label = "";
                    if (n == null)
                    {
                        Attachments.Attachment a = node as Attachments.Attachment;
                        if (a != null)
                        {
                            n = a.Node;
                            label = a.Label;
                        }
                    }
                    else
                    {
                        label = n.Label;
                    }

                    Nodes.Node.ErrorCheck error = new Nodes.Node.ErrorCheck(n, node.Id, label, Nodes.ErrorCheckLevel.Error, str);
                    result.Add(error);
                }
            }

            return null;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:91,代码来源:DesignerMethodEnum.cs

示例2: parseMethodString

        public static MethodDef parseMethodString(NodeTag.DefaultObject node, AgentType agentType, MethodType methodType, string str)
        {
            try
            {
                if (agentType != null)
                {
                    int pos = str.IndexOf('(');
                    if (pos < 0)
                        return null;

                    string ownerName = agentType.ToString();
                    int pointIndex = str.IndexOf('.');
                    if (pointIndex > -1 && pointIndex < pos)
                    {
                        ownerName = str.Substring(0, pointIndex);
                        str = str.Substring(pointIndex + 1, str.Length - pointIndex - 1);
                        agentType = Plugin.GetInstanceAgentType(ownerName, agentType);
                        if (agentType == node.Behavior.AgentType)
                            ownerName = VariableDef.kSelf;
                        pos = str.IndexOf('(');
                    }

                    IList<MethodDef> actions = agentType.GetMethods(methodType);
                    string actionName = str.Substring(0, pos);
                    foreach (MethodDef actionTypeIt in actions)
                    {
                        if (actionTypeIt.Name == actionName
            #if BEHAVIAC_NAMESPACE_FIX
                        || actionTypeIt.Name.EndsWith(actionName)
            #endif
            )
                        {
                            MethodDef method = new MethodDef(actionTypeIt);
                            method.Owner = ownerName;

                            List<string> paras = parseParams(str.Substring(pos + 1, str.Length - pos - 2));
                            //Debug.Check((paras.Count == actionTypeIt.Params.Count));

                            //if (paras.Count == actionTypeIt.Params.Count)
                            {
                                for (int i = 0; i < paras.Count; ++i)
                                {
                                    string param = paras[i];
                                    string[] tokens = null;
                                    if (param[0] == '\"')
                                    {
                                        param = param.Substring(1, param.Length - 2);
                                    }
                                    else if (param[0] == '{')
                                    {
                                        //struct

                                        //to set it as action.Method is used in the following parsing
                                        Nodes.Action action = node as Nodes.Action;
                                        if (action != null)
                                        {
                                            action.Method = method;
                                        }
                                    }
                                    else
                                    {
                                        tokens = param.Split(' ');
                                    }

                                    if (i < method.Params.Count)
                                    {
                                        MethodDef.Param par = method.Params[i];

                                        if (tokens != null && tokens.Length > 1)
                                        {
                                            //par
                                            VariableDef var = setParameter(node, tokens[tokens.Length - 1]);
                                            if (var != null)
                                                par.Value = var;
                                            //else
                                            //    throw new Exception(string.Format(Resources.ExceptionDesignerAttributeIllegalFloatValue, str));
                                        }
                                        else
                                        {
                                            bool bOk = Plugin.InvokeTypeParser(par.Type, param, (object value) => par.Value = value, node, par.Name);
                                            if (!bOk)
                                                throw new Exception(string.Format(Resources.ExceptionDesignerAttributeIllegalFloatValue, str));
                                        }
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }

                            return method;
                        }
                    }
                }
            }
            catch (Exception)
            {
                System.Windows.Forms.MessageBox.Show(str, Resources.LoadError, System.Windows.Forms.MessageBoxButtons.OK);
            }
//.........这里部分代码省略.........
开发者ID:godsonhand,项目名称:behaviac,代码行数:101,代码来源:DesignerMethodEnum.cs


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