Tuesday, June 25, 2013

Visual Studio 2012, shortcut key combinations

I found it very helpful and putting in my blog to help others, If you find any other combination that is missing in this list, Do update in comment section and I`ll include them into the list

All shortcuts beginning with CTRL+W are for opening or navigating to Windows:

  •   CTRL+W, S: Solution Explorer
  •   CTRL+W, E: Error list
  •   CTRL+W, R: Resourceview
  •   CTRL+W, A: Command window
  •   CTRL+W, T: Taskview
  •   CTRL+W, Q: Find Symbol Results
  •   CTRL+W, X: ToolboX
  •   CTRL+W, C: Classview

Thanks
Pradeep

Monday, June 03, 2013

Serialize object or list of objects using xDocument

This works for any serializable type or list of serializable type and deserialize back.

 

XDocument doc = new XDocument();

using (var writer = doc.CreateWriter())

{

    var serializer = new DataContractSerializer(objToSerialize.GetType());

    serializer.WriteObject(writer, objectToSerialize);

}

Var objectXml = doc.ToString();

 

To Deseralize xml back to type T.

 

DataContractSerializer ser = new DataContractSerializer(typeof(T));

return  (T)ser.ReadObject(xmlDocument.CreateReader(), true);

 

 

you need to refer using System.Xml.Serialization; in your class type.

 

Thanks

Pradeep

(425)463-7804