mardi 29 décembre 2015

Best way to refactor If-statement

I have the following code:

                            if (adSetting.Core_standard_application_role)
                            {
                                rc = new IntegrationRoleCompany();
                                rc.RoleCompany = firmSettings.FirmNo.ToString();
                                rc.RoleName = "Core standard application role";
                                rcList.Add(rc);
                            }
                            if (adSetting.Expense_Invoice_Application_Access)
                            {
                                rc = new IntegrationRoleCompany();
                                rc.RoleCompany = firmSettings.FirmNo.ToString();
                                rc.RoleName = "Expense Invoice Application Access";
                                rcList.Add(rc);
                            }

The problem is that I have 20 if-checks where I check addSetting.Property. Now to the question:

What is the best and most effective way to refactor this if-statements?

Aucun commentaire:

Enregistrer un commentaire