Lets say I have an item
, which has fields(properties)
And I have 10-15 items>
I’d use web.config and store this in app settings area and then create one class that will read these retrieve it as a list.
Here is how it could look in web config and C# code.
public class SomeClass
{
private string location;
private double avgValue;
private int usability;
public string Location
{
get { return location; }
set { location = value; }
}
public double AvgValue
{
get { return avgValue; }
set { avgValue = value; }
}
public int Usability
{
get { return usability; }
set { usability = value; }
}
}
public class Config
{
public static List Items
{
get
{
List result = new List();
for (int i = 1; i <= Convert.ToInt32(WebConfigurationManager.AppSettings["count"]); i++)
{
SomeClass sClass = new SomeClass();
sClass.AvgValue = Convert.ToDouble(WebConfigurationManager.AppSettings["avgValue_" + i.ToString()]);
sClass.Location = WebConfigurationManager.AppSettings["location_" + i.ToString()];
sClass.Usability = Convert.ToInt32(WebConfigurationManager.AppSettings["usability_" + i.ToString()]);
}
return result;
}
}
}