예제 #1
0
        private static bool Browse(Element element, ReflectorFacade reflector)
        {
            if (!EnsureReflectorRunning(reflector))
            {
                return false;
            }

            reflector.Browse(element.AssemblyFile, element.TypeName, element.MemberName);

            return true;
        }
예제 #2
0
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            ReflectorFacade reflector = new ReflectorFacade();

            IDeclaredElement declared =
                context.GetData(
                    JetBrains.ReSharper.Psi.Services.DataConstants.
                        DECLARED_ELEMENT);

            TryBrowseElement(declared, reflector);

            nextExecute();
        }
예제 #3
0
        private static bool EnsureReflectorRunning(ReflectorFacade reflector)
        {
            if (reflector.IsRunning())
            {
                return true;
            }

            string configFile = GetConfigFile();
            string reflectorExe = GetReflectorExe();

            if (!ValidReflectorPath(reflectorExe))
            {
                return false;
            }

            ReflectorRunner runner = new ReflectorRunner(configFile, reflectorExe);
            runner.Run();

            runner.WaitForIdle();

            for (int i = 0; !reflector.IsRunning() && i < RetryCount; i++ )
            {
                if (!reflector.IsRunning())
                {
                    Debug.WriteLine("Reflector still not running at attempt #" + i + ". Sleeping for a second");
                    Thread.Sleep(1000);
                }
                else
                {
                    Debug.WriteLine(string.Format("Launched reflector after {0} retries.", i));
                    return true;
                }
            }

            return reflector.IsRunning();
        }
예제 #4
0
        private static bool TryBrowseElement(IDeclaredElement declared, ReflectorFacade reflector)
        {
            var finder = new ElementFinder();
            Element element = finder.FindElement(declared);

            if (element != Element.NotFound)
            {
                return Browse(element, reflector);
            }

            return false;
        }