QuickStart Commandfilter Project on GitHub with its own modified version

Source: Internet
Author: User

Example of command filtering

Derive a new command filter class from Commandfilterattribute, and then place these derived classes above the command class []

Finally, it triggers when the command is executed.

Oncommandexecuting and Oncommandexecuted methods, these 2 methods need to be overridden in a derived class

Specific analysis:

First, a server class

[Countcommandfilter]//global Command Filter
public class Myappserver:appserver<myappsession>

Then there are 2 command classes

[Logtimecommandfilter]

public class Login:stringcommandbase<myappsession>

[Loggedinvalidationfilter (Order = 0)]
[Logtimecommandfilter (Order = 1)]

public class Query:stringcommandbase<myappsession>

Then there are 3 commands to filter the class

public class Countcommandfilter:commandfilterattribute

public class Loggedinvalidationfilter:commandfilterattribute

public class Logtimecommandfilter:commandfilterattribute

Where Countcommandfilter as the global command filter
LOGIN has an explicit command-filtering [Logtimecommandfilter]

Query has 2 explicit command filters [loggedinvalidationfilter (order = 0)] and [Logtimecommandfilter (order = 1)]

They all have implicit global command filtering Countcommandfilter

So the last time you execute the command:

The login command only triggers 2 command filters

The query command triggers 3 command filters

QuickStart Commandfilter Project on GitHub with its own modified version

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.