Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to make code more generic
Message
 
 
À
Tous
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Titre:
Trying to make code more generic
Divers
Thread ID:
01667539
Message ID:
01667539
Vues:
55
Hi everybody,

I have the following code right now:
 JavaScriptSerializer js = new JavaScriptSerializer();
                    var itp = js.Deserialize<List<RetailItemsToPrint>>(formValues["itemsToPrint"].ToString());

                    if (itp == null)
                    {
                        labels.AlertType = "error";
                        labels.AlertMessage = Messages.noItemsToPrint;
                    }
                    else
                    {
                        // Here we may need different methods for different types of labels
                        // This currently works for retail labels only
                        RetailItemsToPrintCollection itemsToPrint = new RetailItemsToPrintCollection();
                        itemsToPrint.AddRange(itp);

                        List<ReportData> gatherData = _reportsRepository.GatherRetailLabelsData(itemsToPrint);
                        List<ReportDataSource> reportData = new List<ReportDataSource>();
                        if (gatherData != null)
                        {
                            foreach (ReportData rd in gatherData)
                            {
                                ReportDataSource rds = new ReportDataSource(rd.Name, rd.Data);
                                reportData.Add(rds);
                            }
                        }
                        labels.ReportData = reportData;
                    }
I'm trying to figure out how to change it to allow different types of labels. I added a new type RentalItemsToPrint, so when my labelType=="Rental" I need to have different type for itp, etc.

Do you know how to change this code to allow for different types?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform