MS Code Conversion Tools

Now-a-days, I’ve been exploring much thru VB.NET programming. As being a programmer for more than 3 years, I’ve found difficulties in VB.NET programming towards writing the right syntax. But all these days, I used to think that there are online code conversion tools available to make my life easy. But I were found mistaken with the widely available code conversion tools.

There are 2 tools that are widely used by the industry. One is from Telerik and the other is from Developer fusion. These both do the work till the maximum extent, but couldn’t handle the situation of event delegates and lambda expressions. The main problem is this with many of the free tools, they would not be having that intelligence provided for free. Surprisingly,  Developer fusion doesn’t provide any paid services. Telerik didn’t indicate that there is a paid version for the same. Hence, my work become more troublesome.

While planning to post a query at the MSDN Forums for VB.NET lambda expressions as well as the event delegates, I have come across of a tool as a signature of the person who answered a post. This tool is from Tangible Software Solutions Inc., They offer a demo version for free with limited number of conversion, but it solved my problem. So it is time for me to post the problem and the solution provided by Tangible Software Solutions tool

Problem Statement :

Add a delegate for page preload event

C# Code Snippet:

        void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
Page page = application.Context.CurrentHandler as Page;
if (page != null)
{
page.PreLoad += (src, args) => BuildController(page);
page.Unload += (src, args) => UnloadController(page);
}
}


VB.NET Code snippet from Telerik

Private Sub context_PreRequestHandlerExecute(sender As Object, e As EventArgs)
Dim application As HttpApplication = DirectCast(sender, HttpApplication)
Dim page As Page = TryCast(application.Context.CurrentHandler, Page)
If page IsNot Nothing Then
page.PreLoad += Function(src, args) BuildController(page)
page.Unload += Function(src, args) UnloadController(page)
End If
End Sub

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik, @toddanglin
'Facebook: facebook.com/telerik
'=======================================================



VB.NET Code snippet from Developer fusion

Private Sub context_PreRequestHandlerExecute(sender As Object, e As EventArgs)
Dim application As HttpApplication = DirectCast(sender, HttpApplication)
Dim page As Page = TryCast(application.Context.CurrentHandler, Page)
If page IsNot Nothing Then
page.PreLoad += Function(src, args) BuildController(page)
page.Unload += Function(src, args) UnloadController(page)
End If
End Sub



VB.NET Code snippet from TSS

    Private Sub context_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs)
Dim application As HttpApplication = DirectCast(sender, HttpApplication)
Dim page As Page = TryCast(application.Context.CurrentHandler, Page)
If page IsNot Nothing Then
AddHandler page.PreLoad, Sub(src, args) BuildController(page)
AddHandler page.Unload, Sub(src, args) UnloadController(page)
End If
End Sub



The main pain point in this conversion is towards the page.PreLoad event delegation. Finally, if you see that the change in the above conversions, only the TSS could do the decent conversion.

Comments

This site is really awesome and amazing to me, i am also gonna share this site to my friends.
Thanks for the comment and I'm glad that you found this place to be sharable by your friends.

Popular posts from this blog

Network Intrusion Detection using Supervised ML technique

Common mistakes by Interviewer

Keep the system active, to avoid the auto lock