using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.ComponentModel;
using System.Globalization;
using System.Collections.Specialized;
using System.Web.Routing;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Runtime.Serialization.Formatters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public enum CsControlType
public Guid Id { get; set; }
public Guid CustomerId { get; set; }
[JsonProperty(ItemTypeNameHandling = TypeNameHandling.All)]
public IList<Control> Controls { get; set; }
public class Control : ControlBase
public override Enums.CsControlType CsControlType { get { return Enums.CsControlType.Base; } }
public abstract class ControlBase
public Guid Id { get; set; }
public abstract Enums.CsControlType CsControlType { get; }
public string PropertyName { get; set; }
public IList<int> Width { get; set; }
public string FriendlyName { get; set; }
public string Description { get; set; }
public class OptionsControl : Control
public override Enums.CsControlType CsControlType { get { return Enums.CsControlType.OptionsControl; } }
public IDictionary<string, string> Options;
public static void Test()
Controls = new List<Control>()
Options = new Dictionary<string, string>() { { "TN", "TN "} },
PropertyName = "addresses[0].state",
Width = new List<int> { 2, 2, 6 },
var old = JsonConvert.DefaultSettings;
var json = JsonConvert.SerializeObject(page, Formatting.Indented);
JsonConvert.DefaultSettings = old;
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("Json.NET version: " + typeof(JsonSerializer).Assembly.FullName);