1+ using System ;
12using System . Collections . Generic ;
23using System . Linq ;
34using Mono . Cecil ;
@@ -27,6 +28,9 @@ public AspectInfo(CustomAttribute aspectAttribute)
2728 InitSkipProperties ( aspectAttributes ) ;
2829 InitTargetMembers ( ) ;
2930 InitChangingInputArguments ( aspectAttributes ) ;
31+ InitNamespaceFilter ( ) ;
32+ InitTypeNameFilter ( ) ;
33+ InitMethodNameFilter ( ) ;
3034 }
3135
3236 public TypeDefinition AspectTypeDefinition { get ; }
@@ -49,6 +53,10 @@ public AspectInfo(CustomAttribute aspectAttribute)
4953
5054 public bool AllowChangingInputArguments { get ; private set ; }
5155
56+ public string NamespaceFilter { get ; set ; }
57+ public string TypeNameFilter { get ; set ; }
58+ public string MethodNameFilter { get ; set ; }
59+
5260 public IEnumerable < MethodAttributes > AttributeTargetMemberAttributes { get ; set ; } =
5361 new List < MethodAttributes >
5462 {
@@ -199,5 +207,47 @@ private void InitChangingInputArguments(IEnumerable<CustomAttribute> aspectAttri
199207 . Any ( c => c . AttributeType . FullName == AttributeFullNames . AllowChangingInputArguments ) ;
200208
201209 }
210+
211+ private void InitNamespaceFilter ( )
212+ {
213+ var namespaceFilterArgument = AspectAttribute . Properties
214+ . FirstOrDefault ( property => property . Name == AttributeNames . NamespaceFilter ) ;
215+
216+ if ( namespaceFilterArgument . Equals ( default ( CustomAttributeNamedArgument ) ) )
217+ return ;
218+
219+ if ( ! ( namespaceFilterArgument . Argument . Value is string argumentValue ) )
220+ return ;
221+
222+ NamespaceFilter = argumentValue ;
223+ }
224+
225+ private void InitTypeNameFilter ( )
226+ {
227+ var typeNameFilterArgument = AspectAttribute . Properties
228+ . FirstOrDefault ( property => property . Name == AttributeNames . TypeNameFilter ) ;
229+
230+ if ( typeNameFilterArgument . Equals ( default ( CustomAttributeNamedArgument ) ) )
231+ return ;
232+
233+ if ( ! ( typeNameFilterArgument . Argument . Value is string argumentValue ) )
234+ return ;
235+
236+ TypeNameFilter = argumentValue ;
237+ }
238+
239+ private void InitMethodNameFilter ( )
240+ {
241+ var methodNameFilterArgument = AspectAttribute . Properties
242+ . FirstOrDefault ( property => property . Name == AttributeNames . MethodNameFilter ) ;
243+
244+ if ( methodNameFilterArgument . Equals ( default ( CustomAttributeNamedArgument ) ) )
245+ return ;
246+
247+ if ( ! ( methodNameFilterArgument . Argument . Value is string argumentValue ) )
248+ return ;
249+
250+ MethodNameFilter = argumentValue ;
251+ }
202252 }
203253}
0 commit comments