Tag Archives: .net

The NFC wave is coming…kinda.

I stepped out yesterday morning to go to an appointment and when I got back I dumped my wallet on my desk then neatly stacked my phone on top of it. I’ve got a Nokia Lumia 920 running Windows Phone 8. After a second my phone chimed. I was familiar with the noise because I have a wireless charging stand by my bedside table.

Turns out that the NFC proximity sensor on the Nokia Lumia 920 had picked up an NFC chip from the many cards within my wallet. This afternoon I sat down to figure out which card it was and how I could use the proximity API within Windows RT to read the card.

As I flicked through the cards in my wallet and held them out to my phone I found that if the 23 cards in my wallet, six of them had NFC chips within them. Of those there were 3 bank cards, 2 transport cards and 1 loyalty card.

My next goal was to figure out how the proximity API within Windows Phone works to see whether I could get access to any of the details on the cards. I’ve slapped together a quick example of how to use the proximity API. The code uses the ProximityDevice and hooks up to the DeviceArrived and DeviceDeparted events and also calls SubscribeForMessage.

Unfortunately none of the cards that I had in my wallet contained an NFC device which was in a format that Windows Phone 8 could understand. NFC messages that Windows RT supports are listed on the PublishBinaryMessage documentation page. From what I can tell Windows Phone 8 only supports a subset of these, and other than Windows specific message types, the messages need to be formatted using NDEF. If you happen to have an NDEF formatted card you can use the NDEF library hosted at CodePlex to work with the data directly.

I hope that in the future Microsoft will open up more of the NFC device capabilities on their mobile platform. I suspect that many loyalty card programs that use NFC won’t necessarily encode their messages with NDEF which will limit the ability to do anything interesting with Windows Phone unless they take the step to redistribute cards (unlikely).

Either way, I think that we are going to see more and more NFC moving forward. It is already quickly taking hold with credit card/over-the-counter transactions, but so much more is possible with mobile integration. Maybe I’ll look at using NFC in between mobile devices next. The NFC wave is coming…kinda.

C# 6.0 Suggestion: Automatic Property Initializers

When automatic properties were introduced into C# as a short-cut way of declaring properties I am sure lots of developers cheered for joy. Automatic properties are a great enhancement but every-time I use them I keep thinking that they are somewhat incomplete.

What I would like to do is have a neat way initializing automatic properties without having to declare them in the constructor. The syntax would be something like as follows:

public class Customer
{
public IEnumerable<Address> Addresses { get; protected set; } new Collection<Address>();
}

There are a few subtle things going on here. First, I might want to expose a list of addresses to calling code, however I may not necessarily want to expose a collection that can be updated. The syntax above exposes a public property as IEnumerable<Address>, however the backing field would be created as a Collection<Address>.

This would remove probably the #1 reason that I have to resort to implementing a property manually.

Reflector, why not pay for it?

I’m surprised at the somewhat negative reaction by the .NET community about RedGate’s recent announcement about charging $35.00 dollars for the basic version of .NET Reflector. For those who don’t know the history, Lutz Roeder handed .NET Reflector over to RedGate so that they could maintain and enhance it into the future.

.NET Reflector is an awesome tool and I’ve used it countless times to get a better understanding of “how stuff works”. I wouldn’t be the .NET developer I am today without this tool. So I’m definitely going to cough up the $35.00 dollars, and you know what, now that I’ve sat down and thought about it, I might go and get the Pro version.

My only hope is that Lutz got a good deal when he handed over the tool to RedGate, but that doesn’t diminish the value of the tool, and if Lutz had decided to start selling it I would have happily have paid for it then as well.

Using .NET Reflector is not some special right that the .NET community has. We’ve been lucky to get it for free for so long given how useful it is. Looking forward to version 7.0!