示例#1
0
    string CustomEvent(string param)
    {
        param = param.Trim();
        if (string.IsNullOrEmpty(param))
        {
            return("parameters needed");
        }
        string[] ss        = param.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
        string   classname = ss[0];

        ScenarioRTL.EventListener   evt = ScenarioRTL.Asm.CreateEventListenerInstance(classname);
        ScenarioRTL.IO.StatementRaw raw = new ScenarioRTL.IO.StatementRaw();

        if (evt == null)
        {
            return("cannot create statement");
        }

        raw.classname  = classname;
        raw.order      = 0;
        raw.parameters = new ScenarioRTL.IO.ParamRaw(ss.Length - 1);
        for (int i = 1; i < ss.Length; ++i)
        {
            string   paramstr = ss[i];
            string[] nv       = paramstr.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
            if (nv.Length == 2)
            {
                raw.parameters.Set(i - 1, nv[0], nv[1]);
            }
            else
            {
                raw.parameters.Set(i - 1, "null", "0");
            }
        }
        evt.Init(null, raw);
        evt.OnPost += OnCustomEventPost;
        evt.Listen();
        return("[" + classname + "] is listening");
    }
示例#2
0
 void OnCustomEventPost(ScenarioRTL.EventListener evt)
 {
     Debug.LogWarning("[" + evt.classname + "] posted");
 }