This repository contains a collection of some of my most frequently used Visual Studio-snippets.
Download (or clone) the snippets into %USERPROFILE%\Visual Studio 2013\Code Snippets\Visual C#\My Code Snippets
. For older versions of Visual Studio, just change the version number in the path to the version desired.
Quickly sets up a configuration property, which comes in handy when writing your own configuration section code.
- type - The type of the configuration property. Will be used for casting to and from the base-class.
- name - Name of the C#-property.
- xmlname - Name of the XML-element in the applications configuration file.
private const string MaxRequestsXmlElementName = "maxRequests";
[ConfigurationProperty(MaxRequestsXmlElementName)]
public int MaxRequests
{
get
{
return (int)base[MaxRequestsXmlElementName];
}
set
{
base[MaxRequestsXmlElementName] = value;
}
}
Creates a DataContract-class. Usable when fiddling about alot with WCF-services and the DataContractSerializer.
- name - Name of the DataContract-class.
[DataContract]
public class MyDataContract
{
}
Creates a DataMember-property. Usable when fiddling about alot with WCF-services and the DataContractSerializer.
- type - The type of the DataMember-property
- name - The name of the DataMember-property
[DataMember]
public string CustomerName { get; set; }
Seriously? Do I need one? Just do whatever you like with it. :)