ASP.NET design issue - Factory vs Dynamic code selection behind (if possible)

I have a generic editor on an ASP.NET page to edit search values ​​for different database tables.

The code uses a base class that handles 99% of the work for all the various searches in the system.

The C # class is passed to the base class from the code behind, as shown below.

    public class LookupPageBase : System.Web.UI.Page
    {
         protected IEditableLookupManager LookupManager
         {
          get
          {
             return this.lookupManager;
            }
         set
         {
             this.lookupManager = value;
          }
        }
     }

public partial class LookupsEditor : LookupPageBase
{
   this.LookupManager = new ConcreteManagerClass();
}

Another C # class is passed to the lookup Manager property for each search. I could use the factory pattern to avoid the big, if anything else in the code behind. However, I was wondering if it is possible to achieve the same effect through a subclass of the code behind , for example.

    public partial class LookupsEditorSubClass : LookupsEditor
{
   public LookupsEditorSubClass() {
        base.LookupManager = new ConcreteManagerClass();
   }
}

: 1) , . ? 2) factory , ?

+3
1

, MVC ? , .NET 3.5 , , .

, MVC. .

. , , Factory, , . codebehind , , . , codebehind, usercontrol . , . factory.

+1

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


All Articles