I successfully implemented the answer on this question. However, it does not work when I have a List. When I ran this through, here's what I got back:
AccountDataResult: 'AccountFound'
AccountList: 'CustomWebService.TestApplication.ServiceMethods.CustomClassOutputData+DataList[]'
This list has X items inside and I need to list out all of the properties for each one. What is the best method to achieve this?
Here is what I have today:
void AddPropertiesToTextbox(object output, TextBox txt)
{
PropertyInfo[] piData = null;
piData = Utility.GetPublicProperties(output.GetType());
foreach (PropertyInfo pi in piData)
{
if (pi.Name.ToLower() != "extensiondata")
{
textResult.Text += string.Format("{0}: '{1}'", pi.Name, pi.GetValue(output, null));
textResult.Text += Environment.NewLine;
}
}
}
Here is my web service Model:
[DataContract]
public class OutputData
{
[DataContract]
public class AccountData
{
[DataMember]
public string AccountStatus { get; set; }
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
}
[DataContract]
public enum AccountDataResults
{
[EnumMember]
None,
[EnumMember]
AccountFound,
[EnumMember]
NoAccounts
}
[DataMember]
public List<AccountData> DataList { get; set; }
[DataMember]
public AccountDataResults AccountDataResult { get; set; }
}