예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TemplateWizardContext"/> class.
        /// </summary>
        /// <param name="serviceProvider">The <see cref="IOleServiceProvider">service provider</see> associated with the created context.</param>
        /// <param name="replacements">The <see cref="IDictionary{TKey,TValue}">collection</see> of template replacements for the created context.</param>
        public TemplateWizardContext( IOleServiceProvider serviceProvider, IDictionary<string, string> replacements )
            : base( CreateParentContainer( serviceProvider ) )
        {
            Arg.NotNull( serviceProvider, nameof( serviceProvider ) );
            Arg.NotNull( replacements, nameof( replacements ) );

            // get previous context, if any; expected to be the first item on the stack
            var parent = contextStack.Any() ? contextStack.Peek() : null;

            currentReplacements = replacements;

            if ( parent == null )
            {
                // there is no previous context so make sure to reset values to defaults
                IsInteractive = true;
                sharedState = new Dictionary<string, object>();
            }
            else
            {
                // copy values from the parent context
                IsInteractive = parent.IsInteractive;
                sharedState = parent.sharedState;

                // override any non-reserved replacements that also defined by the parent context (e.g. pass them forward)
                foreach ( var replacement in parent.Replacements )
                {
                    if ( !reserved.Contains( replacement.Key ) )
                        currentReplacements[replacement.Key] = replacement.Value;
                }
            }

            // make this the current context
            contextStack.Push( this );
            ServiceProvider.SetCurrent( this );
        }
예제 #2
0
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            dteObject = (DTE)automationObject;
            serviceProvider = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)this.dteObject;

            IntPtr zero4 = IntPtr.Zero;
            Guid guid = typeof(SComponentModel).GUID;
            serviceProvider.QueryService(ref guid, ref IUnknownGuid, out zero4);
            componentModel = (IComponentModel)GetObjectFromNativeUnknown(zero4);

            replacementsDictionary["$ext_safeprojectname$"] = RootWizard.GlobalDictionary["$ext_safeprojectname$"];
            replacementsDictionary["$ext_projectname$"] = RootWizard.GlobalDictionary["$ext_projectname$"];

            string localDBInstance = "v11.0";
            var localDBInstances = SqlLocalDbApi.GetInstanceNames();
            if (localDBInstances.IndexOf("MSSqlLocalDB") >= 0)
                localDBInstance = "MSSqlLocalDB";
            else if (localDBInstances.IndexOf("v12.0") >= 0)
                localDBInstance = "v12.0";
            else if (localDBInstances.IndexOf("v11.0") >= 0)
                localDBInstance = "v11.0";
            else if (localDBInstances.Count > 0)
                localDBInstance = localDBInstances[0];

            replacementsDictionary["connectionString=\"Data Source=(LocalDb)\\v11.0;"] =
                "connectionString=\"Data Source=(LocalDb)\\" + localDBInstance + ";";

            if (!replacementsDictionary.TryGetValue("$wizarddata$", out wizardData))
                wizardData = null;
        }
        public ReSharperIntegrationBootstrap(IVsShell vsShell, IVsOleServiceProvider vsOleServiceProvider)
        {
            this.vsShell = vsShell;
              this.vsOleServiceProvider = vsOleServiceProvider;

              int fInstalled;
              IsReSharperInstalled = vsShell.IsPackageInstalled(GuidList.ReSharperPkg, out fInstalled) == 0 &&
                             Convert.ToBoolean(fInstalled);
        }
예제 #4
0
        public static IVsHierarchy HierarchyForLogger(IOleServiceProvider provider)
        {
            BaseMock mock = HierarchyFactory.GetInstance();
            mock.AddMethodReturnValues(
                string.Format("{0}.{1}", typeof(IVsHierarchy).FullName, "GetSite"),
                new object[] { 0, provider });

            return mock as IVsHierarchy;
        }
예제 #5
0
 internal VisualStudioDocument(IVsWindowFrame frame, IVsTextLines buffer, IOleServiceProvider docViewService)
 {
     this.textEditorBuffer = buffer;
     this.currentWindowFrame = frame;
     if (GetSource(docViewService))
     {
         LoadDocument();
     }
 }
