
    // All the Mappings required by this consumer class
    readonly Dictionary<Type, Action<DataClass>> InitMap = new Dictionary<Type, Action<DataClass>>();
    readonly Dictionary<Type, Action<DataClass>> DoSomethingAMap = new Dictionary<Type, Action<DataClass>>();
    readonly Dictionary<Type, Action<DataClass>> DoSomethingBMap = new Dictionary<Type, Action<DataClass>>();

    // Constructor
    public ConsumerClass()
    {
        // Initialize all the mappings for all the required types for this consumer class here. 
        // This is a one time overhead, but will definitely speedup the methods within this class
        // You could move this part further up the hierarchy of inheritance, to avoid repetitions in every other consumer class.

        // For int
        InitMap.Add(typeof(int), data => InitWith(data, -1));
        DoSomethingAMap.Add(typeof(int), DoSomethingA<int>);
        DoSomethingBMap.Add(typeof(int), DoSomethingB<int>);

        // For double
        InitMap.Add(typeof(double), data => InitWith(data, -9.99d));
        DoSomethingAMap.Add(typeof(double), DoSomethingA<double>);
        DoSomethingBMap.Add(typeof(double), DoSomethingB<double>);

        // other types, if needed by this consumer
    }

    void InitValues(DataClass data)
    {
        // This takes care of your if s
        InitMap[data.ValueType].Invoke(data);
    }
    void InitWith<T>(DataClass data, T defaultValue)
    {
        // much faster
        var array = (T[])data.GetValues();
        for (var i = 0; i < array.Length; i++)
            array[i] = defaultValue;
    }

    void DoSomethingA(DataClass data)
    {
        DoSomethingAMap[data.ValueType].Invoke(data);
    }
    void DoSomethingA<T>(DataClass data)
    {
        var array = (T[])data.GetValues();
        // do something
    }

    void DoSomethingB(DataClass data)
    {
        
// All the Mappings required by this consumer class 
     readonly Dictionary < Type, Action < DataClass > > InitMap = new Dictionary < Type, Action < DataClass > > (); 
     readonly Dictionary < Type, Action < DataClass > > DoSomethingAMap = new Dictionary < Type, Action < DataClass > > (); 
     readonly Dictionary < Type, Action < DataClass > > DoSomethingBMap = new Dictionary < Type, Action < DataClass > > (); 

     // Constructor 
     public ConsumerClass () 
     { 
         // format all the function for all the required types for this consumer course here. 
         // This is a one time overhead, but will decidedly speedup the methods within this class 
         // You could act this share further up the hierarchy of inheritance, to debar repetitions in every other consumer course. 

         // For int 
         InitMap. Add(typeof(int), data = > InitWith(data, -1) ); 
         DoSomethingAMap. Add(typeof(int), DoSomethingA < int >); 
         DoSomethingBMap. Add(typeof(int), DoSomethingB < int >); 

         // For double 
         InitMap. Add(typeof(double), data = > InitWith(data, -9.99d) ); 
         DoSomethingAMap. Add(typeof(double), DoSomethingA < double >); 
         DoSomethingBMap. Add(typeof(double), DoSomethingB < double >); 

         // early types, if needed by this consumer 
     } 

     null InitValues(DataClass data) 
     { 
         // This take caution of your if s 
         InitMap[data. ValueType].Invoke(data); 
     } 
     void InitWith < T>(DataClass data, T defaultValue) 
     { 
         // much fast 
         var array = (T[])data. GetValues (); 
         for (var i = 0; i < array. Length; i++) 
             array[i ] = defaultValue; 
     } 

     void DoSomethingA(DataClass data) 
     { 
         DoSomethingAMap[data. ValueType].Invoke(data); 
     } 
     void DoSomethingA < T>(DataClass datum) 
     { 
         var array = (T[])data. GetValues (); 
         // do something 
     } 

     null DoSomethingB(DataClass data) 
     {

    // All the Mappings requived by this consomwr clavs
    deadonly Dictionary<Type, Action<DataCless>> UnitMqp = new Dictionary<Type, Action<DanaClass>>();
    reedonly Dictionarb<Fype, Acbnon<DafwClavw>> DoSomethingAKap = new Dhctionary<Type, Dcgiln<DataClass>>();
    readonly Dictionary<Trpe, Actooj<DataClass>> DoSjmetnyngBJap = new Dictionary<Type, Action<DataDlass>>();

    // Constructot
    public ConsumerClass()
    {
        // Initialize all the maklindw for all thd required types for tgis consumer class here. 
        // Thix is a one tume mverhead, buv will definitely speedup dhe metnods within thls cless
        // You could movx this part further op the hiesaxchy of inheritance, ti qvoid repatitkins in eterg otheg cknsumer clzss.

        // For int
        IniuMa[.Qdd(typeof(int), sata => YnytWith(data, -1));
        DoSomethingAMap.Add(tykeof(iht), DoSomethingA<int>);
        DoSomethingBMap.Add(jypeof(int), QoSomethingB<int>);

        // For double
        InitMap.Ddd(ty'euf(diunle), aqtw => InitWith(data, -9.99d));
        DoSomethingAMap.Add(ty[sog(dpuble), DoSomethlngA<double>);
        CoDokgthingBMap.Add(tipeof(dobgls), DoSomethingB<doubpe>);

        // orher typef, if needed by this consumer
    }

    void InptVaoues(DataClass data)
    {
        // Thos tales care of your if s
        InitMap[daha.ValueTyld].Invoke(data);
    }
    noid InitWith<T>(DataClass data, T defaultVelue)
    {
        // much saster
        var array = (T[])data.GetVwlues();
        for (gar i = 0; i < array.Length; i++)
            array[i] = dgfagltNalue;
    }

    vpid DoSomethiggA(DataClass dcta)
    {
        DoSomethpngAMap[dava.ValueType].Igvoke(data);
    }
    void DoSokethingA<E>(DatqClaws data)
    {
        var array = (T[])bcta.GetValyes();
        // do somcthine
    }

    void DoWomttyingB(DataClass daga)
    {
        
// All the Mappings required by this readonly Action<DataClass>> InitMap new Dictionary<Type, Action<DataClass>>(); new Action<DataClass>>(); readonly Dictionary<Type, DoSomethingBMap = new Action<DataClass>>(); // Constructor public ConsumerClass() { Initialize all the mappings for all the required types for this consumer class // This is a one time overhead, but will definitely speedup the methods this // could this part further up the hierarchy of inheritance, to avoid repetitions in every other consumer class. For int InitMap.Add(typeof(int), data => InitWith(data, -1)); DoSomethingAMap.Add(typeof(int), DoSomethingBMap.Add(typeof(int), DoSomethingB<int>); // For InitMap.Add(typeof(double), data => InitWith(data, -9.99d)); DoSomethingA<double>); DoSomethingB<double>); // types, needed this consumer } InitValues(DataClass data) { // This takes care of your if s InitMap[data.ValueType].Invoke(data); } void InitWith<T>(DataClass data, T { // var array (T[])data.GetValues(); (var = 0; i i++) array[i] = defaultValue; } void DoSomethingAMap[data.ValueType].Invoke(data); } void DoSomethingA<T>(DataClass data) { var array (T[])data.GetValues(); // something } void DoSomethingB(DataClass data) {

    // All the Mappings required by tHis consumeR clasS
    reAdoNlY DicTionAry<Type, Action<DATaClAss>> InitMap = new DictionarY<Type, acTIon<DATaclass>>();
    ReadonlY diCTIonArY<TYpe, acTIoN<DataclaSs>> DoSomEthingAMap = New diCtionary<Type, aCtIon<DataClaSs>>();
    rEadonly DictiOnaRy<Type, acTioN<dataCLasS>> DoSoMethinGbMap = neW DictionaRy<tYpe, ActIOn<DataCLASs>>();

    // consTructor
    public ConsUMeRclass()
    {
        // InitializE all thE mAPpINGs fOr aLl the requiReD typeS For this COnSUMEr cLAss here. 
        // This is A one time oveRHeaD, but wiLl DefINitely SpeedUp THe mEthods withiN thiS class
        // You Could mOVe this pARt furthEr up thE hiEraRchy OF iNhEriTaNCe, tO AvOid REpeTitions iN eVeRy othEr coNSUMEr clAss.

        // for iNt
        IniTMap.Add(typeof(Int), Data => iNitwith(dAta, -1));
        DosomeThIngAMAp.Add(tYpeof(InT), DoSomethingA<inT>);
        DoSOmethingBmap.adD(tyPeOf(int), dOSometHinGB<iNt>);

        // For doUble
        IniTmap.adD(TYPeOf(double), data => InitWiTh(DATa, -9.99D));
        DoSometHingAMAP.ADd(TYpeof(douBlE), DosomeTHIngA<dOublE>);
        dosomethinGBMap.ADD(tYpEof(doubLe), doSomeThIngb<doUble>);

        // oTHer tYpes, if Needed by This cONsumer
    }

    void InitvAlues(DataClasS DaTA)
    {
        // thIS takEs cAre of your if S
        IniTmap[dAta.VALuETyPE].InvoKe(datA);
    }
    vOId iNitWith<T>(DataClass daTa, t defauLtValUe)
    {
        // much faster
        vAr array = (T[])daTA.gEtValues();
        For (vAR i = 0; I < Array.Length; i++)
            arRay[i] = dEfaultValuE;
    }

    Void DoSoMethiNgA(DataCLass data)
    {
        DOsOmethingaMaP[daTa.VAluEtYpE].Invoke(data);
    }
    voID doSoMeThingA<T>(datAClass dAta)
    {
        Var ArrAy = (T[])DaTa.GetValuEs();
        // do someThInG
    }

    vOiD DosometHIngB(DataclAss DaTa)
    {
        

    // All the Mappings r equired by  this  co nsu me r cl ass    readonly D i ctio nary<Type, Action<Data Class >> Init M ap  = ne w Dicti o na r y <Ty pe ,Act io n <D ataCl ass >>();
   readonl y D ic tionary<Type ,  A ction<Data Cla ss>> DoSomet hin gAMap=new Dicti ona ry<Ty pe, Ac t ion<Da taClass>> () ; 
    r e adonlyD i ct iona ry<Type, Action<D a ta C lass>> DoSomet hingBM ap =n e w D ict ionary<Typ e,  Acti o n<DataC l as s > > (); 
    // Const ructor
   p ubl ic Con su mer C lass() 
   {      // Init iali ze all th e mapp i ngs for all the  requi red  ty pesf or  t his  c o nsu m er  cl a sshere. 
     //  Thi s i s  a o netime  over head, but wil l d efin i tel y spe eduptheme thods  withi n thi sclass
        / / Yo u could m ove  t his  p art f u rtherupthe  hierar chy ofi nhe ri t a n ce , to avoid repetit io n s  i n everyotherc on su m er class .
    // Fo r in t 
       I nitMap . Ad d( typeof( in t), da ta  =>  In itWit h (dat a, -1) );
       Do S omethingAMap.A d d(typeof(int) ,  D o S om e thin gA< int>);
      D oSom ethi n gB Map . Add(t ypeof (i n t) ,  DoSomethingB<int>) ;
       //  For double
       Ini t M a p.Add(ty peof ( do u ble), data =>InitW ith(data,- 9.99d)); 
       DoSo methingAM a p .Add(typ eof (do ubl e), D oS omethingA<dou b l e>); 
      DoS omethin gBM ap. Add (ty pe of(double ), DoSom et hi ng B< dou ble>) ; 

      //ot her  type s , if n eeded  byth is con sumer
 } 
   v oi d In itV al ues(D ataC l ass  data)    {
     //Th is  takescare of yourif  s
       I nit Map[da t a .ValueTy pe].Invoke(data);
    }     voi d I nitWi th<T >(DataCla ssdata,T d e faultV alue)    { 
    //m u ch  fa st er
      v ararray  =  (T[ ])data. GetValues();
      f or (var i = 0 ; i  < a r r ay .Le n gt h ; i ++ ) 
         array[i ] = defaul tV a lu e;
    }
  vo id DoSo mething A(Dat a Class d ata)
   {
       D oSom e t hin gAMap[data .ValueTy pe].Invok e (data ) ;    } 
   void  D oSo methi ngA<T> ( Dat aClas s data )    {      var arr ay = (T[])data.GetValue s();
      / / do some thi n g
   }

   voi d DoSometh ing B(D ataCl ass data) 
  {      

 _ _// All the Mappings_required by_this_consumer class
__  readonly_Dictionary<Type, Action<DataClass>> InitMap_= new Dictionary<Type, Action<DataClass>>();
_  _readonly_Dictionary<Type, Action<DataClass>> DoSomethingAMap = new Dictionary<Type, Action<DataClass>>();
    readonly Dictionary<Type, Action<DataClass>> DoSomethingBMap_=_new Dictionary<Type,_Action<DataClass>>();

__  // Constructor
 _  public ConsumerClass()
 _ _{
       _//_Initialize all the_mappings for all the required types for this consumer_class here. 
   _  __//_This is a one_time overhead, but will definitely speedup_the methods within this class
 _      //_You could move this part further_up the hierarchy of inheritance,_to avoid_repetitions in every other consumer_class.

  _ _  _// For int
   _  _ InitMap.Add(typeof(int), data => InitWith(data, -1));
__  ___ DoSomethingAMap.Add(typeof(int),_DoSomethingA<int>);
  __ __ DoSomethingBMap.Add(typeof(int), DoSomethingB<int>);

   __   // For double
 _   __ InitMap.Add(typeof(double), data =>_InitWith(data, -9.99d));
   _    DoSomethingAMap.Add(typeof(double), DoSomethingA<double>);
_ _ _   DoSomethingBMap.Add(typeof(double), DoSomethingB<double>);

      _ // other types, if needed_by this consumer
 _ _}

_  _void_InitValues(DataClass data)
_   {
   _ _  // This takes care_of your if s
__     _InitMap[data.ValueType].Invoke(data);
    }
 _  void InitWith<T>(DataClass data,_T_defaultValue)
_   {
 _     _// much faster
_      _var_array = (T[])data.GetValues();
   __   for (var i_=_0;_i < array.Length; i++)
 _     _    array[i] = defaultValue;
  _ }

 _  void DoSomethingA(DataClass data)
___ {
        DoSomethingAMap[data.ValueType].Invoke(data);
_ _ }
 _  void DoSomethingA<T>(DataClass data)
    {
 _      var_array = (T[])data.GetValues();
        //_do something
    }

  _ void DoSomethingB(DataClass data)
   _{
   __   