11using System ;
22using System . ComponentModel . Composition ;
33using System . Diagnostics . CodeAnalysis ;
4- using System . Linq ;
5- using System . Reflection ;
64using System . Windows ;
7- using GitHub . VisualStudio ;
85
96namespace GitHub . Exports
107{
@@ -45,21 +42,6 @@ public ExportViewForAttribute(Type viewModelType)
4542 public string ViewModelType { get ; }
4643 }
4744
48- /// <summary>
49- /// A MEF export attribute that defines an export of type <see cref="IMenuHandler"/> with
50- /// <see cref="MenuType"/> metadata.
51- /// </summary>
52- [ MetadataAttribute ]
53- [ AttributeUsage ( AttributeTargets . Class , AllowMultiple = false ) ]
54- public sealed class ExportMenuAttribute : ExportAttribute
55- {
56- public ExportMenuAttribute ( ) : base ( typeof ( IMenuHandler ) )
57- {
58- }
59-
60- public MenuType MenuType { get ; set ; }
61- }
62-
6345 /// <summary>
6446 /// Defines a MEF metadata view that matches <see cref="ExportViewModelForAttribute"/> and
6547 /// <see cref="ExportViewForAttribute"/>.
@@ -73,35 +55,4 @@ public interface IViewModelMetadata
7355 [ SuppressMessage ( "Microsoft.Performance" , "CA1819:PropertiesShouldNotReturnArrays" ) ]
7456 string [ ] ViewModelType { get ; }
7557 }
76-
77- /// <summary>
78- /// Defines a MEF metadata view that matches <see cref="ExportMenuAttribute"/>.
79- /// </summary>
80- /// <remarks>
81- /// For more information see the Metadata and Metadata views section at
82- /// https://msdn.microsoft.com/en-us/library/ee155691(v=vs.110).aspx#Anchor_3
83- /// </remarks>
84- public interface IMenuMetadata
85- {
86- MenuType MenuType { get ; }
87- }
88-
89- public static class ExportMetadataAttributeExtensions
90- {
91- public static bool IsMenuType ( this IMenuHandler c , MenuType type )
92- {
93- return c . GetType ( ) . GetCustomAttributesData ( ) . Any ( attr => IsMenuType ( attr , type ) ) ;
94- }
95-
96- static bool IsMenuType ( CustomAttributeData attributeData , MenuType type )
97- {
98- if ( attributeData . NamedArguments == null )
99- {
100- throw new GitHubLogicException ( "attributeData.NamedArguments may not be null" ) ;
101- }
102-
103- return attributeData . AttributeType == typeof ( ExportMenuAttribute )
104- && ( MenuType ) attributeData . NamedArguments [ 0 ] . TypedValue . Value == type ;
105- }
106- }
10758}
0 commit comments