Having a base class for lightswitch screens? RRS feed

  • Question

  • I want to introduce an own concurrency handling :

    For example

    partial void UsersListDetail_SaveError(Exception exception, ref bool handled)
        if (exception is ConcurrencyException)
          handled = true;

    Until now, I have to add this code to every data manupulating Screen.

    Is there a way to have lightswitch to execute my own SaveError-Method for all screens?

    In Windows Forms I would create my on base form and all other forms will be derived from that base class.

    Thanks for your help

    Thursday, July 24, 2014 2:42 PM


  • Interesting question.

    A base class wouldn't work in this case, because the screen class is already "based" on a base class. C#/VB doesn't support multiple inheritance.

    What is used for your problem is a technique called code weaving. (e.g. postSharp, I think Roslyn can do it as well). Nonetheless, I don't recommend this, unless you don't mind to go very deep on technical level.

    The easiest thing is simply wrap it in a reusable utility class in such a way you can add it as a one liner.


    paul van bladel independent enterprise application architect. http://blog.pragmaswitch.com

    • Proposed as answer by joshbooker Thursday, July 24, 2014 7:25 PM
    • Marked as answer by Angie Xu Tuesday, July 29, 2014 7:42 AM
    Thursday, July 24, 2014 7:07 PM