Exemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of the <see cref="ProductService"/> class.
 /// </summary>
 /// <param name="hostApplication"></param>
 public ProductService(IHostApplication hostApplication)
 {
     addedProductsCallbackList = new List <IProductServiceCallback>();
     this.hostApplication      = hostApplication;
     //subscribe to host event
     this.hostApplication.ProductAdded += HostApplicationProductAdded;
 }
Exemplo n.º 2
0
        private void RefreshFinder(IHostApplication host)
        {
            var oldDecalarationFinder = DeclarationFinder;

            DeclarationFinder = _declarationFinderFactory.Create(AllDeclarationsFromModuleStates, AllAnnotations, AllUnresolvedMemberDeclarationsFromModulestates, host);
            _declarationFinderFactory.Release(oldDecalarationFinder);
        }
 public DeclarationFinder Create(IReadOnlyList <Declaration> declarations,
                                 IEnumerable <IParseTreeAnnotation> annotations,
                                 IReadOnlyDictionary <QualifiedModuleName, IFailedResolutionStore> failedResolutionStores,
                                 IHostApplication hostApp)
 {
     return(new DeclarationFinder(declarations, annotations, failedResolutionStores, hostApp));
 }
Exemplo n.º 4
0
        public Process CreateProcess(IHostApplication host, ICodeSource src, CompilerService compilerSvc)
        {
            SetGlobalEnvironment(host, src);
            var module = _engine.LoadModuleImage(compilerSvc.CreateModule(src));

            return(InitProcess(host, src, ref module));
        }
Exemplo n.º 5
0
 public TestMethod(string projectName, string moduleName, string methodName, IHostApplication hostApp)
 {
     _projectName = projectName;
     _moduleName  = moduleName;
     _methodName  = methodName;
     _hostApp     = hostApp;
 }
Exemplo n.º 6
0
        public TextEditorControl(IHostApplication hostApplication)
        {
            Stopwatch launchWatch = new Stopwatch();
            launchWatch.Start();

            if (null != TextEditorControl.hostApplication)
                throw new InvalidOperationException("'TextEditorControl' should be a singleton!");
            if (null != textEditorControl)
                throw new InvalidOperationException("'TextEditorControl' should be a singleton!");

            textEditorControl = this;
            TextEditorControl.hostApplication = hostApplication;

            TextEditorControl.dialogProvider = new DialogProvider();
            CoreInterfaceFactory.RegisterInterfaces(hostApplication, dialogProvider);
            textCore = CoreInterfaceFactory.CreateTextEditorCore(OnExecutionStateChanged);

            actionRecorder = new CommandRecorder();
            textCore.SetCommandRecorder(actionRecorder); // Only for human users.

            InitializeComponent();
            InitializeEditor();
            startUpWorker = new StartUpWorker();
            startUpWorker.InitializeStartUpWorker();
            startUpWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OnStartUpWorkerRunWorkerCompleted);
            startUpWorker.RunWorkerAsync();
            EnumerateExtensions();

            this.LayoutUpdated += new EventHandler(OnTextEditorLayoutUpdated);
            launchWatch.Stop();
            Logger.LogPerf("TextEditorControl.ctor", launchWatch.ElapsedMilliseconds + " ms");
        }
Exemplo n.º 7
0
        public ExecutionSession(IHostApplication hostApplication)
        {
            if (null == hostApplication)
                throw new ArgumentNullException("hostApplication");

            this.hostApplication = hostApplication;
        }
