Beispiel #1
0
 public int SaveUserOptions(IVsSolutionPersistence pPersistence)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     pPersistence.SavePackageUserOpts(this, SELECTED_WEB_RESOURCES);
     pPersistence.SavePackageUserOpts(this, SELECTED_REPORTS);
     return(VSConstants.S_OK);
 }
        public bool ForceLoadUserSettings(string streamName)
        {
            IVsSolutionPersistence persistence = GetService <IVsSolutionPersistence>(typeof(SVsSolutionPersistence));

            if (persistence == null)
            {
                return(false);
            }

            try
            {
                int hr = persistence.LoadPackageUserOpts(this, streamName);

                return(true);
            }
            catch (Exception ex)
            {
                IAnkhErrorHandler handler = GetService <IAnkhErrorHandler>();

                if (handler != null)
                {
                    handler.OnError(ex);
                }

                return(false);
            }
        }
Beispiel #3
0
        // Called by the shell when a solution is opened and the SUO file is read.
        public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            pPersistence.LoadPackageUserOpts(this, NuGetOptionsStreamKey);
            return(VSConstants.S_OK);
        }
Beispiel #4
0
        public int SaveSolutionProps(IVsHierarchy pHierarchy, IVsSolutionPersistence pPersistence)
        {
            // This function gets called by the shell after QuerySaveSolutionProps returned QSP_HasDirtyProps

            // The package will pass in the key under which it wants to save its properties,
            // and the IDE will call back on WriteSolutionProps

            // The properties will be saved in the Pre-Load section
            // When the solution will be reopened, the IDE will call our package to load them back before the projects in the solution are actually open
            // This could help if the source control package needs to persist information like projects translation tables, that should be read from the suo file
            // and should be available by the time projects are opened and the shell start calling IVsSccEnlistmentPathTranslation functions.
            if (pHierarchy == null)             // Only save the property on the solution itself
            {
                // SavePackageSolutionProps will call WriteSolutionProps with the specified key

                if (CqrsSettings != null)
                {
                    pPersistence.SavePackageSolutionProps(1 /* TRUE */, null, this, CqrsNetSettingsKey);
                }

                // Once we saved our props, the solution is not dirty anymore
                IsDirty = false;
            }

            return(VSConstants.S_OK);
        }
 /// <summary>
 /// Called by the shell when the SUO file is saved. The provider calls the shell back to let it
 /// know which options keys it will use in the suo file.
 /// </summary>
 public int SaveUserOptions(IVsSolutionPersistence pPersistence)
 {
     // The shell will create a stream for the section of interest, and will call back the provider on
     // IVsPersistSolutionProps.WriteUserOptions() to save specific options under the specified key.
     pPersistence.SavePackageUserOpts(this, _strSolutionUserOptionsKey);
     return(VSConstants.S_OK);
 }
Beispiel #6
0
        // Called by the shell when the SUO file is saved. The provider calls the shell back to let it
        // know which options keys it will use in the suo file.
        public int SaveUserOptions(IVsSolutionPersistence pPersistence)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            pPersistence.SavePackageUserOpts(this, NuGetOptionsStreamKey);
            return(VSConstants.S_OK);
        }
        public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
        {
            if ((grfLoadOpts & (uint)__VSLOADUSEROPTS.LUO_OPENEDDSW) != 0)
            {
                return(VSErr.S_OK); // We only know .suo; let's ignore old style projects
            }

            try
            {
                pPersistence.LoadPackageUserOpts(this, SccPendingChangeStream);
                pPersistence.LoadPackageUserOpts(this, SccExcludedStream);
                pPersistence.LoadPackageUserOpts(this, SccTranslateStream);

                return(VSErr.S_OK);
            }
            catch (Exception ex)
            {
                IAnkhErrorHandler handler = GetService <IAnkhErrorHandler>();

                if (handler != null)
                {
                    handler.OnError(ex);
                }

                return(Marshal.GetHRForException(ex));
            }
            finally
            {
                if (Marshal.IsComObject(pPersistence))
                {
                    Marshal.ReleaseComObject(pPersistence); // See Package.cs from MPF for reason
                }
            }
        }
