public override object EditValue( ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (provider != null) { IWindowsFormsEditorService service1 = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); ITypeDiscoveryService service2 = (ITypeDiscoveryService)provider.GetService(typeof(ITypeDiscoveryService)); IDesignerHost service3 = (IDesignerHost)provider.GetService(typeof(IDesignerHost)); IComponentChangeService service4 = (IComponentChangeService)provider.GetService(typeof(IComponentChangeService)); if (service1 == null) { return(value); } if (this.screenTipUI == null) { this.screenTipUI = new ScreenTipUI(this); } this.screenTipUI.Initialize(service1, service2, service3, service4, value); service1.DropDownControl((Control)this.screenTipUI); if (this.screenTipUI.Value != null) { value = this.screenTipUI.Value; } this.screenTipUI.End(); } return(value); }
private static VstsClient CreateVstsClient(string instanceName, System.IServiceProvider ctx) { var client = ctx.GetService <IHttpClient>(); var logger = ctx.GetService <ILogger <VstsClient> >(); return(new VstsClient(instanceName, client, logger)); }
/// <summary> /// Gets the current IWpfTextView that is the active document. /// </summary> /// <returns></returns> public static IWpfTextView GetActiveTextView(System.IServiceProvider serviceProvider) { var monitorSelection = (IVsMonitorSelection)serviceProvider.GetService(typeof(SVsShellMonitorSelection)); if (monitorSelection == null) { return(null); } if (ErrorHandler.Failed(monitorSelection.GetCurrentElementValue((uint)VSConstants.VSSELELEMID.SEID_DocumentFrame, out var curDocument))) { // TODO: Report error return(null); } if (!(curDocument is IVsWindowFrame frame)) { // TODO: Report error return(null); } if (ErrorHandler.Failed(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out var docView))) { // TODO: Report error return(null); } #if DEV11_OR_LATER if (docView is IVsDifferenceCodeWindow diffWindow && diffWindow.DifferenceViewer != null) { switch (diffWindow.DifferenceViewer.ActiveViewType) { case VisualStudio.Text.Differencing.DifferenceViewType.InlineView: return(diffWindow.DifferenceViewer.InlineView); case VisualStudio.Text.Differencing.DifferenceViewType.LeftView: return(diffWindow.DifferenceViewer.LeftView); case VisualStudio.Text.Differencing.DifferenceViewType.RightView: return(diffWindow.DifferenceViewer.RightView); default: return(null); } } #endif if (docView is IVsCodeWindow window) { if (ErrorHandler.Failed(window.GetPrimaryView(out var textView))) { // TODO: Report error return(null); } var model = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); var adapterFactory = model.GetService <IVsEditorAdaptersFactoryService>(); var wpfTextView = adapterFactory.GetWpfTextView(textView); return(wpfTextView); } return(null); }
/// <devdoc> /// Override to GetService so we can route requests /// to the package's service provider. /// </devdoc> protected override object GetService(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } if (_provider != null) { if (serviceType.IsEquivalentTo(typeof(AmbientProperties))) { if (_uis == null) { _uis = (IUIService)_provider.GetService(typeof(IUIService)); } if (_ambientProperties == null) { _ambientProperties = new AmbientProperties(); } if (_uis != null) { // update the _ambientProperties in case the styles have changed // since last time. _ambientProperties.Font = (Font)_uis.Styles["DialogFont"]; } return(_ambientProperties); } object service = _provider.GetService(serviceType); if (service != null) { return(service); } } return(base.GetService(serviceType)); }
// this should be removed in a future release internal static IRemoteStorage GetStorage(System.IServiceProvider provider) { var logger = provider.GetService <ILogger <Hosting.DownlinkBuilder> >(); logger?.LogDebug("Running service factory for IRemoteStorage"); var config = provider.GetService <IConfiguration>(); var backend = config.GetValue("Storage", string.Empty).ToLower().Trim(); var providers = provider.GetServices <IRemoteStorage>(); return(providers.GetStorageFor(backend)); }
public void Close() { var rdt = (IVsRunningDocumentTable)_serviceProvider.GetService(typeof(SVsRunningDocumentTable)); rdt.UnlockDocument(0, ((MockVsTextLines)GetBuffer())._docCookie); var disposable = _classifier as IDisposable; if (disposable != null) { disposable.Dispose(); } _view.Close(); }
public IMessageHandler GetHandler(MessageType messageType) { if (_typeStore.TryGetValue(messageType, out System.Type handlerType)) { return(_serviceProvider.GetService(handlerType) as IMessageHandler); } if (_typeStore.TryGetValue(MessageType.Unknwon, out System.Type defaultHandlerType)) { return(_serviceProvider.GetService(defaultHandlerType) as IMessageHandler); } return(null); }
public void TestIfLeadProcessedInRuleCall() { var Rule = _ruleServiceProvider.GetService <IRule>(); const string expectedMessage = "Lead was processed"; string actualMessage = ""; // Mock the ProcessLead function to update the message _rule.Setup(c => c.ConstraintMet(It.IsAny <ILeadEntityImmutable>())).Callback(() => { actualMessage = expectedMessage; }); Rule.ConstraintMet(_leadEntity.Object); Assert.AreEqual(expectedMessage, actualMessage); }
internal static IResponseHandler GetResponseHandler(System.IServiceProvider provider) { var config = provider.GetService <IConfiguration>(); var proxying = config.GetValue <bool>("ProxyRemoteFiles", false); if (proxying) { return(provider.GetService <ProxyingResponseHandler>()); } else { return(provider.GetService <RedirectingResponseHandler>()); } }
public override object EditValue( ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (provider != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService) provider.GetService(typeof (IWindowsFormsEditorService)); if (service == null) return value; if (this.chordKeysUI == null) this.chordKeysUI = new ChordKeysUI(this); this.chordKeysUI.Start(service, value); service.DropDownControl((Control) this.chordKeysUI); if (this.chordKeysUI.Value != null) { string chordKeys = (this.chordKeysUI.Value as Chord).ChordKeys; value = this.chordKeysUI.Value; } else if (value is Chord) (value as Chord).Keys = ""; this.chordKeysUI.End(); } return value; }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { var svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; if ((value is string || value == null) && svc != null) { value = value ?? string.Empty; // Preselect old entry. _dialog.SelectedAtributeName = (string)value; // Restrict selection. //var giContext = context as GridItem; //TODO check if we DO need this //if (giContext == null || // giContext.Parent == null || // giContext.Parent.Parent == null || // giContext.Parent.Parent.Parent == null || // giContext.Parent.Parent.Parent.Value == null) //{ // MessageBox.Show("Cannot edit heres.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); // return value; //} if (svc.ShowDialog(_dialog) == DialogResult.OK) { return(_dialog.SelectedAtributeName); } } return(base.EditValue(context, provider, value)); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { //从当前对象中获取按钮控件对象 SVPageWidget page = context.Instance as SVPageWidget; if (page == null) { return(null); } IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVWpfControl textDialog = new SVWpfControl(); textDialog.Width = 200; textDialog.Height = 300; WPFWidgetBackGround edit = new WPFWidgetBackGround(); edit.DataContext = page.Attrib; textDialog.addContent(edit); edSvc.DropDownControl(textDialog); page.refreshPropertyToPanel(); } return(value); }
/// <summary> /// Helper to create an instance from the local registry given a CLSID Guid /// </summary> internal static InterfaceType CreateInstance <InterfaceType>(System.IServiceProvider serviceProvider, Guid clsid) where InterfaceType : class { InterfaceType instance = null; if (clsid != Guid.Empty) { ILocalRegistry localRegistry = serviceProvider.GetService <ILocalRegistry>(); if (localRegistry != null) { IntPtr proxy = IntPtr.Zero; Guid iid = NativeMethods.IID_IUnknown; // This creates an IUnknown ptr to an object with the given CLSID - the problem is that the object is wrapped // in a proxy behind an IntPtr. To get an object we can call from .Net we need to unwrap the proxy and then // manually release the reference to the proxy. // // This method handles failures in creating an object or converting the appropriate type by returning null, // which the surrounding code expects. int hr = localRegistry.CreateInstance(clsid, null, ref iid, NativeMethods.CLSCTX_INPROC_SERVER, out proxy); if (!NativeMethods.Succeeded(hr) || proxy == IntPtr.Zero) { return(null); } instance = Marshal.GetObjectForIUnknown(proxy) as InterfaceType; // We're throwing here on failure because we don't expect this to every happen under any circumstances. hr = Marshal.Release(proxy); Marshal.ThrowExceptionForHR(hr); } } return(instance); }
/// <summary> /// 重载EditValue /// </summary> /// <param Name="context"></param> /// <param Name="provider"></param> /// <param Name="value"></param> /// <returns></returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { SVHeartbeat heart = context.Instance as SVHeartbeat; if (heart == null) { return(value); } IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVWpfControl picDialog = new SVWpfControl(); picDialog.Width = 300; picDialog.Height = 300; SVWPFHeartPic heartPicture = new SVWPFHeartPic(); heartPicture.resultListView.ItemsSource = heart.Attrib.BitMapArray.BitmapArray; picDialog.addContent(heartPicture); edSvc.DropDownControl(picDialog); heart.refreshPropertyToPanel(); heart.RedoUndo.operChanged(); return(value); } return(value); }
internal static void OpenVsWebBrowser(System.IServiceProvider serviceProvider, string url) { serviceProvider.GetUIThread().Invoke(() => { var web = serviceProvider.GetService(typeof(SVsWebBrowsingService)) as IVsWebBrowsingService; if (web == null) { OpenWebBrowser(serviceProvider, url); return; } try { IVsWindowFrame frame; ErrorHandler.ThrowOnFailure(web.Navigate(url, (uint)__VSWBNAVIGATEFLAGS.VSNWB_ForceNew, out frame)); frame.Show(); } catch (Exception ex) when(!ex.IsCriticalException()) { Utilities.ShowMessageBox( serviceProvider, SR.GetString(SR.WebBrowseNavigateError, url, ex.Message), null, OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST ); } }); }
public IdleManager(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _compMgr = new Lazy <IOleComponentManager>(() => (IOleComponentManager)serviceProvider?.GetService(typeof(SOleComponentManager)) ); _compId = new Lazy <uint>(() => { var compMgr = _compMgr.Value; if (compMgr == null) { return(VSConstants.VSCOOKIE_NIL); } uint compId; OLECRINFO[] crInfo = new OLECRINFO[1]; crInfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crInfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime; crInfo[0].grfcadvf = (uint)0; crInfo[0].uIdleTimeInterval = 0; if (ErrorHandler.Failed(compMgr.FRegisterComponent(this, crInfo, out compId))) { return(VSConstants.VSCOOKIE_NIL); } return(compId); }); }
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (context != null && provider != null) { edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { lb = new ListBox(); lb.Items.AddRange(new object[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }); lb.SelectedIndexChanged += new System.EventHandler(lb_SelectedIndexChanged); edSvc.DropDownControl(lb); } return(text); } return(base.EditValue(context, provider, value)); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVWpfControl alignTextDialog = new SVWpfControl(); alignTextDialog.Width = 120; alignTextDialog.Height = 120; SVWPFAlignDialog dialog = new SVWPFAlignDialog(); alignTextDialog.addContent(dialog); dialog.CloseEvent += () => { edSvc.CloseDropDown(); value = dialog.AlignValue; }; edSvc.DropDownControl(alignTextDialog); return(value); } return(value); }
/// <summary> /// 重载EditValue,编辑按钮动作属性的弹出窗口 /// </summary> /// <param Name="context"></param> /// <param Name="provider"></param> /// <param Name="value"></param> /// <returns></returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { SVBtnChoicePage page = value as SVBtnChoicePage; if (page == null) { return(value); } IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVPageSelectWindow win = new SVPageSelectWindow(); if (win.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { page.PageText = win.getPageText(); page.PageID = win.getPageID(); return(page); } } return(value); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { //if( value.GetType() != typeof(Color)) // return value; // Uses the IWindowsFormsEditorService to display a // drop-down UI in the Properties window. IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { ColorEditorControl editor = new ColorEditorControl((Color)value); edSvc.DropDownControl(editor); // Return the value in the appropraite data format. if (value.GetType() == typeof(Color)) { return(editor.color); } //FormSaveFileEditor sfeditor = new FormSaveFileEditor(); //edSvc.ShowDialog(sfeditor); ////if (value.GetType() == typeof(Color)) //// return sfeditor.color; //return sfeditor.filename; } return(value); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVWpfControl colorDialog = new SVWpfControl(); colorDialog.Width = 170; colorDialog.Height = 160 + 200; SVWpfColorDialog dialog = new SVWpfColorDialog(); colorDialog.addContent(dialog); var clr = (System.Drawing.Color)value; dialog.setDataContext(System.Windows.Media.Color.FromArgb(clr.A, clr.R, clr.G, clr.B)); edSvc.DropDownControl(colorDialog); var rgb = dialog.SelectColor; value = System.Drawing.Color.FromArgb(rgb.A, rgb.R, rgb.G, rgb.B); return(value); } return(value); }
/// <summary> /// Use this instead of VsShellUtilities.ShowMessageBox because VSU uses ThreadHelper which /// uses a private interface that can't be mocked AND goes to the global service provider. /// </summary> public static int ShowMessageBox(IServiceProvider serviceProvider, string message, string title, OLEMSGICON icon, OLEMSGBUTTON msgButton, OLEMSGDEFBUTTON defaultButton) { IVsUIShell uiShell = serviceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell; Debug.Assert(uiShell != null, "Could not get the IVsUIShell object from the services exposed by this serviceprovider"); if (uiShell == null) { throw new InvalidOperationException(); } Guid emptyGuid = Guid.Empty; int result = 0; serviceProvider.GetUIThread().Invoke(() => { ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox( 0, ref emptyGuid, title, message, null, 0, msgButton, defaultButton, icon, 0, out result)); }); return(result); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, System.IServiceProvider serviceProvider) { app.UseCors("MyPolicy"); app.UseDefaultFiles(); app.UseStaticFiles(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // todo : removee app.UseMiddleware(typeof(Utils.ErrorHandlingMiddleware)); } else { app.UseMiddleware(typeof(Utils.ErrorHandlingMiddleware)); } var wsOptions = new WebSocketOptions() { KeepAliveInterval = System.TimeSpan.FromSeconds(60), ReceiveBufferSize = 4 * 1024 }; app.UseWebSockets(wsOptions); app.MapWebSocketManager(Configuration["Params:WebSocketPath"], serviceProvider.GetService <WebSocketRouter>()); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute("default", "api/{controller}/{id?}"); }); }
public CurrentEnvironmentCommand(IServiceProvider serviceProvider) : base(null, null, QueryStatus, new CommandID(GuidList.guidPythonToolsCmdSet, (int)PkgCmdIDList.comboIdCurrentEnvironment)) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _envSwitchMgr = serviceProvider.GetPythonToolsService().EnvironmentSwitcherManager; _logger = serviceProvider.GetService(typeof(IPythonToolsLogger)) as IPythonToolsLogger; }
/// <summary> /// Displays the UI for value selection. /// </summary> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { /* * PropertiesUtils.PropertyWrapper pw; * if ((pw = context.PropertyDescriptor as PropertiesUtils.PropertyWrapper) == null) * return value; * * DependencyObject depObj; * DependencyProperty depProp; * pw.GetWpfObjects(out depObj, out depProp); * if (depObj == null || depProp == null) * return value; */ IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { System.Windows.Forms.ColorDialog cd = new System.Windows.Forms.ColorDialog(); if (cd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { System.Windows.Media.SolidColorBrush scb = new System.Windows.Media.SolidColorBrush(); scb.Color = System.Windows.Media.Color.FromArgb( cd.Color.A, cd.Color.R, cd.Color.G, cd.Color.B); return(scb); } } return(value); }
public T Resolve <T>() { var type = typeof(T); var instance = _serviceProvider.GetService <T>(); return(instance); }
// https://stackoverflow.com/questions/45667126/how-to-get-table-name-of-mapped-entity-in-entity-framework-core public void InitializeHashSet(System.IServiceProvider services) { lock (s_lock) { if (s_tables == null) { TGenericRepository bmc = (TGenericRepository) services.GetService(typeof(TRepository)); if (bmc == null) { // throw new System.NullReferenceException(nameof(bmc)); return; } // End if (bmc == null) System.Collections.Generic.HashSet <string> hs = new System.Collections.Generic.HashSet <string>( System.StringComparer.InvariantCultureIgnoreCase ); foreach (string table in bmc.ListTableNames()) { hs.Add(table); } s_tables = hs; } // End if (s_tables == null) } // End lock (s_lock) } // End Sub InitializeHashSet
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { SVLabel svLabel = context.Instance as SVLabel; if (svLabel == null) { return(value); } IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { SVWpfControl textDialog = new SVWpfControl(); textDialog.Width = 200; textDialog.Height = 120; SVWPFLabelTextEdit edit = new SVWPFLabelTextEdit(); edit.textBox.DataContext = value; textDialog.addContent(edit); edSvc.DropDownControl(textDialog); value = edit.textBox.Text; return(value); } return(value); }
public IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget) { var target = new ScriptingOleCommandTarget(textView, (IComponentModel)_serviceProvider.GetService(typeof(SComponentModel))); target.NextCommandTarget = nextTarget; return(target); }
/// <summary> /// Displays the UI for value selection. /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { /*PropertiesUtils.PropertyWrapper pw; * if ((pw = context.PropertyDescriptor as PropertiesUtils.PropertyWrapper) == null) * return value; * * DependencyObject depObj = pw.ControlledObject as DependencyObject; * DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(pw.ControlledProperty); * if (depObj == null || dpd == null) * return value; * DependencyProperty depProp = dpd.DependencyProperty;*/ IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { FreeSCADA.Designer.Dialogs.VariablesDialog dlg; if (value == null) { dlg = new FreeSCADA.Designer.Dialogs.VariablesDialog(true, ""); } else { dlg = new FreeSCADA.Designer.Dialogs.VariablesDialog(true, value.ToString()); } if (dlg.ShowDialog() == DialogResult.OK) { foreach (IChannel ch in dlg.SelectedChannels) { // returns the first channel from selection return(ch.PluginId + "." + ch.Name); } } } return(value); }