OK. It worked. the code:
[ApplicationStartup]publicclass TestStartupEvents {static TestStartupEvents() {//RegisterEvents();return; }publicstaticvoid OnBeforeInitialize() {//RegisterEvents();return; }publicstaticvoid OnInitialized() { RegisterEvents();return; }publicstaticvoid RegisterEvents() { DataEvents<IPage>.OnAfterAdd += new DataEventHandler(DataEvents_OnAferAdd); DataEvents<IPage>.OnDeleted += new DataEventHandler(DataEvents_OnDeleted); DataEvents<IPage>.OnNew += new DataEventHandler(DataEvents_OnNew); DataEvents<IPage>.OnStoreChanged += new StoreEventHandler(DataEvents_OnStoreChanged);return; }///<summary>///</summary>///<returns></returns>staticvoid DataEvents_OnAferAdd(object sender, DataEventArgs dataEventArgs) {// here a minor update to the cache could be done (like adding info about the new element only).return; }staticvoid DataEvents_OnNew(object sender, DataEventArgs dataEventArgs) {// here a minor update to the cache could be done // (like adding info about the new element only).return; }staticvoid DataEvents_OnDeleted(object sender, DataEventArgs dataEventArgs) {// here a minor update to the cache could be done // (like adding info about the new element only).return; }staticvoid DataEvents_OnStoreChanged(object sender, StoreEventArgs storeEventArgs) {if (!storeEventArgs.DataEventsFired) {// an external update event happened - DataEvents_OnBeforeAdd not fired// here a complete cache flush could be done }return; } } }
Another question: hooking events can be done in Globa.asax too. Right?
OK this approach is more elegant, but Global.asax Application_Start should do the job?
thanks
mel