Vijay Krishna's Notes http://vijaykrishna.posterous.com Most of my notes as a student of computer software and everything around it. posterous.com Sat, 26 Mar 2011 07:22:47 -0700 Code Formatter for Blogger http://vijaykrishna.posterous.com/code-formatter-for-blogger http://vijaykrishna.posterous.com/code-formatter-for-blogger This was something that my friend was asking me the other day, after he got a pang of envy looking at my code formatting in my wordpress blog (this blog). Ofcourse, there is no inbuilt method for formatting code in blogger. There are roundabout manners by which you can do it, but its too much trouble to ask for. So, instead of explaining all the weird methods in the world, i decided to Google for an online solution and hit upon this: http://alexgorbatchev.com/SyntaxHighlighter/ This uses different syntaxfiles (JS files) to support the syntax of different languages. Here is a list of all the languages that it supports: http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/ Also, the whole thing won't work for Blogger by default. You will have to activate the Blogger Mode by setting the configuration. The clear instructions for which are given here: http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/ Now, there are some sites which do some amazing formatting for a few given languages. Here is one for c# (and other related languages): http://www.manoli.net/csharpformat/ . But the issue comes about when you have to take care of all or more popular languages like Ruby or Scala. So, with that in mind i feel that Syntaxhighlighter is not half as bad a solution. Try it. I found it ok. However, if you do have any better suggestions to make, you are most welcome.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1369599/pic.jpeg http://posterous.com/users/hcGXxsTkwP6SS Vijay Krishna Palepu vpalepu Vijay Krishna Palepu
Tue, 22 Mar 2011 13:20:39 -0700 Retrieving all the Methods in a Service http://vijaykrishna.posterous.com/retrieving-all-the-methods-in-a-service http://vijaykrishna.posterous.com/retrieving-all-the-methods-in-a-service Well, today i was in a real fix. I was asked to work out a manner by which i show all the methods of a service in a combo-box. Now, people told me to ideally have a look at the proxy and type out the method names as they were and then create a static list of strings which i could then bind to the combo-box. WOW!! So simple ain't it?!? "And what if the list of methods were to change", i asked. The reply came, well, you can guess what the reply was. Someone then suggested a method involving WSDL. I do not know what that meant, as the idea was instantly trashed and i was never explained the details. Either way i smelled unnecessary  labor there as well. So i put up a brave face and googled it. I refused to believe that the method list of a given class could not be retrieved. After all that was the crux of my project. So after a little bit of googling and a little asking around from a trusted colleague, i found a way: Type. [sourcecode language="csharp"] public List<string> GetMethodNames(){ Type type = client.GetType(); var methods = type.GetMethods(); List<string> methodNames = new List<string>(); methodNames = methods.select(x=>x.Name).ToList<string>(); return methodNames; } [/sourcecode] So i can actually send in the type of service client (for which the method name list is required) to the GetMethodNames function and get different lists for different services. Thus, allowing me to dynamically get the method lists, which will take care of cases when the service changes the methods in terms of names and numbers. Ofcourse, in case of a Silverlight project, we will have to take care of things like the "Async" prefix. So we just have to remove that. Simple enough. So that is that!! :D

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1369599/pic.jpeg http://posterous.com/users/hcGXxsTkwP6SS Vijay Krishna Palepu vpalepu Vijay Krishna Palepu