private void CreateServices(List <dynamic> configs) { foreach (var serviceConfig in configs) { ServiceBase service; try { ServiceCreationInfo info = new ServiceCreationInfo(serviceConfig, mServiceManager, mDeviceManager); service = ServiceFactory.CreateService(info); mServiceManager.AddService(service); } catch (Exception e) { Log.Error("Failed creating service for node: " + serviceConfig.Name); if (e.InnerException != null) { Log.Error("Inner Exception: {0}\nCallstack:\n{1}", e.InnerException.Message, e.InnerException.StackTrace); } else { Log.Error("Exception: {0}\nCallstack:\n{1}", e.Message, e.StackTrace); } continue; } Log.Info("Created service: {0} of type: {1}", service.Name, service.GetType().ToString()); } }
public void OdbcDriverCheck(string version, int lcid, bool expected) { var coreShell = Substitute.For <ICoreShell>(); var driverPath = @"c:\windows\system32\driver.dll"; var sm = new ServiceManager(); coreShell.Services.Returns(sm); var fs = Substitute.For <IFileSystem>(); fs.FileExists(Arg.Any <string>()).Returns(true); fs.GetFileVersion(driverPath).Returns(new Version(version)); sm.AddService(fs); var registry = Substitute.For <IRegistry>(); sm.AddService(registry); var odbc13Key = Substitute.For <IRegistryKey>(); odbc13Key.GetValue("Driver").Returns(driverPath); var hlkm = Substitute.For <IRegistryKey>(); hlkm.OpenSubKey(@"SOFTWARE\ODBC\ODBCINST.INI\ODBC Driver 13 for SQL Server").Returns(odbc13Key); registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).Returns(hlkm); var app = Substitute.For <IApplication>(); app.LocaleId.Returns(lcid); sm.AddService(app); var ui = Substitute.For <IUIService>(); sm.AddService(ui); ui.When(x => x.ShowErrorMessage(Arg.Any <string>())).Do(x => { var arg = x.Args()[0] as string; arg.Should().Contain(CultureInfo.GetCultureInfo(lcid).Name); }); var process = Substitute.For <IProcessServices>(); sm.AddService(process); process.When(x => x.Start(Arg.Any <string>())).Do(x => { var arg = x.Args()[0] as string; arg.Should().Contain(CultureInfo.GetCultureInfo(lcid).Name); }); var service = new DbConnectionService(coreShell); service.CheckSqlOdbcDriverVersion().Should().Be(expected); if (!expected) { ui.Received(1).ShowErrorMessage(Arg.Any <string>()); process.Received(1).Start(Arg.Any <string>()); } }
public void SetUp() { _serviceManager = new ServiceManager(); _settingsService = new FakeSettingsService(); _serviceManager.AddService(_settingsService); _projectService = new FakeProjectService(); _serviceManager.AddService(_projectService); }
public void SetUp() { _serviceManager = new ServiceManager(); _settingsService = new FakeSettingsService(); _serviceManager.AddService(_settingsService); #if NUNIT_ENGINE _projectService = new FakeProjectService(); _serviceManager.AddService(_projectService); #endif }
public void LocalFiles() { var services = new ServiceManager(); services.AddService(new WindowsFileSystem()); services.AddService(Substitute.For <IRInteractiveWorkflowProvider>()); services.AddService(Substitute.For <IImageService>()); var provider = new FilesCompletionProvider(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), services); var entries = provider.GetEntries(null); entries.Should().NotBeEmpty(); entries.Should().Contain(e => e.DisplayText == _testFolderName); }
public ContainedLanguageHandler(ITextBuffer textBuffer) { ServiceManager.AddService <IContainedLanguageHandler>(this, textBuffer); TextBuffer = textBuffer; TextBuffer.Changed += OnTextBufferChanged; }
public ROutliningTagger(REditorDocument document, IEditorShell shell) : base(document.EditorTree.TextBuffer, new ROutlineRegionBuilder(document, shell)) { document.DocumentClosing += OnDocumentClosing; ServiceManager.AddService <ROutliningTagger>(this, document.EditorTree.TextBuffer, shell); }
public ContainedLanguageAdapter(ITextBuffer textBuffer) { Document = ServiceManager.GetService <HtmlEditorDocument>(textBuffer); Document.OnDocumentClosing += OnDocumentClosing; ServiceManager.AddService(this, textBuffer); }
public IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget) { var target = ServiceManager.GetService <IOleCommandTarget>(textView); if (target == null) { var controller = ReplCommandController.Attach(textView, textView.TextBuffer, _shell.Services); var es = _shell.GetService <IApplicationEditorSupport>(); // Wrap controller into OLE command target target = es.TranslateToHostCommandTarget(textView, controller) as IOleCommandTarget; Debug.Assert(target != null); ServiceManager.AddService(target, textView, _shell); // Wrap next OLE target in the chain into ICommandTarget so we can have // chain like: OLE Target -> Shim -> ICommandTarget -> Shim -> Next OLE target var nextCommandTarget = es.TranslateCommandTarget(textView, nextTarget); controller.ChainedController = nextCommandTarget; // We need to listed when R projected buffer is attached and // create R editor document over it. textView.BufferGraph.GraphBuffersChanged += OnGraphBuffersChanged; var pb = textView.TextBuffer as IProjectionBuffer; if (pb != null) { pb.SourceBuffersChanged += OnSourceBuffersChanged; } textView.Closed += TextView_Closed; } return(target); }
public EditorErrorTagger(ITextBuffer textBuffer) { EditorShell.Current.CompositionService.SatisfyImportsOnce(this); _document = REditorDocument.FromTextBuffer(textBuffer); _document.DocumentClosing += OnDocumentClosing; _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted; _document.EditorTree.NodesRemoved += OnNodesRemoved; _errorTags = new ErrorTagCollection(_document.EditorTree); _textBuffer = _document.EditorTree.TextBuffer; _textBuffer.Changed += OnTextBufferChanged; _fireCodeMarkerUponCompletion = true; // Don't push syntax errors to the Error List in transient // documents such as in document attached to a projected buffer // in the R interactive window if (TaskList != null) { var view = _document.GetFirstView(); if (view != null && !view.IsRepl()) { TaskList.AddTaskSource(this); } } TreeValidator validator = TreeValidator.EnsureFromTextBuffer(_textBuffer, _document.EditorTree); validator.Cleared += OnCleared; ResultsQueue = validator.ValidationResults; EditorShell.Current.Idle += OnIdle; ServiceManager.AddService <EditorErrorTagger>(this, textBuffer); }
public bool AddService(IService service) { if (ServiceManager.AddService(service.ServiceKey, service)) { service.ServiceConnector += ServiceConnector; service.ServiceLog += ServiceRuningLog; if (service.IsAutoStart) { try { service.StartService(); } catch (Exception ex) { Logger.Error(true, "", ex); } } Logger.Info(true, String.Format("<{0}>增加服务成功", service.ServiceName)); return(true); } else { Logger.Info(true, String.Format("<{0}>增加服务失败", service.ServiceName)); return(false); } }
public void OnBlockCreated(ITextBuffer editorBuffer, LanguageProjectionBuffer projectionBuffer) { WindowHelpers.WaitFor(delegate { var textView = TextViewConnectionListener.GetFirstViewForBuffer(editorBuffer); if (textView == null) { return(false); } // Add the inner buffer's EditorDocument to the outer buffer before // broken editor code tries to create a new EditorDocument from the // outer buffer. var editorDocument = JSONEditorDocument.FromTextBuffer(projectionBuffer.IProjectionBuffer); ServiceManager.AddService(editorDocument, textView.TextBuffer); editorDocument.Closing += delegate { ServiceManager.RemoveService <JSONEditorDocument>(textView.TextBuffer); }; // JSONIndenter uses TextView.TextBuffer, and therefore operates on the // entire Markdown buffer, breaking everything. I manually force it to // use the inner projection buffer instead. Beware that this breaks its // ViewCaret property, and I can't fix that unless I mock its TextView. var indenter = ServiceManager.GetService <ISmartIndent>(textView); indenter.GetType().GetField("_textBuffer", BindingFlags.Instance | BindingFlags.NonPublic) .SetValue(indenter, projectionBuffer.IProjectionBuffer); return(true); }); }
public TreeValidator(IEditorTree editorTree) { #if DEBUG TraceValidation.Enabled = false; #endif _editorTree = editorTree; _editorTree.NodesRemoved += OnNodesRemoved; _editorTree.UpdateCompleted += OnTreeUpdateCompleted; _editorTree.Closing += OnTreeClose; _syntaxCheckEnabled = IsSyntaxCheckEnabled(_editorTree.TextBuffer); // Advise to settings changed *after* accessing the RSettings, // since accessing the host application (VS) settings object may // cause it fire Changed notification in some cases. REditorSettings.Changed += OnSettingsChanged; // We don't want to start validation right away since it may // interfere with the editor perceived startup performance. StartValidationNextIdle(); ValidationResults = new ConcurrentQueue <IValidationError>(); ServiceManager.AddService <TreeValidator>(this, editorTree.TextBuffer); }
public void AddService() { var mocks = Mock.Mocks.New(); var services = new List <Data.Entities.Service> { new Data.Entities.Service { Key = "Test1" } }; Assert.AreEqual(1, services.Count()); var servicesMock = mocks .NewDbSet <Data.Entities.Service>() .CanAddTo(services); var dbContextMock = mocks .NewDbContext <MirrorDbContext>() .WithDbSet(context => context.Services, servicesMock.Object) .SavedChanges(); var serviceManager = new ServiceManager(dbContextMock.Object); serviceManager.AddService(new Data.Entities.Service { Key = "Test2" }); Assert.AreEqual(2, services.Count()); mocks.VerifyAll(); }
protected ContainedLanguageHandler(ITextBuffer textBuffer, ICoreShell coreShell) { ServiceManager.AddService <IContainedLanguageHandler>(this, textBuffer, coreShell); TextBuffer = textBuffer; TextBuffer.Changed += OnTextBufferChanged; }
private void SetBindingHandlerSettings(InputDeviceTree dev, IOutputMode outputMode, BindingSettings settings) { string group = dev.Properties.Name; var bindingHandler = new BindingHandler(outputMode); var bindingServiceProvider = new ServiceManager(); object pointer = outputMode switch { AbsoluteOutputMode absoluteOutputMode => absoluteOutputMode.Pointer, RelativeOutputMode relativeOutputMode => relativeOutputMode.Pointer, _ => null }; if (pointer is IVirtualMouse virtualMouse) { bindingServiceProvider.AddService <IVirtualMouse>(() => virtualMouse); } var tipbinding = bindingHandler.TipBinding = settings.TipButton?.Construct <IBinding>(); bindingServiceProvider.Inject(tipbinding); bindingHandler.TipActivationPressure = settings.TipActivationPressure; Log.Write(group, $"Tip Binding: [{bindingHandler.TipBinding}]@{bindingHandler.TipActivationPressure}%"); var eraserBinding = bindingHandler.EraserBinding = settings.EraserButton?.Construct <IBinding>(); bindingServiceProvider.Inject(eraserBinding); bindingHandler.EraserActivationPressure = settings.EraserActivationPressure; Log.Write(group, $"Eraser Binding: [{bindingHandler.EraserBinding}]@{bindingHandler.EraserActivationPressure}%"); if (settings.PenButtons != null) { for (int index = 0; index < settings.PenButtons.Count; index++) { var bind = settings.PenButtons[index]?.Construct <IBinding>(); if (!bindingHandler.PenButtonBindings.TryAdd(index, bind)) { bindingHandler.PenButtonBindings[index] = bind; bindingServiceProvider.Inject(bind); } } Log.Write(group, $"Pen Bindings: " + string.Join(", ", bindingHandler.PenButtonBindings)); } if (settings.AuxButtons != null) { for (int index = 0; index < settings.AuxButtons.Count; index++) { var bind = settings.AuxButtons[index]?.Construct <IBinding>(); if (!bindingHandler.AuxButtonBindings.TryAdd(index, bind)) { bindingHandler.AuxButtonBindings[index] = bind; bindingServiceProvider.Inject(bind); } } Log.Write(group, $"Express Key Bindings: " + string.Join(", ", bindingHandler.AuxButtonBindings)); } }
public MdEditorDocument(ITextBuffer textBuffer) { EditorShell.Current.CompositionService.SatisfyImportsOnce(this); this.TextBuffer = textBuffer; ServiceManager.AddService <MdEditorDocument>(this, TextBuffer); }
public SignatureHelpSource(ITextBuffer textBuffer, ICoreShell shell) { _disposeToken = DisposeToken.Create <SignatureHelpSource>(); _textBuffer = textBuffer; _shell = shell; ServiceManager.AddService <SignatureHelpSource>(this, textBuffer, shell); }
public CoreShell(IActionLog log) { ThreadId = Thread.CurrentThread.ManagedThreadId; _serviceManager = new ServiceManager(); _serviceManager .AddService(new MaxLoggingPermissions()) .AddService(log); }
public VsMdEditorDocument(IEditorInstance editorInstance, IProjectionBufferFactoryService projectionBufferFactoryService, IContentTypeRegistryService contentTypeRegistryService) : base(editorInstance.ViewBuffer, projectionBufferFactoryService, contentTypeRegistryService) { _editorInstance = editorInstance; ServiceManager.AddService <VsMdEditorDocument>(this, TextBuffer); }
public BraceHighlighter(ITextView view, ITextBuffer textBuffer, ICoreShell shell) { _textBuffer = textBuffer; _textView = view; _shell = shell; ServiceManager.AddService(this, _textView, shell); }
public override void OnDoCreate(ExtendObject item, params object[] args) { base.OnDoCreate(item, args); ServiceManager.AddService <IWindowManager>(new WindowManager()); OnSelectedItemCommand = RegisterCommand(OnSelectedItem); OnOpenViewsCheckedCommand = RegisterCommand(OnOpenViewsChecked); OnHeroSelectedCommand = RegisterCommand(OnHeroSelected); OnAlbumSelectedCommand = RegisterCommand(OnAlbumSelected); OnApplyTPCommand = RegisterCommand(OnApplyTP); popupView = CreateView <SelectVideoPlayerDialogViewModel>(true); DownLoadManagerView = CreateView <DownloadManagerViewModel>(true); ModifySkinDialogView = CreateView <ModifySkinDialogViewModel>(true); DownloadManager.Info = DownLoadManagerView.Model; //CurrentAlbumProperty.ValueChanged += CurrentAlbumProperty_ValueChanged; AlbumList = new ObservableCollection <Album> { new Wow178Album("http://wow.178.com/list/pvpshipin/index.html") { Name = "pvp视频区" }, new Wow178Album("http://wow.178.com/list/quweishipin/index.html") { Name = "娱乐视频区" }, new Wow178Album("http://wow.178.com/list/ctmsp/index.html") { Name = "大灾变视频区" }, new Wow178Album("http://wow.178.com/list/49616960521.html") { Name = "我叫MT系列" }, new Wow178Album("http://wow.178.com/list/lk/index.html") { Name = "巫妖王视频区" }, new Wow178Album("http://wow.178.com/list/rs/index.html") { Name = "晶红圣殿视频" }, new Wow178Album("http://wow.178.com/list/ghxc/index.html") { Name = "公会宣传视频" }, new Wow178Album("http://wow.178.com/list/cg/index.html") { Name = "官方视频" }, new Wow178Album("http://wow.178.com/list/fanchang/index.html") { Name = "玩家翻唱区" }, }; }
/// <summary> /// Creates contained language host with default settings. /// </summary> /// <param name="document">Markdown editor document</param> /// <param name="textBuffer">Contained language text buffer</param> public MdContainedLanguageHost(IEditorDocument document, ITextBuffer textBuffer) { _textBuffer = textBuffer; _document = document; _document.DocumentClosing += OnDocumentClosing; ServiceManager.AddService <IContainedLanguageHost>(this, textBuffer); }
public static void Add(ServiceDto pService, int[] pSelectedBaseRouteIds) { using (Rbr_Db _db = new Rbr_Db()) { using (Transaction _tx = new Transaction(_db, pService, pSelectedBaseRouteIds)) { ServiceManager.AddService(_db, pService, pSelectedBaseRouteIds); _tx.Commit(); } } }
public RSuggestedActionSource(ITextView textView, ITextBuffer textBuffer, IEnumerable <IRSuggestedActionProvider> suggestedActionProviders) { _textBuffer = textBuffer; _textView = textView; _textView.Caret.PositionChanged += OnCaretPositionChanged; _suggestedActionProviders = suggestedActionProviders; _document = REditorDocument.TryFromTextBuffer(_textBuffer); ServiceManager.AddService(this, _textView); }
public MdEditorDocument(ITextBuffer textBuffer, IProjectionBufferFactoryService projectionBufferFactoryService, IContentTypeRegistryService contentTypeRegistryService, ICoreShell coreShell) { this.TextBuffer = textBuffer; ServiceManager.AddService(this, TextBuffer, coreShell); _projectionBufferManager = new ProjectionBufferManager(textBuffer, projectionBufferFactoryService, contentTypeRegistryService, coreShell, MdProjectionContentTypeDefinition.ContentType, RContentTypeDefinition.ContentType); ContainedLanguageHandler = _rLanguageHandler = new RLanguageHandler(textBuffer, _projectionBufferManager, coreShell); }
public async Task RunTest(Func <ServiceManager, Task> test) { using (var sm = new ServiceManager()) { var fs = Substitute.For <IFileSystem>(); sm.AddService(fs); const string baseName = "analysis.v"; SetupDirectories(fs, new[] { $"{baseName}1", $"{baseName}3" }); var mdc = Substitute.For <IModuleDatabaseCache>(); mdc.CacheFolder.Returns(c => "CacheFolder"); sm.AddService(mdc); await test(sm); fs.Received().DeleteDirectory($"{baseName}1", true); fs.Received().DeleteDirectory($"{baseName}3", true); } }
private MasterServer SetService(SocketConfig socketConfig) { var masterServer = new MasterServer(socketConfig.ServiceID, RawMessageManager, ModuleManager, CacheManager, ControllerComponentManager); _services.TryAdd(socketConfig, masterServer); ServiceManager.AddService(socketConfig.ServiceID, masterServer); masterServer.InitializeModules(); return(masterServer); }
// Use this for initialization void Start() { DontDestroyOnLoad(this); serviceManager = ServiceManager.Instance; if (serviceManager.ContainsService(ServiceType.EventManager)) { Debug.Log("GameManager.Start being called a second time."); } else { EventManager eventManager = new EventManager(); serviceManager.AddService(ServiceType.EventManager, eventManager); GameObject input = (GameObject)Instantiate(inputManager); input.transform.parent = this.transform; serviceManager.AddService(ServiceType.InputManager, input.GetComponent <InputManager>()); GameObject hudObject = (GameObject)Instantiate(hud); hudObject.transform.parent = this.transform; StatsManager statsManager = new StatsManager(); serviceManager.AddService(ServiceType.StatsManager, statsManager); //TODO: the stats manager shouldn't be responsible for initializing the stats statsManager.Initialize(); GameObject collectibles = (GameObject)Instantiate(collectibleFactory); collectibles.transform.parent = this.transform; serviceManager.AddService(ServiceType.CollectibleFactory, collectibles.GetComponent <CollectibleFactory>()); GameObject levels = (GameObject)Instantiate(levelManager); levels.transform.parent = this.transform; LevelManager levelManagerScript = levels.GetComponent <LevelManager>(); serviceManager.AddService(ServiceType.LevelManager, levelManagerScript); InitializeLevels(levelManagerScript); //statsManager.SetWeight(1600f); levelManagerScript.TransitionToLevel(1); } }
public IIntellisenseController TryCreateIntellisenseController(ITextView view, IList <ITextBuffer> subjectBuffers) { var completionController = ServiceManager.GetService <TemplateCompletionController>(view); if (completionController == null) { completionController = new TemplateCompletionController(_pyService, view, subjectBuffers, _completionBroker, _quickInfoBroker, _signatureHelpBroker); ServiceManager.AddService <TemplateCompletionController>(completionController, view); } return(completionController); }
// Use this for initialization void Start() { DontDestroyOnLoad(this); serviceManager = ServiceManager.Instance; if (serviceManager.ContainsService(ServiceType.EventManager)) { Debug.Log("GameManager.Start being called a second time."); } else { EventManager eventManager = new EventManager(); serviceManager.AddService(ServiceType.EventManager, eventManager); GameObject input = (GameObject)Instantiate(inputManager); input.transform.parent = this.transform; serviceManager.AddService(ServiceType.InputManager, input.GetComponent<InputManager>()); GameObject hudObject = (GameObject)Instantiate(hud); hudObject.transform.parent = this.transform; StatsManager statsManager = new StatsManager(); serviceManager.AddService(ServiceType.StatsManager, statsManager); //TODO: the stats manager shouldn't be responsible for initializing the stats statsManager.Initialize(); GameObject collectibles = (GameObject)Instantiate (collectibleFactory); collectibles.transform.parent = this.transform; serviceManager.AddService(ServiceType.CollectibleFactory, collectibles.GetComponent<CollectibleFactory>()); GameObject levels = (GameObject)Instantiate(levelManager); levels.transform.parent = this.transform; LevelManager levelManagerScript = levels.GetComponent<LevelManager>(); serviceManager.AddService(ServiceType.LevelManager, levelManagerScript); InitializeLevels(levelManagerScript); //statsManager.SetWeight(1600f); levelManagerScript.TransitionToLevel(1); } }