public ResistorColorCodesProvidor() { string _filePath = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory.Replace(".UnitTests\\bin", "")) + ".Provider\\Content\\ColorCodes.xml"; XmlSerializer deserializer = new XmlSerializer(typeof(Models.ResistorColorCodes)); using (TextReader textReader = new StreamReader(_filePath)) { resistorcolorCodes = (Models.ResistorColorCodes)deserializer.Deserialize(textReader); } }
private void GetdropdownValues() { List <SelectListItem> test = new List <SelectListItem>(); Models.ResistorColorCodes resistorcolorCodes = null; ResistorColorCodesProvidor provider = new ResistorColorCodesProvidor(); resistorcolorCodes = provider.resistorcolorCodes; List <SelectListItem> items = (from code in resistorcolorCodes.ColorCodes where !string.IsNullOrEmpty(code.SignificantFigues) select new SelectListItem { Text = code.Color, Value = code.Color.ToString(), Selected = true }).ToList(); ViewBag.ColorA = items; ViewBag.ColorB = items; items = (from code in resistorcolorCodes.ColorCodes where !string.IsNullOrEmpty(code.Multiplier) select new SelectListItem { Text = code.Color, Value = code.Color.ToString(), Selected = true }).ToList(); ViewBag.colorC = items; items = (from code in resistorcolorCodes.ColorCodes where !string.IsNullOrEmpty(code.Tolerance) select new SelectListItem { Text = code.Color, Value = code.Color.ToString(), Selected = true }).ToList(); ViewBag.colorD = items; }