Skip to content

Instantly share code, notes, and snippets.

View clemensv's full-sized avatar
🏠
Working from home

Clemens Vasters clemensv

🏠
Working from home
View GitHub Profile
@clemensv
clemensv / gist:2589551
Created May 3, 2012 21:12
I actually wasn't kidding about entityless HTTP calls
var wr = WebRequest.Create("http://localhost:39472/Provisioning.svc/setup");
wr.Method = "POST";
wr.Headers.Add("P-DeviceId", this.deviceId);
using (var wq = (HttpWebResponse)wr.GetResponse())
{
if (wq.StatusCode == HttpStatusCode.OK)
{
settings.DeviceAccount = wq.Headers["P-DeviceAccount"];
settings.DeviceKey = wq.Headers["P-DeviceKey"];
settings.DeviceSubscriptionUri = new Uri(wq.Headers["P-DeviceSubscriptionUri"]);
@clemensv
clemensv / CorrelationWorker.cs
Created May 10, 2012 19:34
Message Correlation - Worker Role Side
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BackgroundWorker
{
using System.Threading;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
@clemensv
clemensv / ProcessingJobsController.cs
Created May 10, 2012 19:37
Message Correlation - Web Role Side
namespace CorrelationSite.Controllers
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web.Mvc;
using CorrelationSite.Models;
using Microsoft.ServiceBus.Messaging;
@clemensv
clemensv / gist:3540372
Created August 30, 2012 20:40
Yes, a goto courtesy of async/await's scoping issues with "catch".
// The scoping model in "catch" doesn't allow for async/await handling because
// catch needs to be able to rethrow without messaging up the stack frame, i.e. "throw;"
// There's obviously an alternate non-goto solution here with a result variable and a
// subsequent switch on that result, but if you code that up, the switch looks like
// a longer, uglier variant of the gotos.
static async Task LoopedReceive(Func<Task<BrokeredMessage>> receiveCallbackAsync,
Func<BrokeredMessage, Task<bool>> messageReceivedCallbackAsync,
CancellationToken token)
{
namespace Sagas
{
using System;
using System.Collections.Generic;
class Program
{
static ActivityHost[] processes;
@clemensv
clemensv / gist:3652025
Created September 6, 2012 06:18
Send with retry
namespace MartVue.Common
{
using System;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Microsoft.ServiceBus.Messaging;
public static class RobustSendExtension
{
static readonly TaskFactory TaskFactory = new TaskFactory();
@clemensv
clemensv / gist:3817582
Created October 2, 2012 09:04
C# class extensibility pattern
public interface ISomeExtension
{
object Private { get; set; }
}
public static class SomeExtension
{
class State
{
public string data;
@clemensv
clemensv / gist:3853572
Created October 8, 2012 16:56
Writes
namespace Writing
{
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
class Program
{
static void Main(string[] args)
@clemensv
clemensv / gist:4252776
Created December 10, 2012 19:33
ForwardTo Minimal Sample
namespace ConsoleApplication2
{
using System;
using System.Configuration;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
class Program
{
static void Main(string[] args)
@clemensv
clemensv / gist:4253067
Created December 10, 2012 20:21
ForwardTo with Topics and Session Queues
namespace ConsoleApplication2
{
using System;
using System.Configuration;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
class Program
{
static void Main(string[] args)