Create an extension function similar to Google Labs

I am not sure if this is a suitable question, because it is rather specific, but in any case ...

In this application I'm working on, I have an extension system based on static events . The whole idea is taken mainly from the (very cool) extension system created by BlogEngine.NET .

Essentially, Application_Startan extension instance is created that captures static events in application classes.
Take, for example, an extension that censors blacklisted words, for example, from a forum post before displaying it on a page; When an event is ForumMessage.OnDisplayingfired, the extension takes the sender object ForumMessageand replaces the blacklists with words.

Example:

static class WordBlackListExtension {
    private static string[] _blacklist = new string[] { ... };
    static WordBlacklistExtension() { ForumMessage.OnDisplaying += DoWork; }
    private static void DoWork(object sender, EventArgs e) {
        // Do some blacklist filtering...
        ((ForumMessage)sender).Body = ...;
    }
}

, , , , .
, , , , Google Labs? / ?
.

, , - , ( - ForumMessage.Forum.etc.Config - );

?
? , - EventArgs?
, ?

?

Edit

- - ?
- - .

+3
1

, EventArgs . , .

. , ..

+2

Source: https://habr.com/ru/post/1730878/


All Articles