Exemplo n.º 8
0
        public WebGlobalContext(IHostApplication host, ICodeSource entryScript)
        {
            var sys = new SystemGlobalContext();

            sys.ApplicationHost = host;
            sys.CodeSource      = entryScript;
            _osGlobal           = new RCIRedirector(sys);
            _osGlobal.PublishProperty("Символы", null);
            _osGlobal.PublishProperty("Chars", null);
            _osGlobal.PublishProperty("ФайловыеПотоки", null);
            _osGlobal.PublishProperty("FileStreams", null);

            _osGlobal.PublishMethod("ОсвободитьОбъект", "FreeObject");
            _osGlobal.PublishMethod("ВыполнитьСборкуМусора", "RunGarbageCollection");
            _osGlobal.PublishMethod("ЗапуститьПриложение", "RunApp");
            _osGlobal.PublishMethod("СоздатьПроцесс", "CreateProcess");
            _osGlobal.PublishMethod("НайтиПроцессПоИдентификатору", "FindProcessById");
            _osGlobal.PublishMethod("НайтиПроцессыПоИмени", "FindProcessesByName");
            _osGlobal.PublishMethod("КраткоеПредставлениеОшибки", "BriefErrorDescription");
            _osGlobal.PublishMethod("КаталогПрограммы", "ProgramDirectory");
            _osGlobal.PublishMethod("ПодробноеПредставлениеОшибки", "DetailErrorDescription");
            _osGlobal.PublishMethod("ТекущаяДата", "CurrentDate");
            _osGlobal.PublishMethod("ТекущаяУниверсальнаяДатаВМиллисекундах", "CurrentUniversalDateInMilliseconds");
            _osGlobal.PublishMethod("ЗначениеЗаполнено", "IsValueFilled");
            _osGlobal.PublishMethod("ЗаполнитьЗначенияСвойств", "FillPropertyValues");
            _osGlobal.PublishMethod("ПолучитьCOMОбъект", "GetCOMObject");
            _osGlobal.PublishMethod("Приостановить", "Sleep");
            _osGlobal.PublishMethod("ПодключитьВнешнююКомпоненту", "AttachAddIn");
            _osGlobal.PublishMethod("ЗагрузитьСценарий", "LoadScript");
            _osGlobal.PublishMethod("ЗагрузитьСценарийИзСтроки", "LoadScriptFromString");
            _osGlobal.PublishMethod("ПодключитьСценарий", "AttachScript");
            _osGlobal.PublishMethod("Сообщить", "Message");

            sys.InitInstance();
        }
Exemplo n.º 9
0
        public Process CreateProcess(IHostApplication host, ModuleImage moduleImage, ICodeSource src)
        {
            SetGlobalEnvironment(host, src);
            var module = _engine.LoadModuleImage(moduleImage);

            return(InitProcess(host, module));
        }
Exemplo n.º 10
0
        public RubberduckParserState(IVBE vbe, IDeclarationFinderFactory declarationFinderFactory)
        {
            if (vbe == null)
            {
                throw new ArgumentNullException(nameof(vbe));
            }
            if (declarationFinderFactory == null)
            {
                throw new ArgumentNullException(nameof(declarationFinderFactory));
            }

            _vbe = vbe;
            _declarationFinderFactory = declarationFinderFactory;

            var values = Enum.GetValues(typeof(ParserState));

            foreach (var value in values)
            {
                States.Add((ParserState)value);
            }

            _hostApp = _vbe.HostApplication();
            AddEventHandlers();
            IsEnabled = true;
            RefreshFinder(_hostApp);
        }
Exemplo n.º 11
0
        private Process InitProcess(IHostApplication host, ICodeSource src, ref LoadedModuleHandle module)
        {
            Initialize();
            var process = new Process(host, module, _engine);

            return(process);
        }
 public ConcurrentlyConstructedDeclarationFinder(
     IReadOnlyList <Declaration> declarations,
     IEnumerable <IParseTreeAnnotation> annotations,
     IReadOnlyDictionary <QualifiedModuleName, IFailedResolutionStore> failedResolutionStores,
     IHostApplication hostApp = null)
     : base(declarations, annotations, failedResolutionStores, hostApp)
 {
 }
Exemplo n.º 13
0
        private Process InitProcess(IHostApplication host, LoadedModule module)
        {
            Initialize();

            var process = new Process(host, module, _engine);

            return(process);
        }
