Beispiel #1
0
        public static IMethod ParseMethod(string valueStr, ref string methodName)
        {
            //Self.test_ns::AgentActionTest::Action2(0)
            if (string.IsNullOrEmpty(valueStr) || (valueStr[0] == '\"' && valueStr[1] == '\"'))
            {
                return(null);
            }

            string agentIntanceName = null;
            string agentClassName   = null;
            int    pBeginP          = ParseMethodNames(valueStr, ref agentIntanceName, ref agentClassName, ref methodName);

            uint agentClassId = Utils.MakeVariableId(agentClassName);
            uint methodId     = Utils.MakeVariableId(methodName);

            AgentMeta meta = AgentMeta.GetMeta(agentClassId);

            Debug.Check(meta != null);

            if (meta != null)
            {
                IMethod method = meta.GetMethod(methodId);

                if (method == null)
                {
                    Debug.Check(false, string.Format("Method of {0}::{1} is not registered!\n", agentClassName, methodName));
                }
                else
                {
                    method = (IMethod)(method.Clone());

                    string paramsStr = valueStr.Substring(pBeginP);
                    Debug.Check(paramsStr[0] == '(');

                    List <string> paramsTokens = new List <string>();
                    int           len          = paramsStr.Length;
                    Debug.Check(paramsStr[len - 1] == ')');

                    string text = paramsStr.Substring(1, len - 2);
                    paramsTokens = ParseForParams(text);

                    method.Load(agentIntanceName, paramsTokens.ToArray());
                }

                return(method);
            }

            return(null);
        }