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