コード例 #1
0
ファイル: CommandAction.cs プロジェクト: SixtenLabs/Gluten
 /// <summary>
 /// Invoked when a new non-null target is set, which has non-null MethodInfo. Used to assert that the method signature is correct
 /// </summary>
 /// <param name="targetMethodInfo">MethodInfo of method on new target</param>
 /// <param name="newTargetType">Type of new target</param>
 protected internal override void AssertTargetMethodInfo(MethodInfo targetMethodInfo, Type newTargetType)
 {
     var methodParameters = targetMethodInfo.GetParameters();
     if (methodParameters.Length > 1)
     {
         var e = new ActionSignatureInvalidException(String.Format("Method {0} on {1} must have zero or one parameters", MethodName, newTargetType.Name));
         logger.Error(e);
         throw e;
     }
 }
コード例 #2
0
ファイル: EventAction.cs プロジェクト: SixtenLabs/Gluten
 /// <summary>
 /// Invoked when a new non-null target is set, which has non-null MethodInfo. Used to assert that the method signature is correct
 /// </summary>
 /// <param name="targetMethodInfo">MethodInfo of method on new target</param>
 /// <param name="newTargetType">Type of new target</param>
 protected internal override void AssertTargetMethodInfo(MethodInfo targetMethodInfo, Type newTargetType)
 {
     var methodParameters = targetMethodInfo.GetParameters();
     if (!(methodParameters.Length == 0 ||
             (methodParameters.Length == 1 && (typeof(EventArgs).IsAssignableFrom(methodParameters[0].ParameterType) || methodParameters[0].ParameterType == typeof(DependencyPropertyChangedEventArgs))) ||
             (methodParameters.Length == 2 && (typeof(EventArgs).IsAssignableFrom(methodParameters[1].ParameterType) || methodParameters[1].ParameterType == typeof(DependencyPropertyChangedEventArgs)))))
     {
         var e = new ActionSignatureInvalidException(String.Format("Method {0} on {1} must have the signatures void Method(), void Method(EventArgsOrSubClass e), or void Method(object sender, EventArgsOrSubClass e)", MethodName, newTargetType.Name));
         logger.Error(e);
         throw e;
     }
 }