Exemple #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;
 }
        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));
 }
        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));
        }
Exemple #5
0
 public TestMethod(string projectName, string moduleName, string methodName, IHostApplication hostApp)
 {
     _projectName = projectName;
     _moduleName  = moduleName;
     _methodName  = methodName;
     _hostApp     = hostApp;
 }
        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");
        }
        public ExecutionSession(IHostApplication hostApplication)
        {
            if (null == hostApplication)
                throw new ArgumentNullException("hostApplication");

            this.hostApplication = hostApplication;
        }
Exemple #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();
        }
        public Process CreateProcess(IHostApplication host, ModuleImage moduleImage, ICodeSource src)
        {
            SetGlobalEnvironment(host, src);
            var module = _engine.LoadModuleImage(moduleImage);

            return(InitProcess(host, module));
        }
        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);
        }
        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)
 {
 }
        private Process InitProcess(IHostApplication host, LoadedModule module)
        {
            Initialize();

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

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

            this.hostApplication = hostApplication;
        }
Exemple #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);
        }
        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))));
        }
Exemple #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;
        }
Exemple #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));
 }
Exemple #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;
        }
        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));
        }
        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;
        }
Exemple #23
0
        private void Run(IEnumerable <Declaration> members)
        {
            if (_hostApplication == null)
            {
                _hostApplication = _vbe.HostApplication();
            }

            foreach (var member in members)
            {
                _hostApplication.Run(member);
            }
        }
        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>());
        }
Exemple #25
0
        private void Run(IEnumerable <QualifiedMemberName> members)
        {
            if (_hostApplication == null)
            {
                _hostApplication = _vbe.HostApplication();
            }

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

            foreach (var member in members)
            {
                _hostApplication.Run(member);
            }
        }
Exemple #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();
        }
        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));
        }
Exemple #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);
        }
Exemple #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);
                }
            }
        }
Exemple #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);
        }
Exemple #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;
        }
        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);
        }
Exemple #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;
        }
Exemple #35
0
 internal Process(IHostApplication host, LoadedModuleHandle src, ScriptingEngine runtime)
 {
     _host = host;
     _engine = runtime;
     _module = src;
 }
 public Process CreateProcess(IHostApplication host, ICodeSource src)
 {
     return CreateProcess(host, src, GetCompilerService());
 }
 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);
 }
 public Process CreateProcess(IHostApplication host, ScriptModuleHandle moduleHandle, ICodeSource src)
 {
     SetGlobalEnvironment(host, src);
     var module = _engine.LoadModuleImage(moduleHandle);
     return InitProcess(host, src, ref module);
 }
 private Process InitProcess(IHostApplication host, ICodeSource src, ref LoadedModuleHandle module)
 {
     Initialize();
     var process = new Process(host, module, _engine);
     return process;
 }
 private void SetGlobalEnvironment(IHostApplication host, ICodeSource src)
 {
     _globalCtx.ApplicationHost = host;
     _globalCtx.CodeSource = src;
     _globalCtx.InitInstance();
 }