Beispiel #1
0
        //[name:p1,p2;name:p1,p2]
        protected List <ITrigger> LoadTrigger(string context, string common)
        {
            if (string.IsNullOrEmpty(context))
            {
                return(null);
            }

            string[] msg = context.Split(';');
            if (msg == null || msg.Length == 0)
            {
                return(null);
            }

            object[] commonParams = null;

            if (common != null)
            {
                string[] comParamString = common.Split(';');
                if (comParamString.Length > 0)
                {
                    commonParams = new object[comParamString.Length];
                    for (int i = 0; i < comParamString.Length; ++i)
                    {
                        if (comParamString[i].Contains(":"))
                        {
                            string[]      dynaParams   = comParamString [i].Split(':');
                            IRuntimeParam runtimeParam = RuntimeParamFactory.S.Create(dynaParams[0]);
                            if (runtimeParam == null)
                            {
                                Log.e("Create Runtime Param Failed:" + dynaParams[0]);
                            }
                            else
                            {
                                if (dynaParams.Length > 1)
                                {
                                    //string[] findParams = dynaParams[1].Split(',');
                                    object[] resultArray = GuideConfigParamProcess.ProcessParam(dynaParams[1], commonParams);
                                    runtimeParam.SetParam(resultArray);
                                }
                            }

                            commonParams[i] = runtimeParam;
                        }
                        else
                        {
                            commonParams[i] = comParamString[i];
                        }
                    }
                }
            }

            List <ITrigger> result = null;

            for (int i = 0; i < msg.Length; ++i)
            {
                if (string.IsNullOrEmpty(msg[i]))
                {
                    continue;
                }
                string[] com = msg[i].Split(':');
                if (com == null || com.Length == 0)
                {
                    continue;
                }

                ITrigger trigger = GuideTriggerFactory.S.Create(com[0]);
                if (trigger == null)
                {
                    Log.e("Create Trigger Failed:" + com[0]);
                    continue;
                }

                if (com.Length > 1)
                {
                    object[] resultArray = GuideConfigParamProcess.ProcessParam(com[1], commonParams);

                    //处理参数
                    trigger.SetParam(resultArray);
                }

                if (result == null)
                {
                    result = new List <ITrigger> ();
                }

                result.Add(trigger);
            }

            return(result);
        }
Beispiel #2
0
        //command format:[c1:p1,p2,p3;c2:p1,p2,p3]
        private List <AbstractGuideCommand> LoadCommands()
        {
            TDGuideStep data = TDGuideStepTable.GetData(m_GuideStepID);

            if (data == null)
            {
                return(null);
            }

            string[] msg = data.command.Split(';');
            if (msg == null || msg.Length == 0)
            {
                return(null);
            }

            object[] commonParams = null;

            if (data.commonParam != null)
            {
                string[] comParamString = data.commonParam.Split(';');
                if (comParamString.Length > 0)
                {
                    commonParams = new object[comParamString.Length];
                    for (int i = 0; i < comParamString.Length; ++i)
                    {
                        if (comParamString[i].Contains(":"))
                        {
                            string[]      dynaParams   = comParamString [i].Split(':');
                            IRuntimeParam runtimeParam = RuntimeParamFactory.S.Create(dynaParams[0]);
                            if (runtimeParam == null)
                            {
                                Log.e("Create RuntimeParam Failed:" + dynaParams[0]);
                            }
                            else
                            {
                                if (dynaParams.Length > 1)
                                {
                                    object[] resultArray = GuideConfigParamProcess.ProcessParam(dynaParams[1], commonParams);
                                    runtimeParam.SetParam(resultArray);
                                }
                            }
                            commonParams[i] = runtimeParam;
                        }
                        else
                        {
                            commonParams[i] = comParamString[i];
                        }
                    }
                }
            }

            List <AbstractGuideCommand> result = null;

            for (int i = 0; i < msg.Length; ++i)
            {
                if (string.IsNullOrEmpty(msg[i]))
                {
                    continue;
                }
                string[] com = msg[i].Split(':');
                if (com == null || com.Length == 0)
                {
                    continue;
                }

                AbstractGuideCommand command = GuideCommandFactory.S.Create(com[0]);
                if (command == null)
                {
                    Log.e("Create Command Failed:" + com [0]);
                    continue;
                }

                if (com.Length > 1)
                {
                    object[] resultArray = GuideConfigParamProcess.ProcessParam(com[1], commonParams);
                    //处理参数
                    command.SetParam(resultArray);
                }

                if (result == null)
                {
                    result = new List <AbstractGuideCommand> ();
                }

                result.Add(command);
            }

            return(result);
        }