using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public enum ErrorDisplayType : int
private string errorCode;
private ErrorDisplayType errorDispType;
get { return this.errorCode; }
this.setFields(errorCode);
public ErrorDisplayType ErrorDispType
get { return this.errorDispType; }
set { this.errorDispType = value; }
private void setFields(string errorCode)
public class ErrorDTO : IEnumerator, IEnumerable
private List<ErrorObj> errorList;
public List<ErrorObj> ErrorList
get { return this.errorList; }
set { this.errorList = value; }
this.errorList = new List<ErrorObj>();
if (indx < errorList.Count - 1)
if (errorList.Count == 0 || indx < 0 || indx > errorList.Count - 1)
return this.errorList[indx];
public IEnumerator GetEnumerator()
return (IEnumerator)this;
public int Add(ErrorObj error)
this.errorList.Add(error);
public static void Test()
public static string GetJson()
ErrorDTO errDTO = new ErrorDTO();
ErrorObj errObj = new ErrorObj();
errObj.ErrorCode = "ABCD125";
errObj.ErrorDispType = (ErrorDisplayType)int.Parse("1");
string json = Newtonsoft.Json.JsonConvert.SerializeObject(errDTO);
public static void Main()
string json = TestClass.GetJson();
ErrorDTO resultDTO = new ErrorDTO();
Newtonsoft.Json.JsonConvert.PopulateObject(json, resultDTO);
Console.WriteLine("Failed with unhandled exception: ");