Posts

Showing posts from July, 2013

Generic Method To get values of an Enum

  Recently I got a requirement of creating a generic method to pass an Enum Name & get all the Enum Names & Values. Method will return a collection of following class objects. public class EnumValueDto  {       public string Id { get; set; }       public string Value { get; set; }   } private IList<EnumValueDto  > GetEnumValueList<T>()     {         IList<EnumValueDto  > enumValueList = new List<EnumValueDto  >();                  var values = Enum.GetValues(typeof(T)).Cast<T>();         var enumerable = values as T[] ?? values.ToArray();         for (int i = 0; i < enumerable.Count(); i++)         {                        enumValueList.Add(new EnumValueDto  { Id =((int)Enum.Parse(typeof (T), enumerable.ElementAt(i).ToString())).ToString(), Value = enumerable.ElementAt(i).ToString() });        }         return enumValueList;     } Hope this will be helpful. Happy Coding !!!!!

Modeling Applications in VS 2012

Image
Designing Systems with a stable architecture is always challenging. But it is one of the most interesting tasks personally I find as a developer, it is where we can improve both technical knowledge & analytical skills. VS 2012 has come with some new rich tools for modeling the applications to make sure , it meets the user requirements. This tools can be used to visualize the code to understand its structure, relationships, and behavior in a more effective manner. It provides us the facility of create models in different levels :- Track requirements Track Tasks Test cases bugs   Types of Models   1. Dependency Graph This diagrams shows how your code is been organized & it’s dependencies. This is very useful to identify the code base without going through code lines. You can create a dependency graph for the whole solution & then dig in to the small levels of the assemblies as follows.   2. Layer Diagram Layer diagram let us to create logical grouping of the