Beispiel #8
0
 private int _SaveUserOptions(IVsSolutionPersistence pPersistence)
 {
     return
         (StorageOptions.SaveBookmarksToOwnFile ?
          VSConstants.S_OK :
          pPersistence.SavePackageUserOpts(this, persistenceKey));
 }
        public int SaveUserOptions([In] IVsSolutionPersistence pPersistence)
        {
            try
            {
                IAnkhSccService scc = GetService <IAnkhSccService>();
                if (scc != null)
                {
                    if (!scc.IsActive)
                    {
                        return(VSErr.S_OK);
                    }

                    pPersistence.SavePackageUserOpts(this, SccPendingChangeStream);
                    pPersistence.SavePackageUserOpts(this, SccExcludedStream);

                    if (scc.IsSolutionManaged)
                    {
                        pPersistence.SavePackageUserOpts(this, SccTranslateStream);
                    }
                }

                return(VSErr.S_OK);
            }
            finally
            {
                if (Marshal.IsComObject(pPersistence))
                {
                    Marshal.ReleaseComObject(pPersistence); // See Package.cs from MPF for reason
                }
            }
        }
Beispiel #10
0
 public int LoadUserOptions(IVsSolutionPersistence pPersistence, [ComAliasName("Microsoft.VisualStudio.Shell.Interop.VSLOADUSEROPTS")] uint grfLoadOpts)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     pPersistence.LoadPackageUserOpts(this, SELECTED_WEB_RESOURCES);
     pPersistence.LoadPackageUserOpts(this, SELECTED_REPORTS);
     return(VSConstants.S_OK);
 }
        private async Task SolutionDevKitSettingInitializeAsync()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsSolutionPersistence solutionPersistence = await GetServiceAsync(typeof(IVsSolutionPersistence)) as IVsSolutionPersistence ?? throw new ArgumentNullException(nameof(solutionPersistence));

            solutionPersistence.LoadPackageUserOpts(this, SELECTED_WEB_RESOURCES);
            solutionPersistence.LoadPackageUserOpts(this, SELECTED_REPORTS);
        }
Beispiel #12
0
        // Called by the shell when a solution is opened and the SUO file is read.
        public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
        {
            if (ShouldMEFBeInitialized())
            {
                NuGetUIThreadHelper.JoinableTaskFactory.Run(InitializeMEFAsync);
            }

            return(SolutionUserOptions.Value.LoadUserOptions(pPersistence, grfLoadOpts));
        }
Beispiel #13
0
        // Called by the shell when the SUO file is saved. The provider calls the shell back to let it
        // know which options keys it will use in the suo file.
        public int SaveUserOptions(IVsSolutionPersistence pPersistence)
        {
            if (SolutionUserOptions != null && SolutionUserOptions.IsValueCreated)
            {
                return(SolutionUserOptions.Value.SaveUserOptions(pPersistence));
            }

            return(VSConstants.S_OK);
        }
Beispiel #14
0
        public int SaveSolutionProps([In] IVsHierarchy pHierarchy, [In] IVsSolutionPersistence pPersistence)
        {
            const int writeToPreLoadSection = 1; //1 == true

            pPersistence.SavePackageSolutionProps(writeToPreLoadSection, pHierarchy, this, SolutionPropertiesKeyName);

            _hasDirtySolutionProperties = false;
            return(VSConstants.S_OK);
        }
