-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/fonts-and-colors
- Loading branch information
Showing
18 changed files
with
445 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...oolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/ToolkitPackageExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace Community.VisualStudio.Toolkit | ||
{ | ||
/// <summary> | ||
/// Extensions for an <see cref="ToolkitPackage"/> | ||
/// </summary> | ||
public static class ToolkitPackageExtensions | ||
{ | ||
/// <summary> | ||
/// Automatically calls the <see cref="BaseToolWindow{T}.Initialize(ToolkitPackage)"/> | ||
/// method for every <see cref="BaseToolWindow{T}"/> in the package or provided assemblies. | ||
/// </summary> | ||
/// <param name="package">The package that contains the tool windows to register.</param> | ||
/// <param name="assemblies">The additional assemblies to look for tool windows in.</param> | ||
public static void RegisterToolWindows(this ToolkitPackage package, params Assembly[] assemblies) | ||
{ | ||
List<Assembly> assembliesList = assemblies.ToList(); | ||
Assembly packageAssembly = package.GetType().Assembly; | ||
if (!assembliesList.Contains(packageAssembly)) | ||
assembliesList.Add(packageAssembly); | ||
|
||
Type baseToolWindowType = typeof(BaseToolWindow<>); | ||
IEnumerable<Type> toolWindowTypes = assembliesList.SelectMany(x => x.GetTypes()) | ||
.Where(x => | ||
!x.IsAbstract | ||
&& x.IsAssignableToGenericType(baseToolWindowType)); | ||
|
||
foreach (Type? toolWindowtype in toolWindowTypes) | ||
{ | ||
MethodInfo initializeMethod = toolWindowtype.GetMethod( | ||
"Initialize", | ||
BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); | ||
|
||
initializeMethod.Invoke(null, new object[] { package }); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.