예제 #6
0
        private static IServiceContainer CreateParentContainer( IOleServiceProvider serviceProvider )
        {
            Contract.Requires( serviceProvider != null );
            Contract.Ensures( Contract.Result<IServiceContainer>() != null );

            var parent = new VisualStudioServiceProvider( serviceProvider );
            parent.AddService( typeof( IComponentModel ), ( c, t ) => c.GetService( typeof( SComponentModel ) ) );
            parent.AddService( typeof( IValidator ), ( c, t ) => new ValidatorAdapter() );
            return parent;
        }
예제 #7
0
 internal EditorFactory(
     SVsServiceProvider vsServiceProvider,
     IVsEditorAdaptersFactoryService vsEditorAdaptersAdapterFactory,
     ITextBufferFactoryService textBufferFactoryService,
     ITextDocumentFactoryService textDocumentFactoryService,
     ITextEditorFactoryService textEditorFactoryService,
     [EditorUtilsImport] IProtectedOperations protectedOperations)
 {
     _vsEditorFactory = new VsEditorFactory();
     _vsServiceProvider = vsServiceProvider;
     _vsEditorAdaptersFactoryService = vsEditorAdaptersAdapterFactory;
     _textBufferFactoryService = textBufferFactoryService;
     _textDocumentFactoryService = textDocumentFactoryService;
     _textEditorFactoryService = textEditorFactoryService;
     _oleServiceProvider = _vsServiceProvider.GetService<IOleServiceProvider, IOleServiceProvider>();
     _protectedOperations = protectedOperations;
 }
예제 #8
0
    public static void Initialise(IVsOleServiceProvider vsServiceProvider, ReSharperApiImplementationCallback callback)
    {
        // TODO: Is the guard strictly necessary?
        // dotCover uses it, but we always seem to get executed immediately
        ReentrancyGuard.Current.ExecuteOrQueue("Register VSIX extension provider",
          () =>
          {
        var jetEnvironment = JetVisualStudioHost.GetOrCreateHost(vsServiceProvider).Environment;
        var catalogue = PartsCatalogueFactory.Create(typeof(Bootstrap).Assembly);
        lifetimeDefinition = Lifetimes.Define(EternalLifetime.Instance, "VsixExtensionProvider");
        jetEnvironment.FullPartCatalogSet.Add(lifetimeDefinition.Lifetime, catalogue);

        var extensionProvider = jetEnvironment.Container.GetComponent<VsixExtensionProvider>();

        callback(new ReSharperApiImplementation(extensionProvider));
          });
    }
예제 #9
0
 /// <summary>
 /// The get item context.
 /// </summary>
 /// <param name="itemid">
 /// The itemid.
 /// </param>
 /// <param name="ppSP">
 /// The pp sp.
 /// </param>
 /// <returns>
 /// The get item context.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int GetItemContext(uint itemid, out IServiceProvider ppSP)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #10
0
 /// <summary>
 /// The set site.
 /// </summary>
 /// <param name="psp">
 /// The psp.
 /// </param>
 /// <returns>
 /// The set site.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int SetSite(IServiceProvider psp)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #11
0
 /// <summary>
 /// The get site.
 /// </summary>
 /// <param name="ppSP">
 /// The pp sp.
 /// </param>
 /// <returns>
 /// The get site.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int GetSite(out IServiceProvider ppSP)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #12