Beispiel #15
0
        private async Task SolutionInitializeAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsSolutionPersistence solutionPersistence = await GetServiceAsync(typeof(IVsSolutionPersistence)) as IVsSolutionPersistence ?? throw new ArgumentNullException(nameof(solutionPersistence));

            solutionPersistence.LoadPackageUserOpts(this, SELECTED_WEB_RESOURCES);
            solutionPersistence.LoadPackageUserOpts(this, SELECTED_REPORTS);
        }
 /// <summary>
 /// Called by the shell when a solution is opened and the SUO file is read.
 /// </summary>
 public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
 {
     // Note this can be during opening a new solution, or may be during merging of 2 solutions.
     // The provider calls the shell back to let it know which options keys from the suo file were written by this provider.
     // If the shell will find in the suo file a section that belong to this package, it will create a stream,
     // and will call back the provider on IVsPersistSolutionProps.ReadUserOptions() to read specific options
     // under that option key.
     pPersistence.LoadPackageUserOpts(this, _strSolutionUserOptionsKey);
     return(VSConstants.S_OK);
 }
Beispiel #17
0
        private int _LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
        {
            solutionService.GetSolutionInfo(out string solutionPath, out string solutionFilePath, out string suoPath);
            this.BookmarksManager.SolutionPath = solutionPath;

            return
                (StorageOptions.SaveBookmarksToOwnFile ?
                 VSConstants.S_OK :
                 pPersistence.LoadPackageUserOpts(this, persistenceKey));
        }
        public int SaveSolutionProps(IVsHierarchy pHierarchy, IVsSolutionPersistence pPersistence)
        {
            if (pHierarchy == null)
            {
                pPersistence.SavePackageSolutionProps(1 /* TRUE */, null, this, SolutionPersistanceKey);
                Presenter.ResetConfiguration();
            }

            return(VSConstants.S_OK);
        }
Beispiel #19
0
        public int SaveSolutionProps(IVsHierarchy pHierarchy, IVsSolutionPersistence pPersistence)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (pHierarchy == null)
            {
                return(pPersistence.SavePackageSolutionProps(1, null, this, PackageGuidString));
            }

            return(VSConstants.S_OK);
        }
Beispiel #20
0
        // Called by the shell when the SUO file is saved. The provider calls the shell back to let it
        // know which options keys it will use in the suo file.
        public int SaveUserOptions(IVsSolutionPersistence pPersistence)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (SolutionUserOptions != null && SolutionUserOptions.IsValueCreated)
            {
                return(SolutionUserOptions.Value.SaveUserOptions(pPersistence));
            }

            return(VSConstants.S_OK);
        }
Beispiel #21
0
        public override void Execute()
        {
            EnvDTE.DTE dte = this.GetService <EnvDTE.DTE>(true);


            try
            {
                IVsSolutionPersistence pers = this.GetService <IVsSolutionPersistence>(true);

                //pers.LoadPackageUserOpts(
            }
            catch (Exception)
            {
            }

            string template = this.SourceFileName;

            if (Content != "")
            {
                template = Path.GetTempFileName();
                using (StreamWriter writer = new StreamWriter(template, false))
                {
                    writer.WriteLine(Content);
                }
            }

            string templateBasePath = GetTemplateBasePath();

            if (!Path.IsPathRooted(template))
            {
                template = Path.Combine(templateBasePath, template);
            }

            template = new FileInfo(template).FullName;

            string solutionPath = (string)dte.Solution.Properties.Item("Path").Value;
            string solutionDir  = Path.GetDirectoryName(solutionPath);
            string keyFilePath  = Path.Combine(solutionDir, this.TargetFileName);

            File.Copy(template, keyFilePath);

            try
            {
                Helpers.LogMessage(dte, this, keyFilePath + ": File added");

                DteHelper.SelectSolution(dte);
                dte.ItemOperations.AddExistingItem(keyFilePath);
                dte.ActiveWindow.Close(EnvDTE.vsSaveChanges.vsSaveChangesNo);
            }
            catch (Exception ex)
            {
                Helpers.LogMessage(dte, this, ex.ToString());
            }
        }
