mardi 15 décembre 2020

Suggest architectural/design pattern in C#

I have a list of BaseClauses which returns ==> Clauses Types ClauseA, ClauseB, ClauseC and baseClauseList and its type are from DLL

List<BaseClause> baseClauseList = DLL.SomeMethod();

String theExpectedResult;

foreach (var clause in baseClauseList)
{
    // Need to run some logic depends on clause type
    // each clause will returns some value/values (type of object/s)
    // get those value/values and form a string 
}

what is the best approach to do this (by avoiding multiple ifs and switch to cast to derived type)

Aucun commentaire:

Enregistrer un commentaire