This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string ToJSON<T>(this T obj) | |
{ | |
MemoryStream ms = new MemoryStream(); | |
try | |
{ | |
DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType()); | |
serializer.WriteObject(ms, obj); | |
return Encoding.UTF8.GetString(ms.ToArray()); | |
} | |
finally |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void TestCalculations() | |
{ | |
// A simple web service offering basic aritmetich operations | |
Service service = new Service(); | |
// Test data... | |
int a = 10; | |
int b = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) | |
{ | |
Outlook.ContactItem currentContact = (Outlook.ContactItem)this.OutlookItem; | |
string address = currentContact.BusinessAddress.Replace("\r\n", ","); | |
ExecuteScript("FindLocation", address, currentContact.FullName, currentContact.BusinessAddress); | |
} | |
private void ExecuteScript(string scriptName, params object[] parameters) | |
{ | |
webBrowser.Document.InvokeScript(scriptName, parameters); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html> | |
<head> | |
<title>Virtual Earth</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<style type="text/css"> | |
body | |
{ | |
margin: 0px; | |
padding: 0px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Starts the Http Listener on a background thread. | |
/// </summary> | |
private void StartHttpListener() | |
{ | |
if (HttpListener.IsSupported) | |
{ | |
try | |
{ | |
//Creates a HttpListener with two urls for RSS and HTML. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// The Main class of the application. | |
/// </summary> | |
static class Program | |
{ | |
// Private members | |
private static MainForm mainForm; | |
/// <summary> | |
/// The main entry point for the application. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RegistryKey helpDesk = Registry.ClassesRoot.CreateSubKey("HelpDesk"); | |
helpDesk.SetValue("", "URL:HelpDesk Protocol"); | |
helpDesk.SetValue("URL Protocol", ""); | |
RegistryKey defaultIcon = helpDesk.CreateSubKey("DefaultIcon"); | |
defaultIcon.SetValue("", Path.GetFileName(Application.ExecutablePath)); | |
RegistryKey shell = helpDesk.CreateSubKey("shell"); | |
RegistryKey open = shell.CreateSubKey("open"); | |
RegistryKey command = open.CreateSubKey("command"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.Gadget = function() | |
{ | |
/// <summary>Defines methods, events, and properties that are used to specify gadget configuration options in the Windows Sidebar environment.</summary> | |
/// <field name="background" type="String">Used in a gadget to set the background image using a file path or to get the file name of the current background image.</field> | |
/// <field name="docked" type="Boolean">Called from within a gadget to determine if the gadget making the script call is docked.</field> | |
/// <field name="name" type="String">Used from within a gadget as a means to determine the gadget name as specified in the gadget manifest file.</field> | |
/// <field name="opacity" type="Number" integer="true">Called from within a gadget to specify the percentage of opacity as an integer.</field> | |
/// <field name="path" type="String">Called from within a gadget to display the file path for the gadget.</field> | |
/// <field name="platformVersion" type="String">Called from within a gadget to retrieve the vers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<CodeSnippets | |
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Execute Sql Data Reader</Title> | |
<Author>Jonas Follesø</Author> | |
<Description>A standard way to execute a stored procedure returning a reader</Description> | |
<HelpUrl>http://jonas.follesoe.no</HelpUrl> | |
<Shortcut>reader</Shortcut> | |
<SnippetTypes> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString)) | |
{ | |
SqlCommand command = new SqlCommand("GetItems", connection); | |
command.CommandType = CommandType.StoredProcedure; | |
command.Parameters.AddWithValue("@author", "Jonas Folleso"); | |
using (command) | |
{ | |
command.Connection.Open(); | |
using (SqlDataReader reader = command.ExecuteReader()) |