Beispiel #22
0
        internal void ReadProjectTrustInformation()
        {
            this.projectTrustTable.Clear();

            IVsSolutionPersistence persistance = this.GetService(typeof(SVsSolutionPersistence)) as IVsSolutionPersistence;

            if (persistance != null)
            {
                // Read the stream out of the .SUO file.  This will call us back on our ReadUserOptions method.
                persistance.LoadPackageUserOpts(this, this.ProjectTrustPersistenceKey);
            }
        }
Beispiel #23
0
        public int SaveUserOptions(IVsSolutionPersistence pPersistence)
        {
            try
            {
                pPersistence.SavePackageUserOpts(this, CqrsNetSettingsKey);

                return(VSConstants.S_OK);
            }
            finally
            {
                Marshal.ReleaseComObject(pPersistence);                 // See Package.cs from MPF for reason
            }
        }
 public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
 {
     try {
         foreach (StoreType type in Enum.GetValues(typeof(StoreType)))
         {
             pPersistence.LoadPackageUserOpts(this, getKey(type));
         }
     }
     finally {
         Marshal.ReleaseComObject(pPersistence);
     }
     return(VSConstants.S_OK);
 }
Beispiel #25
0
        public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
        {
            try
            {
                pPersistence.LoadPackageUserOpts(this, CqrsNetSettingsKey);
            }
            finally
            {
                Marshal.ReleaseComObject(pPersistence);
            }

            return(VSConstants.S_OK);
        }
        public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                pPersistence.LoadPackageUserOpts(this, SettingsKey);
            }
            finally
            {
                Marshal.ReleaseComObject(pPersistence);
            }

            return(VSConstants.S_OK);
        }
        public int SaveSolutionProps(IVsHierarchy pHierarchy, IVsSolutionPersistence pPersistence)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            try
            {
                int hr = VSErr.S_OK;

                // This function gets called by the shell after QuerySaveSolutionProps returned QSP_HasDirtyProps

                // The package will pass in the key under which it wants to save its properties,
                // and the IDE will call back on WriteSolutionProps

                // The properties will be saved in the Pre-Load section
                // When the solution will be reopened, the IDE will call our package to load them back before the projects in the solution are actually open
                // This could help if the source control package needs to persist information like projects translation tables, that should be read from the suo file
                // and should be available by the time projects are opened and the shell start calling IVsSccEnlistmentPathTranslation functions.
                if (Scc != null && Scc.IsSolutionManaged)
                {
                    if (pHierarchy == null)
                    {
                        hr = pPersistence.SavePackageSolutionProps(1 /* fPreLoad */, pHierarchy, this, SubversionPropertyCategory);
                    }
                    else if (Scc.HasProjectProperties(pHierarchy))
                    {
                        hr = pPersistence.SavePackageSolutionProps(1 /* fPreLoad */, pHierarchy, this, AnkhId.SvnOriginName);
                    }

                    // Once we saved our props, the solution is not dirty anymore
                    if (VSErr.Succeeded(hr))
                    {
                        Scc.IsSolutionDirty = false;
                    }
                }

                return(hr);
            }
            catch (Exception ex)
            {
                IAnkhErrorHandler handler = GetService <IAnkhErrorHandler>();

                if (handler != null)
                {
                    handler.OnError(ex);
                }

                return(Marshal.GetHRForException(ex));
            }
        }
Beispiel #28
0
        // IVsPersistSolutionProps::SaveUserOptions
        public int SaveUserOptions([In] IVsSolutionPersistence pPersistence)
        {
            // This function gets called by the shell when the SUO file is saved.
            // The provider calls the shell back to let it know which options keys it will use in the suo file.
            // The shell will create a stream for the section of interest, and will call back the provider on
            // IVsPersistSolutionProps.WriteUserOptions() to save specific options under the specified key.
            int pfResult = 0;

            SccService.AnyItemsUnderSourceControl(out pfResult);
            if (pfResult > 0)
            {
                pPersistence.SavePackageUserOpts(this, _strSolutionUserOptionsKey);
            }
            return(VSConstants.S_OK);
        }
