コード例 #1
0
ファイル: Process.cs プロジェクト: Zinterax/meddle
        public void HandleProcessLoaded()
        {
            // Actually create the _targets
            foreach (object targetClass in _targetsToLoad)
            {
                try
                {
                    // Initialize the target
                    Target newTarget = new Target(targetClass, _pyBoss, this);

                    try
                    {
                        newTarget.Initialize();

                        if (_targets.ContainsKey(newTarget.PyTarget))
                            Console.WriteLine(string.Format("WARNING: Constructor of python class 'Target' {0} attempted to add target handler '{1}' more than once.", targetClass.ToString(), Target.GetName(newTarget.PyTarget)));
                        else
                        {
                            _targets.Add(newTarget.PyTarget, newTarget);

                            try
                            {
                                newTarget.PyTarget.on_attached();
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(string.Format("ERROR: Python class 'Target' {0} failed to call 'on_attached()':", newTarget.GetName()));
                                Console.WriteLine(e.ToString());
                                return;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(string.Format("ERROR: Constructor of python class 'Target' {0} failed:", newTarget.GetName()));
                        Console.WriteLine(e.ToString());
                        return;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(string.Format("ERROR: Constructor of python class 'Target' '{0}' failed:", targetClass.ToString()));
                    Console.WriteLine(e.ToString());
                    return;
                }
            }

            // Let the Process() class handle the process loaded event
            PyProcess.handle_process_loaded();
        }