Exemple #1
0
        public AspectDefinition[] Match(Type targetType, AspectDefinitionCollection aspects)
        {
            // TODO: think about caches here...

            ArrayList list = new ArrayList();

            foreach (AspectDefinition aspect in aspects)
            {
                IClassMatcher matcher = ObtainClassMatcher(aspect);

                if (matcher.Match(targetType, aspect))
                {
                    list.Add(aspect);
                }
            }

            return((AspectDefinition[])list.ToArray(typeof(AspectDefinition)));
        }
Exemple #2
0
        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);
        }
		private void RegisterMatcherInCache(IClassMatcher matcher, Type customType)
		{
			_customMatcherCache[customType] = matcher;
		}
Exemple #4
0
 private void RegisterMatcherInCache(IClassMatcher matcher, Type customType)
 {
     _customMatcherCache[customType] = matcher;
 }