Beispiel #29
0
        // IVsPersistSolutionProps::SaveSolutionProps
        public int SaveSolutionProps([In] IVsHierarchy pHierarchy, [In] IVsSolutionPersistence pPersistence)
        {
            // This function gets called by the shell after determining the package has dirty props.
            // The package will pass in the key under which it wants to save its properties,
            // and the IDE will call back on WriteSolutionProps

            // The properties will be saved in the Pre-Load section
            // When the solution will be reopened, the IDE will call our package to load them back before the projects in the solution are actually open
            // This could help if the source control package needs to persist information like projects translation tables, that should be read from the suo file
            // and should be available by the time projects are opened and the shell start calling IVsSccEnlistmentPathTranslation functions.
            pPersistence.SavePackageSolutionProps(1, null, this, _strSolutionPersistanceKey);

            // Once we saved our props, the solution is not dirty anymore
            SolutionHasDirtyProps = false;

            return(VSConstants.S_OK);
        }
        public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
        {
            if ((grfLoadOpts & (uint)__VSLOADUSEROPTS.LUO_OPENEDDSW) != 0)
            {
                return VSConstants.S_OK; // We only know .suo; let's ignore old style projects
            }

            try
            {
                pPersistence.LoadPackageUserOpts(this, SccPendingChangeStream);
                pPersistence.LoadPackageUserOpts(this, SccEnlistStream);

                return VSConstants.S_OK;
            }
            finally
            {
                Marshal.ReleaseComObject(pPersistence); // See Package.cs from MPF for reason
            }
        }
Beispiel #31
0
        /// <include file='doc\Package.uex' path='docs/doc[@for="Package.IVsPersistSolutionOpts.SaveUserOptions"]/*' />
        /// <internalonly/>
        /// <devdoc>
        /// IVsPersistSolutionOpts implementation.
        /// Called by the shell when we are to persist our service options
        /// </devdoc>
        int IVsPersistSolutionOpts.SaveUserOptions(IVsSolutionPersistence pPersistance)
        {
            if (_optionKeys != null) {
                foreach(string key in _optionKeys) {
                    NativeMethods.ThrowOnFailure( pPersistance.SavePackageUserOpts(this, key) );
                }
            }

            return NativeMethods.S_OK;
        }
 public void SaveNuGetSettings()
 {
     IVsSolutionPersistence solutionPersistence = GetGlobalService(typeof(SVsSolutionPersistence)) as IVsSolutionPersistence;
     solutionPersistence.SavePackageUserOpts(this, "nuget");
 }
 public int SaveUserOptions(IVsSolutionPersistence pPersistence)
 {
     return VSConstants.S_OK;
 }
        public int SaveSolutionProps(IVsHierarchy pHierarchy, IVsSolutionPersistence pPersistence)
        {
            if (pHierarchy == null)
            {
                pPersistence.SavePackageSolutionProps(1 /* TRUE */, null, this, SolutionPersistanceKey);
                Presenter.ResetConfiguration();
            }

            return VSConstants.S_OK;
        }
 public int LoadUserOptions(IVsSolutionPersistence pPersistence, uint grfLoadOpts)
 {
     return VSConstants.S_OK;
 }
        public int SaveSolutionProps(IVsHierarchy pHierarchy, IVsSolutionPersistence pPersistence)
        {
            // This function gets called by the shell after QuerySaveSolutionProps returned QSP_HasDirtyProps

            // The package will pass in the key under which it wants to save its properties,
            // and the IDE will call back on WriteSolutionProps

            // The properties will be saved in the Pre-Load section
            // When the solution will be reopened, the IDE will call our package to load them back before the projects in the solution are actually open
            // This could help if the source control package needs to persist information like projects translation tables, that should be read from the suo file
            // and should be available by the time projects are opened and the shell start calling IVsSccEnlistmentPathTranslation functions.
            if (pHierarchy == null) // Only save the property on the solution itself
            {
                IVisualGitSccService scc = GetService<IVisualGitSccService>();

                // SavePackageSolutionProps will call WriteSolutionProps with the specified key

                if (scc != null && scc.HasSolutionData)
                    pPersistence.SavePackageSolutionProps(1 /* TRUE */, null, this, GitPropertyCategory);

                ISccSettingsStore translate = GetService<ISccSettingsStore>();
                if (translate != null && translate.HasSolutionData)
                    pPersistence.SavePackageSolutionProps(1 /* TRUE */, null, this, VisualGitId.SccStructureName);

                // Once we saved our props, the solution is not dirty anymore
                scc.IsSolutionDirty = false;
            }

            return VSConstants.S_OK;
        }
