Using Reverse Geocoding to Find an Address

Wednesday, June 22, 2011

Using Reverse Geocoding to Find an Address I had a request from a colleague of mine to help him with a geocoding problem. The colleague needed to find an address by a given latitude and longitude which were supplied by a smartphone consumer. The example in this post will show you how you can use Google geocoding API in order to achieve that using C#. Reverse Geocoding (Address Lookup) Geocoding refers to translating an address into its location or coordinates. The reverse of it is address lookup which occurs when you have the map location and...
tags: ,
3 comments

Configuring WCF Data Services using Lambda Expressions

Thursday, April 21, 2011

Configuring WCF Data Services using Lambda Expressions One of the things that I avoid when I’m writing code is the use “magic strings”. Hardcoded strings are a code smell and should be rarely used. When using WCF Data Service configuration object you’ll have to pass the entity set’s string name to the configuration methods which as I wrote I would like to avoid. This is why in today’s post I’m going to extend the DataServiceConfiguration object to support lambda expressions instead of string parameters. Data Service Configuration Extensions I’ve created a simple static class that includes two new extension methods: SetEntitySetAccessRule<DataSource>...
no comments

Back to Basics – Reading a File into Memory Stream

Thursday, March 3, 2011

Back to Basics – Reading a File into Memory Stream Today I was asked to help a developer with a simple task she had. That task included reading an image file into a memory stream in order to send the image through an e-mail attachment. This post will show you how to do exactly that. Reading a File into Memory Stream Here is the code for reading the file into a memory stream: using (FileStream fileStream = File.OpenRead(filePath)) ...
tags: ,
5 comments

Back to Basics – Null-Coalescing Operator

Thursday, November 18, 2010

Back to Basics – Null-Coalescing Operator Yesterday during an EF4 course that I’m giving at a customer I showed an example for a property that is set using the null-coalescing operator. Since some of the students asked me what is this operator, I gave a small explanation and thought that it’s something that I can share here in the blog. So here it goes… Null-Coalescing Operator The null-coalescing operator or ?? can be very useful when you want to check nullity of a reference type or nullable types. When it is used, it returns the left-hand...
no comments

Adding a Javascript Block Into a Form Hosted by WebBrowser Control

Tuesday, July 13, 2010

Adding a Javascript Block Into a Form Hosted by WebBrowser Control Today I found myself with a need to add a javascript block into a WebBrowser control in order to do some work. This post will show you the steps to do exactly that. The Problem In a project I’m consulting for there was a need to dynamically add a javascript block into a web form that is hosted inside a WebBrowser control. So what can we do? The Solution We can use the Microsoft HTML Object Library to achieve the task.  The Microsoft HTML Object Library is a COM library that you...
no comments

Book Review – C# in Depth – What You Need to Master C# 2 and 3

Thursday, April 15, 2010

Book Review – C# in Depth – What You Need to Master C# 2 and 3 In the last weeks  I read the book “C# in Depth – What You Need to Master C# 2 and 3” that was written by Jon Skeet. You might ask yourself why I bothered reading a book about C# 2 and 3. The answer is very simple.  Knowing some material isn’t enough and reading leads to wide and deeper knowledge. One of the first things that I recommend people who ask me how can I learn and gain programming knowledge is reading good...
no comments

Performing Queries Against Active Directory Domain Services

Wednesday, March 3, 2010

Performing Queries Against Active Directory Domain Services One of the missions that needed my attention lately was to check whether a user exists in an enterprise Active Directory. The post will show exactly how to perform such a query. The DirectoryEntry Class The DirectoryEntry class represent an entry in Active Directory. That entry live in memory when created and changes that you perform on it won’t be submitted to Active Directory unless you call the CommitChnages method. That class can be found in System.DirectoryServices namespace. The following code shows how to create a DirectoryEntry object using a the path to the LDAP,...
no comments

Quick Tip – Making Beep From the PC Speaker Using P/Invoke

Friday, February 26, 2010

Quick Tip – Making Beep From the PC Speaker Using P/Invoke I was asked yesterday how can we perform a beep sound from the PC speaker. This is  something that is needed in one of the  applications that I’m consulting for to indicate a successful transaction (don’t ask me way…).  Setting the Environment We first need to add the using for Runtime.InteropServices: using System.Runtime.InteropServices; Then load the unmanaged...
2 comments

Reading a Xml File in T4 Templates

Saturday, December 12, 2009

Reading a Xml File in T4 Templates After I wrote the post about the use of T4 templates in EF4, I played with them for a while (not in EF but generally with T4 templates). In an old project that I’ve created almost 3 years ago which automated the use of lookup tables I had an enum. That...
one comment