vendredi 3 novembre 2023

Provider pattern in C#

Am trying to understand provider pattern in detail , When I use a Abstract class and inherit a providerbase with abstract method then create two class when implements the abstract class and abstract method, The Query here is I am not clear with this understanding as this can be achieved with a simple abstract class and implementing a class , So why are we really inheriting a ProviderBase ? I tried a sample design below , can someone help me in the provider Base class usage in Microsoft please . Thanks

using System.Configuration.Provider;

 namespace POC_Driver
 {
  public abstract class DealNotesProvideBase : ProviderBase
  {
    public abstract void saveData();
  }
 }

 public class DealNotesAsDatapathProvider : DealNotesProvideBase
{


public DealNotesAsDatapathProvider()
{
    

}
  public  override void saveData()
  {
     // do something 
  }
}

 public class AnotherClassProvider : DealNotesProvideBase
{


 
  public override void saveData()
  {
     // do something 
  }
}

Main(){

 DealNotesAsDatapathProvider provider = new DealNotesAsDatapathProvider ();
 AnotherClassProvider  anotherclassprovider = new AnotherClassProvider ();
 provider.saveData();
 anotherclassprovider.saveData();
}

Aucun commentaire:

Enregistrer un commentaire