Exemplo n.º 1
0
 public static void IsValid(InvokingConstraint obj, MethodReturnEventArgs<bool> e, object constrainedObject, object constrainedValue)
 {
     var implementor = obj.IsValidInvocation.Implementor.AsType(false);
     if (implementor == null)
     {
         Log.ErrorFormat("Implementor [{0}] not found", obj.IsValidInvocation.Implementor);
         return;
     }
     var methodInfo = implementor.FindMethod(obj.IsValidInvocation.MemberName, ObjectObject);
     if (methodInfo == null)
     {
         Log.ErrorFormat("Method [{0}](object,object) not found in [{1}]", obj.IsValidInvocation.MemberName, obj.IsValidInvocation.Implementor);
         return;
     }
     e.Result = (bool)methodInfo.Invoke(null, new object[] { constrainedObject, constrainedValue });
 }
Exemplo n.º 2
0
        public static void GetErrorText(InvokingConstraint obj, MethodReturnEventArgs <string> e, object constrainedObject, object constrainedValue)
        {
            var implementor = obj.GetErrorTextInvocation.Implementor.AsType(false);

            if (implementor == null)
            {
                Log.ErrorFormat("Implementor [{0}] not found", obj.GetErrorTextInvocation.Implementor);
                return;
            }
            var methodInfo = implementor.FindMethod(obj.GetErrorTextInvocation.MemberName, ObjectObject);

            if (methodInfo == null)
            {
                Log.ErrorFormat("Method [{0}](object,object) not found in [{1}]", obj.GetErrorTextInvocation.MemberName, obj.IsValidInvocation.Implementor);
                return;
            }
            e.Result = (string)methodInfo.Invoke(null, new object[] { constrainedObject, constrainedValue });
        }