0
 public VSCodeEditor(IOleServiceProvider psp)
   : this()
 {
   services = new ServiceBroker(psp);
   CreateCodeWindow();
 }
        public void RunFinished()
        {
            IOleServiceProvider oleServiceProvider    = this.Dte2 as IOleServiceProvider;
            IVsApplicationConfigurationManager cfgMgr = null;
            IVsHierarchy vsHierarchy = null;

            using (ServiceProvider sp = new ServiceProvider(oleServiceProvider))
            {
                // Get the solution
                IVsSolution sln = sp.GetService(typeof(IVsSolution)) as IVsSolution;
                if (sln == null)
                {
                    return;
                }

                cfgMgr = sp.GetService(typeof(IVsApplicationConfigurationManager)) as IVsApplicationConfigurationManager;
                if (cfgMgr == null)
                {
                    return;
                }

                int result = sln.GetProjectOfUniqueName(this._project.UniqueName, out vsHierarchy);
                if (result != 0 || vsHierarchy == null)
                {
                    return;
                }
            }

            // Return the current application's configuration file by using
            // the IVsApplicationConfiguration APIs. Make sure that the
            // instance that is returned is disposed of correctly in order
            // to clean up any event hooks or docdatas.
            // Note that this interface is aware of source control and text buffers, so it
            // works even if the file is currently open and modified.
            using (IVsApplicationConfiguration appCfg = cfgMgr.GetApplicationConfiguration(vsHierarchy, Microsoft.VisualStudio.VSConstants.VSITEMID_ROOT))
            {
                // Do not do anything unless the file already exists, else we will create an empty one
                if (appCfg != null && appCfg.FileExists())
                {
                    System.Configuration.Configuration cfg = appCfg.LoadConfiguration();
                    if (cfg != null)
                    {
                        WebConfigUtil webConfigUtil = new WebConfigUtil(cfg);

                        // First check whether any work needs to done
                        bool addHttpModule                  = webConfigUtil.DoWeNeedToAddHttpModule();
                        bool addModuleToWebServer           = webConfigUtil.DoWeNeedToAddModuleToWebServer();
                        bool setAspNetCompatiblity          = !webConfigUtil.IsAspNetCompatibilityEnabled();
                        bool setMultipleSiteBindingsEnabled = !webConfigUtil.IsMultipleSiteBindingsEnabled();
                        bool addValidationSection           = webConfigUtil.DoWeNeedToValidateIntegratedModeToWebServer();

                        // Modify the file only if we decided work is required
                        if (addHttpModule || addModuleToWebServer || setAspNetCompatiblity || setMultipleSiteBindingsEnabled || addValidationSection)
                        {
                            string domainServiceModuleName = WebConfigUtil.GetDomainServiceModuleTypeName();

                            // Check the file out from Source Code Control if it exists.
                            appCfg.QueryEditConfiguration();

                            if (addHttpModule)
                            {
                                webConfigUtil.AddHttpModule(domainServiceModuleName);
                            }

                            if (addModuleToWebServer)
                            {
                                webConfigUtil.AddModuleToWebServer(domainServiceModuleName);
                            }

                            if (setAspNetCompatiblity)
                            {
                                webConfigUtil.SetAspNetCompatibilityEnabled(true);
                            }

                            if (setMultipleSiteBindingsEnabled)
                            {
                                webConfigUtil.SetMultipleSiteBindingsEnabled(true);
                            }

                            if (addValidationSection)
                            {
                                webConfigUtil.AddValidateIntegratedModeToWebServer();
                            }

                            cfg.Save();
                        }
                    }
                }
            }
        }
