After I wrote about how to check a website's position at the Google search result page, I thought it would be fun to write a little application that uses that method, but extend it to work with Yahoo and AltaVista as well. This is the result.
The application let you save the keywords of all the websites you want to check. Then just press the “Find positions” button and it automatically retrieves the data from the different search engines.
Installation
The application is deployed using ClickOnce, so Internet Explorer has to be your default browser for it to install. Afterwards you can change your default browser back to what it was.
Install the Search Engine Positioner
C# source code (49 KB)
One of the biggest problems with the different types of collections in the .NET Framework, is that they don’t tell you if the collection as been changed or not. If you have a Collection<int> that has to be persisted to a database, it would be a waste of resources to do so if the collection hasn’t been changed.
That’s why I found it necessary to override the generic Collection<> class to provide it with a property called IsChanged. Everytime you add or remove an item in the collection, the IsChanged property returns true. You can use the property like so:
if (collectionInstance.IsChanged)
{
//Persist to database
}
The code
/// <summary>
/// A generic collection with the ability to
/// check if it has been changed.
/// </summary>
[System.Serializable]
public class StateCollection<T> : System.Collections.ObjectModel.Collection<T>
{
#region Base overrides
/// <summary>
/// Inserts an element into the collection at the specified index and marks it changed.
/// </summary>
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, item);
_IsChanged = true;
}
/// <summary>
/// Removes all the items in the collection and marks it changed.
/// </summary>
protected override void ClearItems()
{
base.ClearItems();
_IsChanged = true;
}
/// <summary>
/// Removes the element at the specified index and marks the collection changed.
/// </summary>
protected override void RemoveItem(int index)
{
base.RemoveItem(index);
_IsChanged = true;
}
/// <summary>
/// Replaces the element at the specified index and marks the collection changed.
/// </summary>
protected override void SetItem(int index, T item)
{
base.SetItem(index, item);
_IsChanged = true;
}
#endregion
private bool _IsChanged;
/// <summary>
/// Gets if this object's data has been changed.
/// </summary>
/// <returns>A value indicating if this object's data has been changed.</returns>
public virtual bool IsChanged
{
get { return _IsChanged; }
set { _IsChanged = value; }
}
}