コード例 #1
0
        private FieldInfo GetFieldInfo(object obj, string field)
        {
            // Get field info from type
            Type type = obj.GetType();

            // Find field info iteratively
            FieldInfo fieldInfo = null;

            foreach (int one in Enum.GetValues(typeof(BindingFlags)))
            {
                foreach (int two in Enum.GetValues(typeof(BindingFlags)))
                {
                    fieldInfo = type.GetField(field, (BindingFlags)one | (BindingFlags)two);
                    if (fieldInfo != null)
                    {
                        goto next;
                    }
                }
            }

next:

            if (fieldInfo == null)
            {
                Watchdog.Log(GetType().ToString(), string.Format("Field '{0}' not found in {1}", field, obj));
                return(null);
            }
            else
            {
                return(fieldInfo);
            }
        }
コード例 #2
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));
                    }
                }
            }
        }
コード例 #3
0
 public void LogNotCompleteProgress()
 {
     _progress.ForEach((x) =>
     {
         if (!x.IsCompleted)
         {
             Watchdog.Log("ParallelProgressFlow", x.ToString());
         }
     });
 }
コード例 #4
0
        public static void Init(Transform parent = null)
        {
#if DEBUG_CONSOLE
            Watchdog.Init();

            // Create instance
            var go = new GameObject("[DebugConsole]");
            _instance = go.AddComponent <DebugConsole>();
            _instance.transform.parent = parent;
            _instance._Init();
#endif
        }
コード例 #5
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);
     }
 }
コード例 #6
0
        private void _Init()
        {
            // Add build-in components
            componentsList = new List <ConsoleComponent>();
            AddConsoleComponent(new FpsDetector());
            AddConsoleComponent(new MainMenuTrigger());

            AddComponentToMainMenu(new WatchdogViewer());
            AddComponentToMainMenu(new CommandButtonPanel());
            AddComponentToMainMenu(new TimerScaler());

            AddConsoleCommand(new FieldReflectCommand());

            GetMainMenu().SetCurrentComponent <CommandButtonPanel>();

            // Log success info
            Watchdog.Log("DebugConsole", "**Initialized**");
        }
コード例 #7
0
        public override void OnDrawing()
        {
            string watchdogString = Watchdog.ToString(null, _messageTypeFilter);

            GUIHelper.PrintScrollText(watchdogString, GUIHelper.RatioRect(0.16f, DebugConsole.RSpacing, 0.83f, 0.82f),
                                      ref _scrollPosition);

            // Directly draw command input area
            CommandInput.OnDrawing();

            // Draw show exception button
            if (GUI.Button(GUIHelper.RatioRect(0.01f, 0.85f, DebugConsole.BtnRWidth, DebugConsole.BtnRHeight),
                           _messageTypeFilter == null ? "Exception" : "Resume"))
            {
                _messageTypeFilter = _messageTypeFilter == null
                    ? new List <Watchdog.LogMessage.Type>()
                {
                    Watchdog.LogMessage.Type.Exception
                }
                    : null;
            }
        }
コード例 #8
0
        private void DoChangeState(string stateName, object param)
        {
            if (CurrentState != null && CurrentState.StateName == stateName)
            {
                return;
            }

            // Get new state
            var newState = GetStateByName(stateName);

            if (newState == null)
            {
                throw new Exception("fsm: Invalid state name " + stateName);
            }

            if (CurrentState != null)
            {
                // Exit current state
                CurrentState.OnExit();
            }

            PreviousState = CurrentState;
            CurrentState  = newState;

            if (EnableDebug)
            {
                Watchdog.Log(Name,
                             string.Format("Change state from {0} to {1}", PreviousState, CurrentState));
            }

            // Enter new state
            CurrentState.OnEnter(param);

            if (OnStateChanged != null)
            {
                OnStateChanged(PreviousState, CurrentState);
            }
        }