Catel framework class library description-catel. Core

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.