Link post for June

July 2nd, 2009

This months list of devs to follow (the GAC pack edition)

W.O.M.M. #4 – Asp MVC Route Attributes

June 22nd, 2009

Download the source code mentioned in this blog post.

works-on-my-machine-starburst

A few weeks ago on the StackOverflow podcast, something Jeff said got me thinking. Jeff was discussing how the stackoverflow team implemented their route mappings:


Those routes are… the way we implemented them are actually like decorators. Attributes on the methods. - Jeff Atwood (stackoverflow episode #54)

This instantly piqued my interest and I completely zoned out for the rest of the podcast: caught up in working out the details of how I could do this for my own Asp.net MVC projects.

Coming up with the actual attribute code was easy; writing the code to set up all the Routes using only data defined in by the attribute was tricky.

Being new to attributes, and reflection in general, it took me a few hours until I had a very basic demo working. However, I was really starting to like where it was going.

As a side note: There are lot of “helper” classes and objects in the route attribute project (it feels cluttered to me) and the reason I did this was to make the code in AssemblyExtensions.GetRoutes() easier to read.

After a few nights of Mtn Dew and convenience-store cherry-pie I finished the rough code, tests and demo project (included in this blog post) and I was starting to realize that:

  1. Using the attributes is more declaritive and it feels cleaner
  2. Having your route information right above your actions is incredibly useful
  3. I had no more need to switch back and forth between your controller and the Global.asax.cs

How does it work?

All of the real work for the RouteAttribute is done in the AssemblyExtensions class. This class uses extension methods to augment the System.Reflection.Assembly class with two methods: GetControllers() and GetRoutes().

GetRoutes is the only method that is used by other classes, I made GetControllers public for unit testing.

GetRoutes()

GetRoutes’ first order of business is to make a list of data that it will need to build out all the routes for the assembly it was passed. After thats done GetRoutes will loop through the collected route data, build up each route and add it to the dictionary that will eventually be returned.


namespace CodeImpossible.Mvc.Routing
{
    public static class AssemblyExtensions
    {

        public static BindingFlags ActionFlags =
            BindingFlags.Instance |
            BindingFlags.Public |
            BindingFlags.DeclaredOnly;

        public static IList<ControllerMetaData> GetControllers(this Assembly assembly)
        {
            var controllers = assembly.GetTypes().ToList().FindAll(type =>
            {
                var isValidController = type.IsClass &&
                    type.IsPublic &&
                    type.IsSubclassOf<Controller>();

                var hasValidActions = type.GetMethods(ActionFlags).ToList().Any(m =>
                {
                    var valid = false;
                    if (m.ReturnParameter != null && m.ReturnParameter.ParameterType == typeof(ActionResult))
                    {
                        valid = m.GetAttributesOfType<RouteAttribute>().Count > 0;
                    }

                    return valid;
                });

                return isValidController && hasValidActions;
            }).Select<Type, ControllerMetaData>((t) => new ControllerMetaData(t)).ToList();

            return controllers;
        }

        public static IDictionary<string, Route> GetRoutes(this Assembly assembly)
        {
            var Routes      = new Dictionary<string, Route>();

            var data = (from c in assembly.GetControllers()
                        from a in c.GetActions()
                        from r in a.Data
                        select new
                        {
                            ControllerName = c.Name,
                            ActionName = a.Name,
                            RouteData = r,
                            RouteParams = a.Params
                        }).ToList();

            foreach (var r in data)
            {
                var route               = new Route(r.RouteData.RoutePath, new MvcRouteHandler());
                route.Constraints       = new RouteValueDictionary();
                route.Defaults          = new RouteValueDictionary(new {
                    controller = r.ControllerName,
                    action = r.ActionName
                });

                if (r.RouteData.RequireRouteParams && r.RouteParams.Count() == 0)
                {
                    throw new MissingRouteParameterException("Unknown", r.RouteData.RoutePath);
                }

                var missingParams = new List<ParameterMetaData>();

                if (r.RouteData.RequireRouteParams)
                {
                    missingParams = (from p in r.RouteParams
                                     where r.RouteData.RoutePath.IndexOf("{" + p.Name + "}") == -1
                                     select p).ToList();
                }

                if (missingParams.Count > 0)
                {
                    var param = missingParams.First();
                    throw new MissingRouteParameterException(param.Name, r.RouteData.RoutePath);
                }

                foreach (var param in r.RouteParams)
                {
                    if (param.Data != null)
                    {
                        if (param.Data.DefaultValue != null)
                        {
                            route.Defaults.Add(param.Name, param.Data.DefaultValue);
                        }

                        if (param.Data.Constraint != null)
                        {
                            route.Constraints.Add(param.Name, param.Data.Constraint);
                        }
                    }
                }

                Routes.Add(r.RouteData.Name ?? r.RouteData.RoutePath, route);
            }

            return Routes;
        }
    }
}

Getting the Routes into the RouteTable

Slapping route attributes onto your classes and methods is all well and good but it doesn’t mean anything unless we can get those routes into the RouteTable object easliy. Originally I had the code to add the routes looking something like


var routes = Assembly.GetCurrentExecutingAssembly().GetRoutes();

routes.ForEach(r => RouteTable.Add(r));

This, although pretty easy, wasn’t as readible as I wanted. So I added some extension methods to the RouteTable class:


RouteTable.Routes.IncludeRoutesFromAssembly();

I think both of these are much clearer than doing:


RouteTable.Routes.MapRoute("Root",
    "",
    new { controller = "Test", action = "GetItem", id = 1 });

RouteTable.Routes.MapRoute("Search",
    "Search/{id}",
    new { controller = "Test", action = "Search", id = 1 });
//.. SNIP ...

Using the RouteAttribute and RouteParamAttribute

In the controller “TestController” below there are three actions: Index, FindByText, and GetItem. Using the RouteAttribute and RouteParamAttribute makes it pretty clear that the routes for FindByText and GetItem are the same but use different RouteContraints.

So a request for /Test/Search/Hello will go to FindByText while /Test/Search/1 will go to GetItem. Also notice how GetItem has a default value of 2 for the id argument.


public class TestController : Controller
{

    [Route(RoutePath = "Test")]
    public ActionResult Index()
    {

        return View();
    }

    [Route(RoutePath = "Test/Search/{query}")]
    public ActionResult FindByText(
        [RouteParam(Constraint="[a-zA-Z]{1,}")]
        string query)
    {

        return View();
    }

    [Route(RoutePath = "Test/Search/{id}")]
    public virtual ActionResult GetItem(
        [RouteParam(Constraint=@"\d{1,}", DefaultValue=2)]
        int id)
    {

        return View();
    }
}

There is support for binding multiple routes to the same action; just add another Route attribute:


[Route("Products/Search/{id}")]
[Route("Products/{id}")]
public ActionResult GetProductById(int id)
{
    return View();
}

Downsides or things I haven’t gotten to yet

Just some gotchas that I think people might raise issue with.

All of your controllers must inherit from the System.Web.Mvc.Controller class
This isn’t really a big deal because if you are using Asp.net MVC then you really should inherit from the Controller class, but for those of you using FubuMVC or another MVC framework this should be easy to change.

Attributes can be ugly
I know a few people out there are against attributes but I think that this is a more than acceptable use because it made the code much easier to understand.

Reflection can be slow
Honestly, when I first started working on this demo I was sort of turned off by the use of Reflection myself. After weighing the possible performance loss against the gains in both readability and maintenance I decided this was definitely worth it. I haven’t performance tested this code so, as always YMMV.

As always, if I screwed up or there is a better way to do this, please let me know in the comments.

Download the source code mentioned in this blog post.

Link Post For May

May 31st, 2009

This months list of devs to follow (Herding Code edition):

Link Post for April

April 30th, 2009

So here it is, the end of another month and I wanted to post some interesting, and helpful links (mostly so I can find them again) as well as point out some interesting bloggers/twitterers (tweeters?) that you should be following if you aren’t already.

Bloggers you should read / follow if you aren’t already:

Debugging "Syntax Error" from a bad WebResource.axd request

April 24th, 2009

“Syntax Error, Line: 2, Char: 0″. How many of you out there have seen this error while working on a web project?

Usually it’s because of a forgotten semi-colon or parenthesis in some external javascript file. But sometimes it’s something more sinister… Something darker, dirtier and just a little bit more evil.

After seeing the error message, I opened up Internet Explorer’s options dialog and unchecked the following options:

  • Disable script debugging (Internet Explorer)
  • Disable script debugging (Other)

Internet Explorer Options Dialog

I then closed IE, returned to Visual Studio, stopped and re-started debugging (ctrl+shift+F5), and watched Solution Explorer as my page began to load.

Solution Explorer Debugging Internet Explorer

Oh! That’s not good. See the WebResource.axd request that has the same icon as the Default.aspx file? That means that a bad request was sent for an embedded resource and – most likely recieved a 404 page back instead of the javascript file, which caused our syntax error.

Ok, so how do we figure out which WebResource reference caused the problem? Well, the only way that I have come up with so far, is to manually copy and paste each WebResource.axd url from the html source of the page to the address bar and navigate there. The pages that give return a file download are ok and the ones that don’t will return a 404 page in the browser.

After finishing this long process of elimination, I found the resource request that was causing my headache:

/WebResource.axd?d=MaCiPhUUtdXNj16OOucV5e5lHCBZO...SNIP...

So how do we figure out which resource has embedded this troublesome URL into our html source? I found the solution to that in Irena Kennedy’s blog post on “How to Decrypt an ASP.NET Encrypted Data”:

Please note, that the code below should not be used in production code! It’s only meant for debugging and troubleshooting, and it may break in future versions of the .NET framework if DecryptString private method changes.

  1. Add a web page (e.g. DecryptData.aspx) to your web application. For the code to work, it must run in the same appdomain as the web application that created your encrypted string.
  2. Add a text box where you will type in the encrypted string.
  3. Add a label where you’ll display decrypted results.
  4. Add a button.
  5. In code-behind on button click event, add the following code:

System.Reflection.BindingFlags bf =
    System.Reflection.BindingFlags.NonPublic |
    System.Reflection.BindingFlags.Static;

System.Reflection.MethodInfo DecryptString =
    typeof(System.Web.UI.Page).GetMethod("DecryptString", bf);

DecryptedData.Text = DecryptString.Invoke(
    null,
    new object[] { EncryptedData.Text } ) as string;

After I created this page, I pasted the WebResource.axd URL (everything up to the &t=) into the DecryptedData textbox on my DecryptData.aspx page, clicked the Decrypt button, and saw that one of my custom aspx controls was responsible. I then corrected the resource path and the page loaded as it should.

See the screenshot below for an example of the DecryptData page, or download the DecryptData .ASPX and Codebehind from my box.net folder.

DecryptData page

Wordpress.com SyntaxHighlighter – How To Remove Indent

April 21st, 2009

I post a lot of source code on my blog and lately I’ve been having a lot of trouble trying to remove the left-padding from my source code blocks.

My problem comes from the SyntaxHighlighter stylesheet that WP.com uses and how it specifies the padding-left for the ordered-lists underneath the .dp-highlighter div tag:


.dp-highlighter ol
{
    list-style: decimal; /* for ie */
    background-color: #fff;
    margin: 0px 0px 1px 45px !important; /* problem */
    padding: 0px;
    color: #5C5C5C;
}

The use of the !important declaration is what is messing me up. The SyntaxHighlighter stylesheet is included at the end of the page html source and my custom css is at the top, so even though the SyntaxHighlighter styles have a lower higher css specificity – my styles will never override them because CSS is processed top-down.  from “CSS Introduction” @ w3schools:

What style will be used when there is more than one style specified for an HTML element?

Generally speaking we can say that all the styles will “cascade” into a new “virtual” style sheet by the following rules, where number four has the highest priority:

  1. Browser default
  2. External style sheet
  3. Internal style sheet (inside the <head> tag)
  4. Inline style (inside an HTML element)

So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style declared inside the <head> tag, in an external style sheet, or in a browser (a default value).

At this point I began thinking that it was pointless to try any more and that I should just accept that my code blocks would forever be indented by 45 pixels.

However, I’m way too stubborn to admit defeat, and after spending a night reading about css specificity and trying some crazy hacks of my own, I realized that my problem was simple. I just wanted the code to be farther to the left.

So my solution was equally simple (Occam’s Razor baby!): tell the outer container to allow overflow and position the child relatively and to offset it by the distance I wanted. I did this by applying to the outer div ( the “.dp-highlighter” div ) the following style:


DIV.dp-highlighter {
overflow:auto;
padding:10px;
}

And added this style to the OL tag within the .dp-highlighter div:


.dp-highlighter ol {
position:relative;
left:-45px;
}

W.O.M.M. weekly post #3 – HtmlHelper.Gravatar

April 18th, 2009

works-on-my-machine-starburstLong story short: I hate re-inventing the wheel. If there is a free service that does something I need I will try my hardest to get that service into whatever I am working on. I’m currently working on an Asp .Net MVC project that needs Avatars (you know, those funny little pictures next to peoples names on Twitter). Enter Gravatar.

Gravatar is an awesome service for anyone looking to add avatars to their apps. It’s free, incredibly simple to implement, and removes a lot of the hassle around getting avatar support into your web/windows app.

Adding Gravatar support to an application is pretty simple. Can you get a users email address? Can you MD5 said email address? Can you make an HTTP GET? BANG. You sir, or madam, can have Gravatars.

This week for the W.O.M.M. code sample I’d like to show how I integrated gravatar support into an Asp .Net MVC application.

How Gravatar Works In A Nutshell

Gravatar is a free service where you sign up and link images to one or more email addresses that you provide.

Once you link an image to an email address, any application that supports getting an image over the internet can show your Gravatar by making a request to a special URL. This URL is generated by combining an MD5 hash of your email address with some other parameters and the end result is a link to your Gravatar image.

IE: the link to my Gravatar on the right of this page is:


http://www.gravatar.com/avatar/15559d868ec27b8583f42116a6b96c14?s=140

So 15559d868ec27b8583f42116a6b96c14 is the hash of my email address – don’t worry it’s a one-way hash. The “s” parameter is the size of the image that I want, in this case 140 pixels.

That is pretty much it as far as how the system works, but if you want to read more, check out Gravatar’s implementation documentation.

The Goal

What I wanted was an HtmlHelper extension method that I could use in my view pages to create an IMG tag with the correct Gravatar URL. After looking at the documentation on Gravatars “How the URL is constructed” page, I decided my helper extension should support the following:

Avatar Size (the “s” parameter)
When making a Gravatar URL you can specify a specific size for the Gravatar image. The size can be anything from 1 to 512 pixels, but the default is 80.

Default Avatars (the “d” parameter)
If the email address you are using doesn’t have any Gravatars setup, Gravatar will generate one for you by default. You can choose from 3 predefined Gravatar types or you can include a URL to a custom avatar of your own. The predefined Gravatar types are Identicon, Wavatar, and Monsterid.

Rating (the “r” parameter)
This wasn’t a requirement for what I was working on, but you can designate the maximum “rating” of the avatars that Gravatar will generate. The accepted values are “g”, “pg”, “r”, and “x” and they are inclusive, so specifying “r” will allow “g” and “pg” rated Gravatars to be generated. Gravatars that are rated “x” will be returned as one of the predefined avatars above. The default rating is “g”.

The Code

Okay, so now I know what I need to support. Now it’s just a matter of getting the code to do this. Let’s take a look at the class file I used to get this done.


namespace System.Web.Mvc
{
    using System;
    using System.Web.Routing;
    using System.Web.Security;

    public enum GravatarDefaultTypes
    {
        Identicon,
        Wavatar,
        Monsterid,
        Custom
    }

    public static class GravatarExtension
    {
		public static string Gravatar(
			this HtmlHelper hh,
			string emailAddress,
			int size,
			GravatarDefaultTypes defaultType,
			string customImageUrl,
			RouteValueDictionary htmlAttributes)
        {
            var tagBuilder = new TagBuilder("img");
            string url = "http://www.gravatar.com/avatar/{0}?d={1}&s={2}";

	    // thanks to jon galloway for this one-liner!
            // http://www.eggheadcafe.com/aspnet/how-to/141740/adding-gravatars-to-your.aspx
            string hash = FormsAuthentication
				.HashPasswordForStoringInConfigFile(emailAddress, "MD5");
            string defImg = defaultType.ToString().ToLower();

            if (defaultType == GravatarDefaultTypes.Custom)
            {
                defImg = System.Web
					.HttpUtility
					.UrlEncode(customImageUrl);
            }

            url = String.Format(
                url,
                hash.ToLower(),
                defImg,
                size.ToString());

            tagBuilder.MergeAttributes(htmlAttributes);
            tagBuilder.MergeAttribute("src", url);

            return tagBuilder.ToString(TagRenderMode.Normal);
        }
    }
}

So you can see I’m not storing the hash of the email address, instead I am going to pass in the unaltered string. I didn’t want to have another piece of data to update when the user changed their email address so the Gravatar() method takes an email address and encodes it using a call to FormsAuthentication.HashPasswordForStoringInConfigFile(), which is awesome ( Thanks Jon, you rock!).

Also, I’m not sure if this is a no-no or what, but I did put the extension class under the System.Web.Mvc namespace. This was mainly a convenience (read: laziness) thing and can be easily changed.

Alright so we have some code now, let’s take a look at how it can be used in our views.


    <%= Html.Gravatar(
        	Model.Email, // the email address
        	50, // size, in pixels of the avatar
        	GravatarDefaultTypes.Identicon,
        	null,
        	new RouteValueDictionary(new {
        		style = "vertical-align: middle;"
        	})
    )%> 
     <%= Model.UserName %> 

Let’s see how that looks.

user-avatar

Booyah, avatar support in 55 lines of code. As always, if I screwed up or there is a better way to do this, please let me know.

W.O.M.M. weekly post #2

April 10th, 2009

works-on-my-machine-starburstDue to me being insanely sick this week I’m going to be changing up the format for the Works On My Machine weekly project post for this week.

Instead of presenting a project that I’ve worked on I’d like to highlight some .Net OSS projects / source code that I’ve been working with / looking at lately.

 

  • The More Linq project – An extension library for LinqToObjects run by Jon Skeet.
  • MusikCube – Awesome music player that uses SqlLite to allow “smart playlists” (eg. show me all songs that were added this week that have fewer than 4 stars and have been played less than 10 times).
  • Moq – IMHO the best mocking framework for .net development.
  • Scott Hanselman posted some code on his website a while back about how to Zip Compress your Session and Cache data in Asp.net.

Feel free to send me any code that you come across and I’ll feature it in a future post.

Works on my machine weekly project #1

April 5th, 2009

Download the source code mentioned in this blog post.

 

works-on-my-machine-starburstI’m a hopeless code junkie. I love to write code. Most people do one thing for work and then another for their hobby. My girlfriend for instance works as an IT / Systems Engineer  and her other thing is photography.

My other thing is writing more code. I never did this with any of my previous jobs (save dish washer… I did wash dishes when I was at home but I wasn’t trying out new, cooler ways to wash them).

… So where was I? Oh, right code junkie. So, I really like to write code and what I’ve decided to do is start a new small project each week and try to use some new chunk of .Net or a new library and I’ll post the end results of my efforts here for you all.

All of these projects will be offered under the CodeImpossible “works on my machine” code quality guarantee. But I’ll never post something that flat-out doesn’t work.

Sound good? Cool, let’s kick it off – as the first entry into this space I’d like to present TweetCommander.

TweetCommander is a small .Net v3.5 console application that lies in wait, watching a twitter account for any new Direct Messages from another user (we’ll call this person the “owner”).

When a direct message from the owner is found, TweetCommander will check to see if it contains certain text, and depending on that text, will perform a series of actions on the machine it is running on.

TweetCommander will support three commands: “current_screenshot”, “exit”, and “set_interval”.

  • Sending “current_screenshot” will tell TweetCommander to take a screen capture of the Windows desktop, upload it to TwitPic, and then send the url for that image to the owner user in a Direct Message.
  • Sending “exit” will cause TweetCommander to exit
  • The “set_interval” is followed by a number that represents the number of seconds TweetCommander should wait between requests for new direct messages from twitter. This is more to avoid the API limit than anything else.

Settings
TweetCommander will need to store the Twitter ID for the last successfully processed Direct Message somewhere so we aren’t constantly processing the same commands over and over again. The end user won’t need to be aware of this value but it’s worth mentioning anyway.

We’ll also need to store the wait interval so we don’t lose this information if we need to restart TweetCommander for whatever reason.

Okay, so here is the settings file I have so far:

tweet_mon_console_settings

Working with Twitter
All right so now we need to be able to interact with Twitter. Now, I don’t want to write my own API library so I’ll go out and get the latest copy of TweetSharp which will give me a nice, readable interface to twitter’s API. After getting this built I’ll be able to get the most recent direct messages using the following code:


var directMessages = FluentTwitter.CreateRequest()
	.AuthenticateAs(
		TWITTERACCOUNT_USERNAME,
		TWITTERACCOUNT_PASSWORD)
	.DirectMessages()
	.Received()
	.Since(Properties
		.Settings
		.Default
		.LastProcessedCommandID)
	.AsJson()
	.Request()
	.AsDirectMessages();

Thats pretty freakin’ sweet I must say. Tweet# really takes the brain work out of working with twitter and there is no way to look at that code and not understand what it is doing immediately. Epic win.

To get this running on your machine, just grab the source from my box.net folder, and change these values at the top of the Program.cs file:


// this is our "owner account" we will only act upon direct messages
// send from this user
private static string TWITTEROWNER  = "codeimpossible"; 

// this is our listener accounts username
private static string TWITTERACCOUNT_USERNAME = "someuser";

// this is our listener accounts password
private static string TWITTERACCOUNT_PASSWORD = "somepassword";

Note: The solution file for this contains a reference to a compiled version of  the Tweet# library that contains a quick patch I made for an issue that affects uploading an image to Twitpic. However this issue has been fixed officially in the most recent source.

Testing JsonResult in Asp.net MVC

March 16th, 2009

So lately I’ve been working on a project using Asp.net MVC and TDD to build a web 2.0 application. It’s a twitter-like application that I started a while ago but due to my failure to test everything I lost about 99% of my work and had to start over from scratch.

But this was sort of a good thing because it gave me a chance to revisit a lot of things that I wasn’t very happy with the first time around. I just got done adding the ability for users to post new messages via AJAX.

In the first version of the application a user would type their status into a textbox, click submit and the page would refresh with their new message at the top of their user wall. Although functional this wasn’t exactly very “web 2.0″-ish.

My controller will have an action called Index that takes two parameters, the message the users is posting and the tags associated with that message. m_UserService, and m_MessageService are private objects, that interact with the database.

[Authorize]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(string message, string[] tags)
{

	var messageOwner = this.m_UserService
		.GetByUserName(User.Identity.Name);

	var messageObj = new Message()
	{
		Owner = new User()
		{
			Identifier = messageOwner.Identifier,
			UserName = messageOwner.UserName,
			Email = messageOwner.Email,
			RealName = messageOwner.RealName,
			IsModerator = messageOwner.IsModerator
		},
		Body = message,
		CreatedOn = DateTime.Now,
		IsReply = message.StartsWith("@")
	};

	this.m_MessageService.Post(messageObj);

	return Json(messageObj);
}

The JsonResult will be serialized/deserialized by the MVC framework when the code is run in a web project or IIS but I need to be able to test this as part of our build process.

* NOTE: For those of you who might be thinking “how do we get around the authorization”? I’ll answer that in a later post (or you can check out Scott Hanselmans blog for the solution).

Ideally I wanted to do something like the following in my test:

	Assert.AreEqual("some text", jsonObject.someproperty);

But since C# is a type-safe language this isn’t easily doable. However, utilizing an extension method and the JavaScriptSerializer in System.Web.Script.Serialization we can come pretty close:

	Assert.AreEqual("some text", jsonObject["someproperty"]);

Here is the code I used to achieve this (This code depends on Moq v3.0.108.5 which you can download here):

using System;
using System.Text;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Mvc;

using Moq;

public static class JsonResultExtensions
{

	public static T Deserialize<T>(this JsonResult json,
		Controller controller)
	{

		var jsonSB = new StringBuilder();

		var httpResponseMock =
			new Mock<httpResponseBase>();

		httpResponseMock.Setup(mock => {
			mock.Write(It.IsAny<string>());
		}).Callback<string>((s) => {
			jsonSB.Append(s);
		});

		var httpContextMock =  new Mock<httpContextBase>();

		httpContextMock.Setup(mock => mock.Response)
			.Returns(httpResponseMock.Object);

		controller.ControllerContext
			.HttpContext = httpContextMock.Object;

		jsonResult.ExecuteResult(
			controller.ControllerContext);

		return new JavaScriptSerializer()
			.Deserialize<T>(jsonSB.ToString());
	}
}