Exemplo n.º 14
0
 internal static void Initialize(IHostApplication host)
 {
     foreach (var item in _libraries)
     {
         item.Value.Dispose();
     }
     _libraries.Clear();
     _host = host;
 }
Exemplo n.º 15
0
        public ExecutionSession(IHostApplication hostApplication)
        {
            if (null == hostApplication)
            {
                throw new ArgumentNullException("hostApplication");
            }

            this.hostApplication = hostApplication;
        }
Exemplo n.º 16
0
        private Process InitProcess(IHostApplication host, ICodeSource src, ref LoadedModuleHandle module)
        {
            Initialize();
            _globalCtx.ApplicationHost = host;
            _globalCtx.CodeSource      = src;
            _globalCtx.InitInstance();
            var process = new Process(host, module, _engine);

            return(process);
        }
Exemplo n.º 17
0
        public static IEnumerable <TestMethod> TestMethods(this VBProject project)
        {
            IHostApplication hostApp = project.VBE.HostApplication();

            return(project.VBComponents
                   .Cast <VBComponent>()
                   .Where(component => component.Type == vbext_ComponentType.vbext_ct_StdModule && component.CodeModule.HasAttribute <TestModuleAttribute>())
                   .Select(component => new { Component = component, Members = component.GetMembers().Where(member => IsTestMethod(member)) })
                   .SelectMany(component => component.Members.Select(method => new TestMethod(project.Name, component.Component.Name, method.Name, hostApp))));
        }
Exemplo n.º 18
0
        public void Init(IHostApplication host)
        {
            if (!(host is IHostExtensionApplication))
            {
                throw new InvalidCastException("Only extension host is supported for this module");
            }

            m_Host          = (IHostExtensionApplication)host;
            m_Host.Connect += OnConnect;
        }
Exemplo n.º 19
0
 public NativeApiComponent(IHostApplication host, NativeApiLibrary library, String typeName, String componentName)
 {
     _host   = host;
     _object = NativeApiProxy.GetClassObject(library.Module, componentName,
                                             (wcode, source, descr, scode) => _host.Echo("ОШИБКА: " + S(source) + " - " + S(descr), Status(wcode)),
                                             (source, message, data) => _host.Echo("СОБЫТИЕ: " + S(source) + " - " + S(message) + " - " + S(data)),
                                             (status) => _host.Echo("СТАТУС: " + S(status))
                                             );
     DefineType(TypeManager.GetTypeByName(typeName));
 }
Exemplo n.º 20
0
        public void Init(IHostApplication host)
        {
            if (!(host is IHostExtensionApplication))
            {
                throw new InvalidCastException("This module is only availabel for extensions");
            }

            m_Host          = (IHostExtensionApplication)host;
            m_Host.Connect += OnConnect;
        }
Exemplo n.º 21
0
        public Process CreateProcess(IHostApplication host, ICodeSource src, CompilerService compilerSvc)
        {
            SetGlobalEnvironment(host, src);
            Initialize();
            _engine.DebugController?.OnMachineReady(_engine.Machine);
            _engine.DebugController?.WaitForDebugEvent(DebugEventType.BeginExecution);
            var module = _engine.LoadModuleImage(compilerSvc.CreateModule(src));

            return(InitProcess(host, ref module));
        }
Exemplo n.º 22
0
        public static void RegisterInterfaces(IHostApplication hostApplication, IDialogProvider dialogProvider)
        {
            if (null != TextEditorCore.HostApplication)
            {
                string message = "'RegisterInterfaces' cannot be called twice!";
                throw new InvalidOperationException(message);
            }

            TextEditorCore.HostApplication = hostApplication;
            TextEditorCore.DialogProvider  = dialogProvider;
        }
Exemplo n.º 23
0
        private void Run(IEnumerable <Declaration> members)
        {
            if (_hostApplication == null)
            {
                _hostApplication = _vbe.HostApplication();
            }

            foreach (var member in members)
            {
                _hostApplication.Run(member);
            }
        }
