AspectSharp.Core.Matchers.DefaultAspectMatcher.ObtainCustomMatcher C# (CSharp) Method

ObtainCustomMatcher() protected method

protected ObtainCustomMatcher ( TargetTypeDefinition target ) : IClassMatcher
target AspectSharp.Lang.AST.TargetTypeDefinition
return IClassMatcher
		protected virtual IClassMatcher ObtainCustomMatcher(TargetTypeDefinition target)
		{
			Type customType = target.CustomMatcherType.ResolvedType;

			IClassMatcher matcher = GetCustomMatcherFromCache(customType);

			try
			{
				matcher = (IClassMatcher) Activator.CreateInstance(customType);
			}
			catch (InvalidCastException ex)
			{
				throw new MatcherException("Error trying to cast your custom class matcher to IClassMatcher", ex);
			}
			catch (Exception ex)
			{
				throw new MatcherException("Error trying to instantiate your custom class matcher", ex);
			}

			RegisterMatcherInCache(matcher, customType);

			return matcher;
		}