Posts Tagged ‘C#’

Integrating with Facebook on Windows Phone 7

March 18, 2011

I recently helped a collegue with Facebook integration on Windows Phone 7. The requirement was to log in and post a link to the users stream. I quickly came across the Facebook C# SDK found on codeplex at: Unfortunately the otherwise pretty straight forward API is poorly documented, so it took me a bit of trial and error to get what I wanted. Here are the steps I took:



iOS Push Notifications in C# with apns-sharp

November 28, 2010

I just recently set up push notification in an iOS application for the first time. The back-end is implemented in C# and searching the web for existing solutions i came across “apns-sharp” ( “apns” is short for Apple Push Notification Service and the library, as you would expect, provides a C# api for sending iOS push notifications. The library also contains an api for Apple’s Feedback service for – a service used to retrieve push tokens that are no longer valid, so as to be able to clean up subscribtions.

Initially i got things working on my dev setup without hardly any effort. I then proceeded to publish the project to by budget webhost and suddenly I wasn’t receiving notifications anymore. It took me quite some time to figure out what was wrong…


Windows Phone 7 predictions from a Window Mobile developer

February 12, 2010

With Mobile World Congress in Barcelona only two days away, I feel like making my “predictions” for Windows Phone 7. If nothing else, then so that people will have something to throw in my face (yeah right – it’s so i can gloat of course).

First let me take you back: One of the first things I noticed about the Windows Mobile 5 / Compact Framework combo was how weak the graphics system was. As usual I created a layout in Photoshop, assuming that stuff like basic transparency and gradients would of course be available. Years later I have spend countless hours trying to wrangle Compact Framework Forms applications into something good looking / user friendly. At some point you just realize it’s too much effort and half resign.

Why this talk of Compact Framework?


There’s no I in standard

September 21, 2009

Coming from C# I personally prefer the I+DescriptiveInterfaceName (e.g. IList) convention, but that “I” seems to be a bit of a sin within the java community.

Imagine my surprise when I came across android.os.IBinder.

Although I’m just a random hacker using a language like C#, one thing I would always adhere to over my own preference in regards to naming, is a standard. I thought java guys were real sticklers for this kind of thing.

Guess I was wrong 🙂

Streaming MP3 audio from a WCF REST service

June 29, 2009

For a project i am working on in my spare time, i needed to stream MP3 audio from a REST service, implemented in WCF. I was supprised at how easy this was. It’s as simple as setting the response content type and returning a stream:

IAudioDemoService.cs method definition:

Method = "GET",
UriTemplate = "/AudioStream")]
Stream GetAudioStream();

AudioDemoService.cs method implementation:

public Stream GetAudioStream()
	WebOperationContext.Current.OutgoingResponse.ContentType = "audio/mpeg";
	return new FileStream(@"c:\AudioFile.mp3", FileMode.Open);

(actually the content type isn’t strictly nessesary, but it enables a client to identify the information in the stream – a browser for instance might use it to select an appropriate application for processing)



February 3, 2008

A small and helpful class that I find myself adding to every single project I start these day is ”GenericEventArgs”.

Microsoft included the System.EvenHandler<T> class in .NET, taking away the need to create custom delegates to enable the use of custom event arguments . This class takes it one step further. It’s a simple generic class with the signature EventArgs<T>, deriving from System.EventArgs. It accepts a single instance of T thru the constructor which it exposes via a property “Value” of the type T.

Now where I would earlier create custom eventarg classes to pass a single argument with an event, I simply use this generic implementation.


Model View Presenter (MVP) – My first post!

January 27, 2008

Hello all and welcome to Mr. Rask on the web.

For this my first post i have composed a basic introduction to my favorite design pattern: Model View Presenter or MVP for short. The implementation presented in the article is pretty much exactly how i do it at the office office every day.

Model View Presenter is all about seperating user interface logic from graphical implementation. If you have ever build applications using a graphical library like Windows Form, you know how easily user interface code can get cluttered. MVP to the rescue.

Article (.PDF): Model View Presenter (MVP)
Source (C# 3.0 / VS2008): Crappy filehosting died, so if you want it just drop a comment.

Last but not least any feedback is much appreciated. So pretty please – with sugar on top – drop a comment if you find what you read here usefull (or even if you don’t – i just want to hear from you 🙂 )

All the best
Olav Rask