예제 #14
0
 public int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider packageServiceProvider)
 {
     _oleServiceProvider = packageServiceProvider;
     return(VSConstants.S_OK);
 }
 /// <summary>
 /// The open standard editor.
 /// </summary>
 /// <param name="grfOpenStandard">
 /// The grf open standard.
 /// </param>
 /// <param name="pszMkDocument">
 /// The psz mk document.
 /// </param>
 /// <param name="rguidLogicalView">
 /// The rguid logical view.
 /// </param>
 /// <param name="pszOwnerCaption">
 /// The psz owner caption.
 /// </param>
 /// <param name="pHier">
 /// The p hier.
 /// </param>
 /// <param name="itemid">
 /// The itemid.
 /// </param>
 /// <param name="punkDocDataExisting">
 /// The punk doc data existing.
 /// </param>
 /// <param name="psp">
 /// The psp.
 /// </param>
 /// <param name="ppWindowFrame">
 /// The pp window frame.
 /// </param>
 /// <returns>
 /// The open standard editor.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int OpenStandardEditor(
     uint grfOpenStandard, 
     string pszMkDocument, 
     ref Guid rguidLogicalView, 
     string pszOwnerCaption, 
     IVsUIHierarchy pHier, 
     uint itemid, 
     IntPtr punkDocDataExisting, 
     IServiceProvider psp, 
     out IVsWindowFrame ppWindowFrame)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 /// <summary>
 /// The initialize editor instance.
 /// </summary>
 /// <param name="grfIEI">
 /// The grf iei.
 /// </param>
 /// <param name="punkDocView">
 /// The punk doc view.
 /// </param>
 /// <param name="punkDocData">
 /// The punk doc data.
 /// </param>
 /// <param name="pszMkDocument">
 /// The psz mk document.
 /// </param>
 /// <param name="rguidEditorType">
 /// The rguid editor type.
 /// </param>
 /// <param name="pszPhysicalView">
 /// The psz physical view.
 /// </param>
 /// <param name="rguidLogicalView">
 /// The rguid logical view.
 /// </param>
 /// <param name="pszOwnerCaption">
 /// The psz owner caption.
 /// </param>
 /// <param name="pszEditorCaption">
 /// The psz editor caption.
 /// </param>
 /// <param name="pHier">
 /// The p hier.
 /// </param>
 /// <param name="itemid">
 /// The itemid.
 /// </param>
 /// <param name="punkDocDataExisting">
 /// The punk doc data existing.
 /// </param>
 /// <param name="pSPHierContext">
 /// The p sp hier context.
 /// </param>
 /// <param name="rguidCmdUI">
 /// The rguid cmd ui.
 /// </param>
 /// <param name="ppWindowFrame">
 /// The pp window frame.
 /// </param>
 /// <returns>
 /// The initialize editor instance.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int InitializeEditorInstance(
     uint grfIEI, 
     IntPtr punkDocView, 
     IntPtr punkDocData, 
     string pszMkDocument, 
     ref Guid rguidEditorType, 
     string pszPhysicalView, 
     ref Guid rguidLogicalView, 
     string pszOwnerCaption, 
     string pszEditorCaption, 
     IVsUIHierarchy pHier, 
     uint itemid, 
     IntPtr punkDocDataExisting, 
     IServiceProvider pSPHierContext, 
     ref Guid rguidCmdUI, 
     out IVsWindowFrame ppWindowFrame)
 {
     throw new Exception("The method or operation is not implemented.");
 }
        /// <summary>
        /// The open document via project.
        /// </summary>
        /// <param name="pszMkDocument">
        /// The psz mk document.
        /// </param>
        /// <param name="rguidLogicalView">
        /// The rguid logical view.
        /// </param>
        /// <param name="ppSP">
        /// The pp sp.
        /// </param>
        /// <param name="ppHier">
        /// The pp hier.
        /// </param>
        /// <param name="pitemid">
        /// The pitemid.
        /// </param>
        /// <param name="ppWindowFrame">
        /// The pp window frame.
        /// </param>
        /// <returns>
        /// The open document via project.
        /// </returns>
        public int OpenDocumentViaProject(
            string pszMkDocument, ref Guid rguidLogicalView, out IServiceProvider ppSP, out IVsUIHierarchy ppHier, out uint pitemid, out IVsWindowFrame ppWindowFrame)
        {
            ppSP = null;
            ppHier = null;
            pitemid = 0;

            if (this._documents.ContainsKey(pszMkDocument))
            {
                ppWindowFrame = this._documents[pszMkDocument];
                return VSConstants.S_OK;
            }
            else
            {
                ppWindowFrame = null;
                return VSConstants.E_INVALIDARG;
            }
        }
 int IVsHierarchy.SetSite(IServiceProvider psp)
 {
     throw new System.NotImplementedException();
 }
 int IVsHierarchy.GetSite(out IServiceProvider ppSP)
 {
     throw new System.NotImplementedException();
 }
예제 #20
0
 // --- IVsEditorFactory implementation
 public int SetSite(IOleServiceProvider serviceProvider)
 {
     _serviceProvider = new ServiceProvider(serviceProvider);
     return VSConstants.S_OK;
 }
예제 #21
0
        private bool GetSource(IOleServiceProvider docViewService)
        {
            Guid languageServiceGuid;
            this.textEditorBuffer.GetLanguageServiceID(out languageServiceGuid);
            if (languageServiceGuid != VisualStudioDocument.xmlLanguageServiceGuid)
            {
                return false;
            }

            //IOleServiceProvider docViewService = (IOleServiceProvider)docViewServiceObject;
            IntPtr ptr;
            Guid guid = VisualStudioDocument.xmlLanguageServiceGuid;
            Guid iid = typeof(IVsLanguageInfo).GUID;
            if (!ErrorHandler.Succeeded(docViewService.QueryService(ref guid, ref iid, out ptr)))
            {
                return false;
            }

            this.currentDocumentLanguageInfo = (IVsLanguageInfo)Marshal.GetObjectForIUnknown(ptr);
            Marshal.Release(ptr);

            LanguageService langsvc = this.currentDocumentLanguageInfo as LanguageService;
            this.currentSource = langsvc.GetSource(this.textEditorBuffer);
            return true;
        }
