I was inspired by the well known Lazy List implementation and decided to create a Lazy Object generic type. There may be better ways to do this, but I thought that a Lazy Object would be a good way to handle the Many To One situations, just as the Lazy List handles the One To Many situations. With out further ado, here is my Lazy Object code:
public class Lazy<T>
{
private IQueryable<T> query;
public Lazy(IQueryable<T> query)
{
this.query = query;
}
public T Get()
{
return query.SingleOrDefault();
}
}

A recent project of mine had me creating a very basic contact form for a simple marketing website. It just so happens that shortly after creating the contact form I had to use a contact form on Ryan Lanciaux's blog and was impressed with the fact that when I received a response from Ryan, his email contained the country that my IP originated from (I know... such a simple thing impressed me). I now had to figure out how to add some of this sweetness to my own simple contact form. I found a couple of different methods for getting country [state] information from an IP and finally settled on a method that utilized the hostip.info website/database. The hostip website allows you to get the data in a couple different ways, you can get raw text (which my sample demonstrates); you can also get an XML data dump that includes lat/long. Here is a very basic method that can be used to get country and state information for an IP address:
private string GetCountryStateForIP(string ip)
{
try
{
//http://api.hostip.info/?ip=12.215.42.19
string ipUrl = "http://www.hostip.info/api/get.html?ip="
+ ip;
WebClient webClient = new WebClient();
Byte[] ipInfoBytes = webClient.DownloadData(ipUrl);
UTF8Encoding encoding = new UTF8Encoding();
string ipInfo = encoding.GetString(ipInfoBytes);
return string.Format("IP: {0} {1}Data: {2}",
ip, Environment.NewLine, ipInfo);
}
catch (Exception ex)
{
return string.Format("IP: {0} {1}Error: {2}",
ip, Environment.NewLine, ex.Message);
}
}
The comment in the code above contains the URL that will return the XML feed. My goal is to create a more robust method that gathers latitude and longitude information. I would actually like to go as far as to then take that latitude and longitude and generate a link to that location using Google Maps.

I've been toying with the idea of creating a blog for quite some time and finally decided to take the plunge in 2008. I had been looking for blogging platform that I could deploy on my host (www.godaddy.com) and that was written in a .NET language (preferably C#). When I stumbled upon BlogEngine.NET (http://www.dotnetblogengine.net/) I knew it would fit the bill. It was designed with extensibility as a goal, and out of the gate seemed to be quite hackable. So far BlogEngine.NET has been a snap to install and configure. I've been able to tweak the themes and have so far been able to make small code adjustments to the theme master pages. I am going to explore the creation of some small extensions that will help add some additional functionally to BlogEngine.NET that I believe my wife will be able to take advantage of on her instance of BlogEngine.NET.