-Code reformat

This commit is contained in:
James Newton-King
2013-10-20 15:08:39 +13:00
parent d03963016e
commit bcd6982419
466 changed files with 71645 additions and 71598 deletions
@@ -7,50 +7,50 @@ using Newtonsoft.Json.Linq;
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
{
public class DeserializeWithLinq
{
#region Types
public class BlogPost
public class DeserializeWithLinq
{
public string Title { get; set; }
public string AuthorName { get; set; }
public string AuthorTwitter { get; set; }
public string Body { get; set; }
public DateTime PostedDate { get; set; }
}
#endregion
public void Example()
{
#region Usage
string json = @"[
#region Types
public class BlogPost
{
'Title': 'Json.NET is awesome!',
'Author': {
'Name': 'James Newton-King',
'Twitter': '@JamesNK',
'Picture': '/jamesnk.png'
},
'Date': '2013-01-23T19:30:00',
'BodyHtml': '<h3>Title!</h3>\r\n<p>Content!</p>'
public string Title { get; set; }
public string AuthorName { get; set; }
public string AuthorTwitter { get; set; }
public string Body { get; set; }
public DateTime PostedDate { get; set; }
}
]";
#endregion
JArray blogPostArray = JArray.Parse(json);
IList<BlogPost> blogPosts = blogPostArray.Select(p => new BlogPost
public void Example()
{
Title = (string) p["Title"],
AuthorName = (string) p["Author"]["Name"],
AuthorTwitter = (string) p["Author"]["Twitter"],
PostedDate = (DateTime) p["Date"],
Body = HttpUtility.HtmlDecode((string) p["BodyHtml"])
}).ToList();
#region Usage
string json = @"[
{
'Title': 'Json.NET is awesome!',
'Author': {
'Name': 'James Newton-King',
'Twitter': '@JamesNK',
'Picture': '/jamesnk.png'
},
'Date': '2013-01-23T19:30:00',
'BodyHtml': '&lt;h3&gt;Title!&lt;/h3&gt;\r\n&lt;p&gt;Content!&lt;/p&gt;'
}
]";
Console.WriteLine(blogPosts[0].Body);
// <h3>Title!</h3>
// <p>Content!</p>
#endregion
JArray blogPostArray = JArray.Parse(json);
IList<BlogPost> blogPosts = blogPostArray.Select(p => new BlogPost
{
Title = (string)p["Title"],
AuthorName = (string)p["Author"]["Name"],
AuthorTwitter = (string)p["Author"]["Twitter"],
PostedDate = (DateTime)p["Date"],
Body = HttpUtility.HtmlDecode((string)p["BodyHtml"])
}).ToList();
Console.WriteLine(blogPosts[0].Body);
// <h3>Title!</h3>
// <p>Content!</p>
#endregion
}
}
}
}
}