예제 #22
0
 /// <summary>
 /// Used for initialization of the editor in the environment
 /// </summary>
 /// <param name="psp">pointer to the service provider. Can be used to obtain instances of other interfaces
 /// </param>
 /// <returns></returns>
 public int SetSite(IServiceProvider psp)
 {
     vsServiceProvider = new ServiceProvider(psp);
     return VSConstants.S_OK;
 }
예제 #23
0
 public virtual int SetSite(IOleServiceProvider psp)
 {
     _serviceProvider = new ServiceProvider(psp);
     return VSConstants.S_OK;
 }
예제 #24
0
 public IVsCodeWindow CreateVsCodeWindowAdapter(Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// The is document in a project.
 /// </summary>
 /// <param name="pszMkDocument">
 /// The psz mk document.
 /// </param>
 /// <param name="ppUIH">
 /// The pp uih.
 /// </param>
 /// <param name="pitemid">
 /// The pitemid.
 /// </param>
 /// <param name="ppSP">
 /// The pp sp.
 /// </param>
 /// <param name="pDocInProj">
 /// The p doc in proj.
 /// </param>
 /// <returns>
 /// The is document in a project.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int IsDocumentInAProject(string pszMkDocument, out IVsUIHierarchy ppUIH, out uint pitemid, out IServiceProvider ppSP, out int pDocInProj)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 public IronPythonEngineProvider(IOleServiceProvider serviceProvider)
 {
     if (null != serviceProvider)
     {
         this.serviceProvider = new ServiceProvider(serviceProvider);
     }
 }
 /// <summary>
 /// The open document via project with specific.
 /// </summary>
 /// <param name="pszMkDocument">
 /// The psz mk document.
 /// </param>
 /// <param name="grfEditorFlags">
 /// The grf editor flags.
 /// </param>
 /// <param name="rguidEditorType">
 /// The rguid editor type.
 /// </param>
 /// <param name="pszPhysicalView">
 /// The psz physical view.
 /// </param>
 /// <param name="rguidLogicalView">
 /// The rguid logical view.
 /// </param>
 /// <param name="ppSP">
 /// The pp sp.
 /// </param>
 /// <param name="ppHier">
 /// The pp hier.
 /// </param>
 /// <param name="pitemid">
 /// The pitemid.
 /// </param>
 /// <param name="ppWindowFrame">
 /// The pp window frame.
 /// </param>
 /// <returns>
 /// The open document via project with specific.
 /// </returns>
 /// <exception cref="Exception">
 /// </exception>
 public int OpenDocumentViaProjectWithSpecific(
     string pszMkDocument, 
     uint grfEditorFlags, 
     ref Guid rguidEditorType, 
     string pszPhysicalView, 
     ref Guid rguidLogicalView, 
     out IServiceProvider ppSP, 
     out IVsUIHierarchy ppHier, 
     out uint pitemid, 
     out IVsWindowFrame ppWindowFrame)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 public ConvertToOleServiceProvider(Microsoft.VisualStudio.OLE.Interop.IServiceProvider provider)
 {
     _provider = provider;
 }
예제 #29
0
 public int SetSite(IOleServiceProvider psp)
 {
     _site = psp;
     return VSConstants.S_OK;
 }
예제 #30
0
			public WrapSP(IServiceProvider_COM inner)
			{
				myInnerSP = inner;
			}
예제 #31
0
 int IVsProjectFactory.SetSite(IOleServiceProvider psp)
 {
     return NativeMethods.S_OK;
 }
 private static IPythonEngineProvider CreateEngineProvider(IOleServiceProvider provider)
 {
     if (null == engineProviderCtr)
     {
         Assembly asm = typeof(PythonConsolePackage).Assembly;
         Type engineProviderType = asm.GetType("Microsoft.Samples.VisualStudio.IronPythonConsole.IronPythonEngineProvider", true);
         engineProviderCtr = engineProviderType.GetConstructor(new Type[] { typeof(IOleServiceProvider) });
     }
     object obj = engineProviderCtr.Invoke(new object[] { provider });
     Assert.IsNotNull(obj);
     return (IPythonEngineProvider)obj;
 }
 int IVsEditorFactory.SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp)
 {
     _oleServiceProvider = psp;
     return VSConstants.S_OK;
 }
예제 #34
0
        public override int SetSite(IOleServiceProvider psp)
        {
            _serviceProvider = new ServiceProvider(psp);

            return(base.SetSite(psp));
        }