Friday, July 11, 2014

Session Helper

I am writing this for my own repository of  using session variables and though may be useful to others friends also.  Over use of session variables are not good. Try to avoid using it. It takes server memory. If you want to use it then this code example shows how to use it without worrying to remember Session keys and simply access like a property with appropriate type.

I am explaining everything using code and code comments. 

/// Session Helper class
   public static class SessionHelper
       /// The userinfo Key
       const string USERINFO = "USERINFO";
       /// The userclaiminfo Key
       const string USERCLAIMINFO = "USERCLAIMINFO";
       /// Property to Get or sets the user claim information from or to Session.
       public static UserClaimsInfo UserClaimInfo
               return GetInfoFromSession<UserClaimsInfo>(USERCLAIMINFO);
               SetInforToSession<UserClaimsInfo>(value, USERCLAIMINFO);
       /// Property to Get or set the user information from or to session.
       public static Userinfo UserInfo
               return GetInfoFromSession<Userinfo>(USERINFO);
               SetInforToSession<Userinfo>(value, USERINFO);
       /// Priavate generic method to Get information from session using Key.
       private static T GetInfoFromSession<T>(string key)
       if (HttpContext.Current.Session[key] != null && HttpContext.Current.Session[key] is T)
               return (T) HttpContext.Current.Session[key];
           return default(T);
       /// Priavate method to set information to session using Key.
       private static void SetInforToSession<T>(T info, string key)
           HttpContext.Current.Session[key] = info;

In above code block You can add individual property for each session variable.  You can to define constant variable for defining key.  Session variable property can use generic method  GetInfoFromSession<T> and SetInfoToSession<T> to get and set values to and from session. 


Thursday, February 13, 2014

Code snippet search

Code snippet search is going to be very easy now and in future with our favorite IDE like visual studio.

It is using Microsoft Bing. 

Bing searches code from coding community like 

  •   MSDN
  •   StackOverFlow
  •   Dotnetperls
  •   CSharp411

To search a code snippet, You can go to following Url.

It is looking like this.

All instruction is written there like how to get code snippet.

Start with special comment "///".
Then you just need to type your code snippet query in English like you search in Google. and press Tab will show you intellisense like window. which also show code in next window beside the main window.

You can select and  get the code snippet. 

You can select and  get the code snippet.   

You can also do directly from Visual Studio directly.   

You can download VS extension from here

Check this blog for more 

Who want to remember all the code all the time. 

There are some other websites also there for code snippet repository

Happy Coding....

Saturday, January 11, 2014

TFS with VS 2013 tutorial

Microsoft has provided online Visual studio support for Team Foundation Server and Git.
You can create your visual studio account and access your own TFS. You can use your own code repository online anytime anywhere. It is free for up to 5 Users.

Go to following url :

Click on "Get Started for free" highlighted in green background.
Visual Studio

Sign in using your any windows live account user id/ password. If you don't have windows live id then you can create one by clicking "Sign up now".

After login, You will get this page. You will find your name as logged in User. If you want to use Visual studio 2013 trial version then you can download from here. 

Click on your user name and you will get following page.

You can find URL starts with your username like {your username} It is your online TFS access link. click on that link. You can add up to 5 Users for free.

As I was the early adopter of this feature, Microsoft has extended my "Visual studio online Ultimate" version for free. After 62 days it will be a standard account with limited feature. You can get to know about all features or get it from here.


Categories and capabilitiesVisual Studio Online AdvancedVisual Studio Online ProfessionalVisual Studio Online BasicVisual Studio Premium with MSDN
Maximum number of users with this plan on an accountUnlimited10 usersUnlimitedUnlimited
Unlimited team projects and private, hosted code repos using TFVC or Git  X   X X X 
Project planning and bug tracking tools, including Kanban boards and team velocity forecasts  X   X X X 
Integration with popular development tools, including Visual Studio, Eclipse, and Xcode  X   X X X 
Work in one IDE to create solutions for the web, desktop, cloud, server, and phoneX X 
Support for Office 365 business appsX X 
Track complex projects with hierarchical portfolio backlogsX X 
Visualize project data with work item chart authoringX X 
Discuss projects with teammates and monitor project events in Team RoomsX X 
Send feedback requests to users and stakeholdersX X 
Manage and run tests and test plansX 
Host team projects on-premises as well as in the cloudX 
Microsoft has provided detail documentation about how online TFS works. 
LIke following. I have provided Link for each. I will still give overview of How to setup Code with Visual studio.

Create Project 
Go on your visual studio url {your username}  This is dashboard of all your project and project activities.  Find "New" link under "Recent project & teams" to create New project. Check highlighted "New" link in following screen shot. 

Click on "New", It will open Modal window to create Project. You can insert Project Name, Description. You also can select Process Template and Version control.  Microsoft has provided following Process Template. 

  • Microsoft Visual Studio Scrum 2013
  • MSF for Agile Software Development 2013
  • MSF for CMMI Process Improvement 2013
These are the process followed by Software development team to develop software. 

Microsoft has come up following two options for version control.
  • Team Foundation Version Control
  • Git ( Github)

After insert of all required details, you can create project by click on "Create project" button. It will crate project using selected Process template.

Visual Studio with Online TFS
Go back to Visual studio.  I am using Visual studio express 2013. I am going to show how can you connect your visual studio with your online TFS which you have configured above.

Open Visual studio and click Menu link "TEAM".  You will find  sub menu link "Connect to Team Foundation Server..".
click on it.

It opens "Team Explorer" tab at right side of VS window.  Find connector icon on top. If you mouse hover on it it shows "Connect to Team Projects". Click on it. It opens small "Connect" tab. 

Click on "Connect" and it will popup screen for "Connect to Team Foundation Server".

Click on "Servers.." and it opens following another popup where you can add your own visual studio url which we have created before explained in above section.  {yourusername}  Once you enter your url it will disable all other options like Path, protocol. online visual studio uses HTTPS.  No need to select anything just your correct url is enough.

Once you added TFS server. you can select same from servers drop down. It will show  DefaultCollection in left tab and all projects on left side. You can find Project you have created online and explained in above section. check below screen shot.

On Team Explorer you will find your project.  Click on Source Control Explorer.

You can create your project folder and map it with your local drive. 

Follow my previous blog to create project in TFS for more details here.  
Online TFS has all features of TFS including Project Management like Scrum dashboard, Tracking Product Backlog items, Sprint Backlog items, Scrum velocity charts, Bug Tracking, Automated Unit Testing, Load testing, Automatic Build Deployment,  also has support with Windows Azure.

In my next blog I will try to cover how to manage Scrum Dashboard, Create Product backlog items, how to track Bug etc.
Thank you.