1. parameter check
We check whether the method is correct. Generally, the method returns a right error or throws an exception. Most people do not check whether the exception is correct. Therefore, this error is hard to be viewed in a deep stack.
Catel is different from the common check method.
public void CheckForException(object obj){ if (obj == null) { throw new ArgumentNullException("obj"); }}
However, catel records all behaviors, so the method for starting the check is as follows:
public void CheckForException(object obj){if (obj == null){Log.Debug("Argument ‘obj‘ is null in CheckForException");throw new ArgumentNullException("obj");}}
However, if you write the code according to this situation, a lot of repeated code will be generated. Therefore, the argument class is developed, which makes it easy to check parameters.
public void CheckForException(object obj){Argument.IsNotNull("obj", obj);}
If the value is a range, it is as follows:
public void CheckForException(object obj){Argument.IsNotNull("obj", obj);}
If you check whether an object implements an interface, use the following method:
public void CheckForException(object obj){Argument.ImplementsInterface("obj", obj, typeof(INotifyPropertyChanged));}
Catel framework class library description-catel. Core