The previous tutorial focused on deserialising simple JSON objects. This tutorial describes the process of deserialising a more complex object using JSON#.
Let’s use the ComplexObject class that we’ve leveraged in earlier tutorials:
Let’s instantiate this with some values, and serialise to JSON. I won’t bloat this post with details on how to serialise, covered in previous posts. Here is our serialised ComplexObject instance:
Notice that we have 2 collections. A simple collection of
Doubles, and a more complex collection of
ComplexArrayObjects. Let’s start with those.
First, create a new class,
ComplexObjectDeserialiser, and implement the required
Remember this method from the previous tutorial?
This effectively parses the JSON and loads each element into a
NameValueCollection. This is fine for simple properties, however collection-based properties would cause the deserialiser to load each collection-element as…
View original post 229 more words
In Part #1, I described a method signature for the
HtmlHelper method, which was:
@Html.DropDownListFor(m => m.UserId, m => m.UserNames, m => m.Id, m => m.Name)
In this part. I’ll write more about
HtmlHelper extension method code to make this work. That’s how you use it in Razor – but what does this method signature look like in the source code? Each of the lambda expressions in the above method signature is an expression which is represented by
Expression<Func<T1, T2>> expr. The first parameter will represent the name of the form field rendered, i.e. what the
Name values are for the Html <select> element. The second parameter represents the items in the
<select> list. The third parameter is the property in the items from the above list which should be rendered in the value attribute of each of the
<option> elements of the
<select> list. The fourth parameter is the property in the items from the above list which…
View original post 678 more words
The Visual Studio Gallery is the best place to find tools, controls, and templates to help make your life as a developer easier and more productive. Every so often, I publish my personal list of favorite extensions. This is something I started back when Visual Studio 2010 was first released. A lot has changed since then. I have already published my favorites list for Visual Studio 2013 several times. As new extensions are released, old ones updated or removed, the list does change a bit from time to time. This time, I’m going to separate the list into two sections, those extensions I feel are “must haves” and those I feel are “really nice to have”.
ImageComments extension by Luke McQuade lets you show images among code in Visual Studio 2010/2012:
Images in code (Visual Studio 2012 with ImageComments)
To add an image you add the specially formatted image comment to your code, like /// <image url=”X:PathToImage.ext” scale=”Y” />. After that the image is displayed by ImageComments right after the comment. You can easily share images with your team by committing them to the repository with the code file and using $(ProjectDir) or $(SolutionDir) macros in the image url to specify relative path for the image. The scale parameter lets you easily change original image size.
While there are some known issues (plus I’d add that images are visible even after the corresponding block is collapsed), the extension adds very useful functionality in a very easy to use manner.
The free ImageComments extension currently supports Visual Studio 2010 and Visual Studio 2012. You can download it…
View original post 10 more words
Microsoft has updated their popular extensions pack Productivity Power Tools for Visual Studio 2013. One interesting new feature they have added is Solution Explorer Errors. It shows error, warning, and message squiggles in the Solution Explorer window and hovering over a squiggle displays a popup filtered to the selected file or project with the ability to go to the corresponding problematic file line:
Solution Explorer Errors in Visual Studio 2013
Visual Commander is a freemium extension for Visual Studio 2010+ allowing you to automate repetitive tasks in the IDE.
Visual Commander Professional v1.5 adds the ability to double-click on a compiler error in the Compilation status box and navigate directly to the relevant code (line and column of the error):
Navigation to relevant code from a compiler error
Visual Commander v1.5 also adds recording for the Edit.FormatSelection and Edit.FormatDocument commands, improves alignment for displayed command bindings in the main VCmd menu.
The recent May 2014 update of Productivity Power Tools for Visual Studio 2013 adds the syntactic line compression feature. “It shrinks lines that contain neither letters nor numbers by 25% vertically, allowing more lines to be displayed in the editor.” In the following sample compressed code takes about 10% less vertical screen space:
Syntactic line compression before and after
In practice most frequently compressed lines are blank ones and lines with braces. If you place opening braces on the same line with code, compressed closing braces will look somewhat odd:
Compressed closing braces
In this case you may want to compress only blank lines. This setting is available in syntactic line compression options:
Syntactic line compression options
I think it’s a nice enhancement that just works.
Visual Studio Platform Team has released the Macros for Visual Studio 2013 extension for VS 2013 to record, edit and execute text editing commands and window operations. You can open the new Macro Explorer tool window from the Tools – Macros menu:
Macro Explorer lists your own macros and preinstalled samples:
You can run a macro double-clicking the name in Macro Explorer or assign a keyboard shortcut (for up to 9 macros).
(To react on Visual Studio events like document saving or reuse older VB macros you still need to use the Visual Commander extension. Visual Commander additionally allows you to write command code in C# and provides access to .NET framework.)
You can download Macros…
View original post 6 more words
Today I stumbled upon a bizarre problem, I wanted to parse an HTML for a site to find out if the site contains any RSS feeds. After some research I found out that finding the RSS feed for a site is not that hard, you have to look for an element that looks like this
“Easy task”, I said, me Mr.Optimistic; “I will just load it up in XElement and using Linq to XML to get the data I want”. BUT guess what the web is filled with crazy HTML that a standard .NET parser such as XElement just gives up on and blows up in flames.
After some heavy head banging to walls and ceilings, I found the solution, HtmlAgilityPack. This open source project lets you load HTML even if it is not in a good shape. With some options HTMLAgilityPack will fix these errors and then you…
View original post 36 more words