예제 #1
0
 private bool HandlerHasBehavior(BehaviorInfo behaviorInfo)
 {
     if (behaviorInfo.BehaviorType.IsGenericType)
     {
         if (_handlerType.GetInterface(behaviorInfo.BehaviorType.FullName) != null)
         {
             return(true);
         }
     }
     return(behaviorInfo.BehaviorType.IsAssignableFrom(_handlerType));
 }
예제 #2
0
        private Expression BuildBehaviorBlock(BehaviorInfo behaviorInfo, Type[] genericArguments)
        {
            var method = behaviorInfo.GetMethod(genericArguments);
            var methodCallExpression = BuildMethodCallExpression(method);

            // If the implementation method returns a boolean, then when it is false, stop processing.
            if (method.ReturnType == typeof(bool))
            {
                return(Expression.IfThen(Expression.Not(methodCallExpression), Expression.Return(_end)));
            }
            return(methodCallExpression);
        }
예제 #3
0
        private bool AddBehaviorBlock(BehaviorInfo behaviorInfo)
        {
            if (behaviorInfo.BehaviorType.IsGenericType)
            {
                var genericInterface = _type.GetInterface(behaviorInfo.BehaviorType.FullName);
                if (genericInterface != null)
                {
                    _blocks.Add(BuildBehaviorBlock(behaviorInfo, genericInterface.GetGenericArguments()));
                    return(true);
                }
            }
            if (behaviorInfo.BehaviorType.IsAssignableFrom(_type))
            {
                _blocks.Add(BuildBehaviorBlock(behaviorInfo));
                return(true);
            }

            return(false);
        }