コード例 #1
0
        private void Callback(List <string> pars)
        {
            if (finder == null)
            {
                Watchdog.LogError(GetType().ToString(), "Finder has not been assigned!");
            }
            else
            {
                if (pars == null || pars.Count != 2)
                {
                    Watchdog.LogError(GetType().ToString(), "Parameter count incorrect");
                }
                else
                {
                    Queue <string> fieldQueue = new Queue <string>(pars[0].Split('.').ToList());

                    // First object supported by finder
                    string firstField = fieldQueue.Dequeue();
                    object curObj     = finder.Find(firstField);

                    if (curObj == null)
                    {
                        Watchdog.LogError(GetType().ToString(), string.Format("{0} doesn't implemented in finder", firstField));
                    }
                    else
                    {
                        // Support dot hierarchy
                        FieldInfo fieldInfo = null;


                        // Parse sub-obj iteratively
                        while (fieldQueue.Count > 0)
                        {
                            fieldInfo = GetFieldInfo(curObj, fieldQueue.Dequeue());
                            if (fieldInfo == null)
                            {
                                return;
                            }

                            curObj = fieldInfo.GetValue(curObj);
                        }

                        // Display the last object
                        fieldInfo = GetFieldInfo(curObj, pars[1]);
                        if (fieldInfo == null)
                        {
                            return;
                        }

                        // Display the field name, value, and attributes.
                        Watchdog.Log(GetType().ToString(), string.Format("{0} = \"{1}\"; attributes: {2}",
                                                                         fieldInfo.Name, fieldInfo.GetValue(curObj), fieldInfo.Attributes));
                    }
                }
            }
        }
コード例 #2
0
ファイル: CommandInput.cs プロジェクト: 243107645/JenkinsTest
 public T GetCommand <T>(string id) where T : ConsoleConmand
 {
     if (!_commandDic.ContainsKey(id))
     {
         Watchdog.LogError(ComponentName(), "GetCommand '" + id + "' not found");
         return(null);
     }
     else
     {
         return(_commandDic[id] as T);
     }
 }