Beispiel #37
0
        /// <include file='doc\Package.uex' path='docs/doc[@for="Package.IVsPersistSolutionOpts.LoadUserOptions"]/*' />
        /// <internalonly/>
        /// <devdoc>
        /// IVsPersistSolutionOpts implementation.
        /// Called when a solution is opened, and allows us to inspect our options.
        /// </devdoc>
        int IVsPersistSolutionOpts.LoadUserOptions(IVsSolutionPersistence pPersistance, uint options) {

            int hr = NativeMethods.S_OK;
            if ((options & (uint)__VSLOADUSEROPTS.LUO_OPENEDDSW) != 0) {
                return hr;
            }

            if (_optionKeys != null) {
                foreach(string key in _optionKeys) {
                    hr = pPersistance.LoadPackageUserOpts(this, key);
                    if (NativeMethods.Failed(hr))
                        break;
                }
            }

            // Shell relies on this being released when we're done with it.  If you see strange
            // faults in the shell when saving the solution, suspect this!
            //
            Marshal.ReleaseComObject(pPersistance);

            NativeMethods.ThrowOnFailure(hr);
            return hr;
        }
Beispiel #38
0
        /// <include file='doc\Package.uex' path='docs/doc[@for="Package.IVsPersistSolutionOpts.SaveUserOptions"]/*' />
        /// <internalonly/>
        /// <devdoc>
        /// IVsPersistSolutionOpts implementation.
        /// Called by the shell when we are to persist our service options
        /// </devdoc>
        int IVsPersistSolutionOpts.SaveUserOptions(IVsSolutionPersistence pPersistance) {

            if (_optionKeys != null) {
                foreach(string key in _optionKeys) {
                    NativeMethods.ThrowOnFailure( pPersistance.SavePackageUserOpts(this, key) );
                }
            }

            // Shell relies on this being released when we're done with it.  If you see strange
            // faults in the shell when saving the solution, suspect this!
            //
            Marshal.ReleaseComObject(pPersistance);

            return NativeMethods.S_OK;
        }
Beispiel #39
0
        /// <include file='doc\Package.uex' path='docs/doc[@for="Package.IVsPersistSolutionOpts.LoadUserOptions"]/*' />
        /// <internalonly/>
        /// <devdoc>
        /// IVsPersistSolutionOpts implementation.
        /// Called when a solution is opened, and allows us to inspect our options.
        /// </devdoc>
        int IVsPersistSolutionOpts.LoadUserOptions(IVsSolutionPersistence pPersistance, uint options)
        {
            int hr = NativeMethods.S_OK;
            if ((options & (uint)__VSLOADUSEROPTS.LUO_OPENEDDSW) != 0) {
                return hr;
            }

            if (_optionKeys != null) {
                foreach(string key in _optionKeys) {
                    hr = pPersistance.LoadPackageUserOpts(this, key);
                    if (NativeMethods.Failed(hr))
                        break;
                }
            }

            NativeMethods.ThrowOnFailure(hr);
            return hr;
        }