コード例 #1
0
        public static Guid GetDteClsid(IHostPlugin serviceProvider)
        {
            try
            {
                var localRegistry4   = serviceProvider.GetService <SLocalRegistry>() as ILocalRegistry4;
                var pdwRegRootHandle = 0U;
                if (localRegistry4 != null)
                {
                    string pbstrRoot;
                    if (HResult.Succeeded(localRegistry4.GetLocalRegistryRootEx(2U, out pdwRegRootHandle, out pbstrRoot)))
                    {
                        switch (pdwRegRootHandle)
                        {
                        case 2147483649U:
                            using (var registryKey = Registry.CurrentUser.OpenSubKey(pbstrRoot))
                            {
                                if (registryKey != null)
                                {
                                    var obj = registryKey.GetValue("ThisVersionDTECLSID");
                                    if (obj is string)
                                    {
                                        Guid result;
                                        if (Guid.TryParse((string)obj, out result))
                                        {
                                            return(result);
                                        }
                                    }
                                }
                                break;
                            }

                        case 2147483650U:
                            using (var registryKey = Registry.LocalMachine.OpenSubKey(pbstrRoot))
                            {
                                if (registryKey != null)
                                {
                                    var obj = registryKey.GetValue("ThisVersionDTECLSID");
                                    if (obj is string)
                                    {
                                        Guid result;
                                        if (Guid.TryParse((string)obj, out result))
                                        {
                                            return(result);
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TeamFoundationTrace.TraceAndDebugFailException(ex);
            }
            return(new Guid());
        }
コード例 #2
0
        /// <summary>
        /// Registers the plugins from directory.
        /// </summary>
        /// <param name="host">The host.</param>
        public static void RegisterPluginsFromDirectory(IHostPlugin host)
        {
            // Constructing plugins directory
            string directory = ConfigurationManager.AppSettings["PluginsDirectory"];

            if (string.IsNullOrWhiteSpace(directory))
            {
                directory = @"Plugins\";
            }

            string path = Path.Combine(Application.StartupPath, directory);

            string[] pluginFiles = Directory.GetFiles(path, "*.dll");

            // Constructing plugins array.
            registeredPlugins = new IPlugin[pluginFiles.Length];

            for (int i = 0; i < pluginFiles.Length; i++)
            {
                // Loading plugins.
                try
                {
                    Assembly assembly = Assembly.LoadFrom(pluginFiles[i]);

                    // Next we'll loop through all the Types found in the assembly.
                    foreach (Type pluginType in assembly.GetTypes())
                    {
                        if (pluginType.IsPublic)        // Only look at public types.
                        {
                            if (!pluginType.IsAbstract) // Only look at non-abstract types.
                            {
                                // Gets a type object of the interface we need the plugins to match.
                                Type typeInterface = pluginType.GetInterface("WpfKolekcjaZdjec.Plugins.IPlugin", true);

                                // Make sure the interface we want to use actually exists.
                                if (typeInterface != null)
                                {
                                    registeredPlugins[i]      = (IPlugin)Activator.CreateInstance(assembly.GetType(pluginType.ToString()));
                                    registeredPlugins[i].Host = host;
                                }

                                typeInterface = null;
                            }
                        }
                    }

                    assembly = null;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Plugins Subsystem Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Registers the plugins from directory.
        /// </summary>
        /// <param name="host">The host.</param>
        public static void RegisterPluginsFromDirectory(IHostPlugin host)
        {
            // Constructing plugins directory
            string directory = ConfigurationManager.AppSettings["PluginsDirectory"];
            if (string.IsNullOrWhiteSpace(directory))
            {
                directory = @"Plugins\";
            }

            string path = Path.Combine(Application.StartupPath, directory);
            string[] pluginFiles = Directory.GetFiles(path, "*.dll");

            // Constructing plugins array.
            registeredPlugins = new IPlugin[pluginFiles.Length];

            for (int i = 0; i < pluginFiles.Length; i++)
            {
                // Loading plugins.
                try
                {
                    Assembly assembly = Assembly.LoadFrom(pluginFiles[i]);

                    // Next we'll loop through all the Types found in the assembly.
                    foreach (Type pluginType in assembly.GetTypes())
                    {
                        if (pluginType.IsPublic) // Only look at public types.
                        {
                            if (!pluginType.IsAbstract)  // Only look at non-abstract types.
                            {
                                // Gets a type object of the interface we need the plugins to match.
                                Type typeInterface = pluginType.GetInterface("WpfKolekcjaZdjec.Plugins.IPlugin", true);

                                // Make sure the interface we want to use actually exists.
                                if (typeInterface != null)
                                {
                                    registeredPlugins[i] = (IPlugin)Activator.CreateInstance(assembly.GetType(pluginType.ToString()));
                                    registeredPlugins[i].Host = host;
                                }

                                typeInterface = null;
                            }
                        }
                    }

                    assembly = null;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Plugins Subsystem Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #4
0
        public static IVsWindowFrame LaunchInWebBrowser(IHostPlugin plugin, string url, bool newWindow)
        {
            var            webBrowsingService = plugin.GetService <SVsWebBrowsingService>() as IVsWebBrowsingService;
            IVsWindowFrame ppFrame            = null;

            if (webBrowsingService != null)
            {
                var vswbnavigateflags = __VSWBNAVIGATEFLAGS.VSNWB_ForceNew;
                if (!newWindow)
                {
                    vswbnavigateflags = __VSWBNAVIGATEFLAGS.VSNWB_AddToMRU;
                }
                webBrowsingService.Navigate(url, (uint)vswbnavigateflags, out ppFrame);
            }
            return(ppFrame);
        }
コード例 #5
0
        public static IVsWindowFrame LaunchInWebBrowser(IHostPlugin plugin, string url, string caption, bool newWindow,
                                                        out IVsWebBrowser browser)
        {
            var webBrowsingService = plugin.GetService <SVsWebBrowsingService>() as IVsWebBrowsingService;
            var vscreatewebbrowser = (__VSCREATEWEBBROWSER)1057;

            if (!newWindow)
            {
                vscreatewebbrowser = __VSCREATEWEBBROWSER.VSCWB_AddToMRU;
            }
            var            rguidOwner = new Guid();
            IVsWindowFrame ppFrame    = null;

            browser = null;
            if (webBrowsingService != null)
            {
                webBrowsingService.CreateWebBrowser((uint)vscreatewebbrowser, ref rguidOwner, caption, url, null, out browser,
                                                    out ppFrame);
            }
            return(ppFrame);
        }
コード例 #6
0
 public static TfsTeamProjectCollection GetTfsTeamProjectCollection(IHostPlugin plugin)
 {
     return(plugin.GetService <ITeamFoundationContextManager2>().CurrentContext.TeamProjectCollection);
 }