public static void AddUserParam(NameValueCollection parameters, UserParameters userParams)
{
PropertyInfo[] pic = userParams.GetType().GetProperties();
UserAttribute name;
foreach (PropertyInfo pi in pic)
{
object value = pi.GetValue(userParams, null);
bool include = false;
if (value != null)
{
string typeName = value.GetType().Name;
switch (typeName)
{
case "String":
name = (UserAttribute)UserAttribute.GetCustomAttribute(pi, typeof(UserAttribute));
parameters.Add(name.Name, pi.GetValue(userParams, null).ToString());
break;
case "List`1":
name = (UserAttribute)UserAttribute.GetCustomAttribute(pi, typeof(UserAttribute));
if (name.Name == "education[]")
{
List<UserEducation> edl = (List<UserEducation>)pi.GetValue(userParams, null);
foreach (UserEducation pc in edl)
parameters.Add(name.Name, pc.School + "," + pc.Degree + "," + pc.Description + "," + pc.StartYear + "," + pc.EndYear);
}
else if (name.Name == "previous_companies[]")
{
List<PreviousCompany> pcl = (List<PreviousCompany>)pi.GetValue(userParams, null);
foreach (PreviousCompany pc in pcl)
parameters.Add(name.Name, pc.Company + "," + pc.Position + "," + pc.Description + "," + pc.StartYear + "," + pc.EndYear);
}
break;
default:
include = false;
break;
}
}
}
}