static Program() { s_userContract = new JsonContract <User>(); s_userContract.SimpleProperty(u => u.UserName).Name("Name"); s_userContract.SimpleProperty(u => u.Age); s_postContract = new JsonContract <Post>(); s_postContract.SimpleProperty(p => p.Title); s_postContract.SimpleProperty(p => p.CreateTime).Converter(new DataTimeConverter()); s_categoryContract = new JsonContract <Category>(); s_categoryContract.SimpleProperty(p => p.Name); s_categoryContract.ComplexProperty(p => p.Author).Contract(s_userContract); s_categoryContract.ArrayProperty(p => p.Posts).ElementContract(s_postContract); }
static Program() { s_userContract = new JsonContract<User>(); s_userContract.SimpleProperty(u => u.UserName).Name("Name"); s_userContract.SimpleProperty(u => u.Age); s_postContract = new JsonContract<Post>(); s_postContract.SimpleProperty(p => p.Title); s_postContract.SimpleProperty(p => p.CreateTime).Converter(new DataTimeConverter()); s_categoryContract = new JsonContract<Category>(); s_categoryContract.SimpleProperty(p => p.Name); s_categoryContract.ComplexProperty(p => p.Author).Contract(s_userContract); s_categoryContract.ArrayProperty(p => p.Posts).ElementContract(s_postContract); }