Exemplo n.º 24
0
        public static IEnumerable <TestMethod> TestMethods(this VBComponent component)
        {
            IHostApplication hostApp = component.VBE.HostApplication();

            if (component.Type == vbext_ComponentType.vbext_ct_StdModule && component.CodeModule.HasAttribute <TestModuleAttribute>())
            {
                return(component.GetMembers().Where(member => IsTestMethod(member))
                       .Select(member => new TestMethod(component.Collection.Parent.Name, component.Name, member.Name, hostApp)));
            }

            return(new List <TestMethod>());
        }
Exemplo n.º 25
0
        private void Run(IEnumerable <QualifiedMemberName> members)
        {
            if (_hostApplication == null)
            {
                _hostApplication = _vbe.HostApplication();
            }

            foreach (var member in members)
            {
                _hostApplication.Run(member);
            }
        }
Exemplo n.º 26
0
        private void Run(IEnumerable<QualifiedMemberName> members)
        {
            if (_hostApplication == null)
            {
                _hostApplication = _vbe.HostApplication();
            }

            foreach (var member in members)
            {
                _hostApplication.Run(member);
            }
        }
Exemplo n.º 27
0
        private void SerialiseTestResults()
        {
            IHostApplication application = TextEditorControl.HostApplication;
            XmlSerializer    serializer  = new XmlSerializer(typeof(List <AutomationResult>));

            string outputFilePath = string.Format("{0}{1}Asserts-{2:yyyy-MM-dd}.xml",
                                                  storageFolder, Path.DirectorySeparatorChar, DateTime.Now);

            Stream     xmlFileStream = new FileStream(outputFilePath, FileMode.Create);
            TextWriter textWriter    = new StreamWriter(xmlFileStream);

            serializer.Serialize(textWriter, testResults);
            textWriter.Close();
        }
Exemplo n.º 28
0
        public Process CreateProcess(IHostApplication host, ICodeSource src, CompilerService compilerSvc)
        {
            SetGlobalEnvironment(host, src);
            Initialize();
            if (_engine.DebugController != null)
            {
                _engine.DebugController.Init();
                _engine.DebugController.AttachToThread(_engine.Machine);
                _engine.DebugController.Wait();
            }
            var module = _engine.LoadModuleImage(compilerSvc.Compile(src));

            return(InitProcess(host, module));
        }
Exemplo n.º 29
0
        public static IMessage CreateMessage(this IHostApplication host)
        {
            Guard.ThrowIfNull("host", host);

            var    msgType = typeof(IMessage);
            var    iid     = msgType.GUID;
            IntPtr ptr     = IntPtr.Zero;

            var result = host.CreateInstance(ref iid, ref iid, ref ptr);

            if (TResult.Succeeded(result))
            {
                return((IMessage)Marshal.GetTypedObjectForIUnknown(ptr, msgType));
            }

            return(null);
        }
Exemplo n.º 30
0
        private void Run(IEnumerable <Declaration> members)
        {
            if (_hostApplication == null)
            {
                _hostApplication = _vbe.HostApplication();
            }

            foreach (var member in members)
            {
                try
                {
                    _hostApplication.Run(member);
                }
                catch (COMException ex)
                {
                    Logger.Error(ex, "Unexpected COM exception while running tests.", member?.QualifiedName);
                }
            }
        }
Exemplo n.º 31
0
        public RubberduckParserState(IVBE vbe, IProjectsRepository projectRepository, IDeclarationFinderFactory declarationFinderFactory, IVbeEvents vbeEvents)
        {
            _vbe = vbe ?? throw new ArgumentNullException(nameof(vbe));
            _projectRepository        = projectRepository ?? throw new ArgumentException(nameof(projectRepository));
            _declarationFinderFactory = declarationFinderFactory ?? throw new ArgumentNullException(nameof(declarationFinderFactory));
            _vbeEvents = vbeEvents ?? throw new ArgumentNullException(nameof(vbeEvents));

            var values = Enum.GetValues(typeof(ParserState));

            foreach (var value in values)
            {
                States.Add((ParserState)value);
            }

            _hostApp = _vbe.HostApplication();
            AddEventHandlers();
            IsEnabled = true;
            RefreshFinder(_hostApp);
        }
Exemplo n.º 32
0
        public ParseCoordinator(
            IVBE vbe,
            RubberduckParserState state,
            IAttributeParser attributeParser,
            Func <IVBAPreprocessor> preprocessorFactory,
            IEnumerable <ICustomDeclarationLoader> customDeclarationLoaders,
            bool isTestScope = false,
            string serializedDeclarationsPath = null)
        {
            _vbe                        = vbe;
            _state                      = state;
            _attributeParser            = attributeParser;
            _preprocessorFactory        = preprocessorFactory;
            _customDeclarationLoaders   = customDeclarationLoaders;
            _isTestScope                = isTestScope;
            _serializedDeclarationsPath = serializedDeclarationsPath
                                          ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Rubberduck", "declarations");
            _hostApp = _vbe.HostApplication();

            state.ParseRequest += ReparseRequested;
        }
Exemplo n.º 33
0
        public Process CreateProcess(Stream sourceStream, IHostApplication host)
        {
            var appDump         = DeserializeAppDump(sourceStream);
            var engine          = new HostedScriptEngine();
            var src             = new BinaryCodeSource();
            var templateStorage = new TemplateStorage(new StandaloneTemplateFactory());

            engine.SetGlobalEnvironment(host, src);
            engine.InitializationCallback = (e, env) =>
            {
                e.Environment.InjectObject(templateStorage);
                GlobalsManager.RegisterInstance(templateStorage);
            };
            engine.Initialize();

            LoadResources(templateStorage, appDump.Resources);
            LoadScripts(engine, appDump.Scripts);

            var process = engine.CreateProcess(host, appDump.Scripts[0].Image, src);

            return(process);
        }
Exemplo n.º 34
0
        public static void RegisterInterfaces(IHostApplication hostApplication, IDialogProvider dialogProvider)
        {
            if (null != TextEditorCore.HostApplication)
            {
                string message = "'RegisterInterfaces' cannot be called twice!";
                throw new InvalidOperationException(message);
            }

            TextEditorCore.HostApplication = hostApplication;
            TextEditorCore.DialogProvider = dialogProvider;
        }
Exemplo n.º 35
0
 internal Process(IHostApplication host, LoadedModuleHandle src, ScriptingEngine runtime)
 {
     _host = host;
     _engine = runtime;
     _module = src;
 }
Exemplo n.º 36
0
 public Process CreateProcess(IHostApplication host, ICodeSource src)
 {
     return CreateProcess(host, src, GetCompilerService());
 }
Exemplo n.º 37
0
 public Process CreateProcess(IHostApplication host, ICodeSource src, CompilerService compilerSvc)
 {
     SetGlobalEnvironment(host, src);
     var module = _engine.LoadModuleImage(compilerSvc.CreateModule(src));
     return InitProcess(host, src, ref module);
 }
Exemplo n.º 38
0
 public Process CreateProcess(IHostApplication host, ScriptModuleHandle moduleHandle, ICodeSource src)
 {
     SetGlobalEnvironment(host, src);
     var module = _engine.LoadModuleImage(moduleHandle);
     return InitProcess(host, src, ref module);
 }
Exemplo n.º 39
0
 private Process InitProcess(IHostApplication host, ICodeSource src, ref LoadedModuleHandle module)
 {
     Initialize();
     var process = new Process(host, module, _engine);
     return process;
 }
Exemplo n.º 40
0
 private void SetGlobalEnvironment(IHostApplication host, ICodeSource src)
 {
     _globalCtx.ApplicationHost = host;
     _globalCtx.CodeSource = src;
     _globalCtx.InitInstance();
 }