Tuesday, October 07, 2008

What’s the next piece of open source software that Microsoft should embrace?

After the recent announcement by Scott Guthrie that JQuery would receive official support from Microsoft (http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx), many people see that as the heralding of a new dawn.

We missed out on NUnit (MsTest), NDoc (Sandcastle) and NHibernate (Linq to SQL/Entity Framework) for sure, but what do you think should be embraced next?

 

Post your answer here:

http://stackoverflow.com/questions/173996/whats-the-next-piece-of-open-source-software-that-microsoft-should-embrace
Tuesday, October 07, 2008 1:00:57 AM (New Zealand Daylight Time, UTC+13:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Saturday, September 27, 2008

Bail Out Truth

wpcbe080924

Saturday, September 27, 2008 4:38:29 PM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, September 25, 2008

Warriors Stuff the Chooks


19092008085
Originally uploaded by An Irishman Down Under
Woo hoo, bring on manly!
Thursday, September 25, 2008 10:29:46 PM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [0]  |  Trackback

Tommy shopping and at the zoo

230920085602309200855923092008558230920085562309200855423092008552230920085502309200854830082008541300820085403008200853816082008531

Thursday, September 25, 2008 10:21:03 PM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Saturday, September 20, 2008

Monetary Reform the only answer to global credit crisis

I believe the problems experienced around the world with the global credit crisis arise from a fundamental problem in our definition of money and the way most modern industrialized nations have structured control over management of the money supply.

Neither Barack Obama or John McCain have any intention of enacting any sort of monetary reform as far as i can tell. Unfortunately, the only person who i think agrees with all this in the US is Ron Paul http://www.campaignforliberty.com/, and i don’t agree with much else of his!

http://en.wikipedia.org/wiki/American_Monetary_Institute

“If money is a commodity to be traded, then all that matters is that the money is 100% backed by some commodity, like gold or silver for example. If money is credit, then it makes sense that bankers control it, as they do in the United States today. But if money is an artifact of law, whose value is derived from law (payment of taxes and legal tender laws) then the Institute argues it would only be proper for the government to issue, and control the money supply.”

http://www.monetary.org/need_for_monetary_reform.html

Monetary reform is achieved in 3 parts which must be enacted together for it to work. Any one or any two of them alone won’t do it, but could actually further harm the monetary situation.

1. First, incorporate the Federal Reserve System into the U.S. Treasury where all new money is created by government as money, not interest-bearing debt, and spent into circulation to promote the general welfare; monitored to be neither inflationary nor deflationary.

2. Second, halt the banks privilege to create money by ending the fractional reserve system in a gentle and elegant way. All the past monetized private credit is converted into U.S. government money. Banks then act as intermediaries accepting savings deposits and loaning them out to borrowers; what people think they do now.

3. Third, spend new money into circulation on infrastructure, including education and healthcare needed for a growing society, starting with the $1.6 trillion that the American Society of Civil Engineers estimate is needed for infrastructure repair; creating good jobs across our nation, re-invigorating local economies and re-funding government at all levels.

REVOLUTION!

Saturday, September 20, 2008 4:22:36 PM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, September 08, 2008

Tommy on the Train and in the Snow!

DSC03595DSC03593DSC03591DSC03587DSC03597DSC03590DSC03587DSC03586DSC03585DSC03582DSC03581DSC03579DSC03576DSC03574DSC03573DSC03561DSC03558DSC03565DSC03569

Monday, September 08, 2008 11:40:19 PM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Saturday, August 16, 2008

Entity Framework - Key Extension Methods

We created the following extension methods for entity framework to avoid code bloat in consuming applications when working with these key types. I hope you find them useful if you are working with the Entity Framework.

 

EntityObject

/// <summary>
/// Extension methods for EntityObject
/// </summary>
public static class EntityObjectExtensions
{

    /// <summary>
    /// Gets the original value for a modified entity object's property
    /// </summary>
    /// <returns>the value before the property was modified</returns>
    public static T GetOriginalValue<T>(this EntityObject entityObject, string propertyName)
    {
        if (entityObject == null)
            return default(T);
        if (entityObject.EntityState == EntityState.Modified)
        {
            ObjectContext context = [YOUR OBJECT CONTEXT]
            ObjectStateEntry stateEntry = null;
            context.ObjectStateManager.TryGetObjectStateEntry(entityObject, out stateEntry);

            if (stateEntry != null)
                return (T)stateEntry.OriginalValues.GetValue(stateEntry.OriginalValues.GetOrdinal(propertyName));

        }

        // return the value of the property
        return (T)entityObject.GetType().GetProperty(propertyName).GetValue(entityObject, null);
    }

EntityCollection<T>

/// <summary>
   /// Extension methods for EntityCollection
   /// </summary>
   public static class EntityCollectionExtensions
   {
       /// <summary>
       /// Loads the entity collection if it hasn't already been loaded
       /// </summary>
       /// <typeparam name="T">Type of entity collection</typeparam>
       /// <param name="entityCollection">Entity collection to potentially load entities into</param>
       /// <param name="entitySource">The source entity which has the entity collection relationship (modified or unchanged only)</param>
       public static void EnsureLoaded<T>(this EntityCollection<T> entityCollection, EntityObject entitySource) where T : class, IEntityWithRelationships
       {
           if (entitySource != null && entityCollection != null && !entityCollection.IsLoaded )
           {
               if (entitySource.EntityState == System.Data.EntityState.Modified || entitySource.EntityState == System.Data.EntityState.Unchanged)
               {
                   entityCollection.Load();
               }
           }
       }

       /// <summary>
       /// Returns the collection as a queryable type
       /// </summary>
       /// <typeparam name="T">Type of entity collection</typeparam>
       /// <param name="entityCollection">Entity collection to return as a queryable object</param>
       /// <param name="ensureLoaded">Flag to determine if to load the collection if it has not been done so already</param>
       /// <returns>Queryable object for the in memory collection</returns>
       public static IQueryable<T> AsQueryable<T>(this EntityCollection<T> entityCollection, bool ensureLoaded, EntityObject entitySource) where T : class, IEntityWithRelationships
       {
           if (ensureLoaded)
               EnsureLoaded(entityCollection, entitySource);
           return entityCollection.AsQueryable();
       }

 

EntityReference<T>

 

/// <summary>
   /// Extension methods for EntityReference
   /// </summary>
   public static class EntityReferenceExtensions
   {

       /// <summary>
       /// Loads the entity reference or its value if it hasn't already been loaded.
       /// </summary>
       /// <typeparam name="T">Type of entity reference</typeparam>
       /// <param name="entitySource">The source entity which has the entity reference relationship (added, modified or unchanged only)</param>
       public static void EnsureLoaded<T>(this EntityReference<T> entityReference, EntityObject entitySource) where T : class, IEntityWithRelationships
       {
           if (entitySource != null && entityReference != null && !entityReference.IsLoaded && entityReference.EntityKey != null)
           {
               if (entitySource.EntityState == System.Data.EntityState.Added) // add the value directly as load will throw
               {
                   if (entityReference.Value == null)
                       entityReference.Value = LoadByKey<T>(entityReference.EntityKey);
               }
               else if (entitySource.EntityState == System.Data.EntityState.Modified || entitySource.EntityState == System.Data.EntityState.Unchanged)
               {
                   entityReference.Load();
               }
           }
       }

privateT LoadByKey<T>(object entityKey)
{
    if (entityKey == null)
        throw new ArgumentNullException("Supplied entity key is null, unable to load entity", "entityKey");
    // make sure the object is loaded in the object context
    ObjectContext objectContext = [YOUR OBJECT CONTEXT];
    EntityKey key = (EntityKey)entityKey;
    ObjectStateEntry entry;
    if (!objectContext.ObjectStateManager.TryGetObjectStateEntry(entityKey, out entry) || entry.Entity == null)
    {
        return (T)objectContext.GetObjectByKey(key);
    }
    return (T)entry.Entity;
}

       /// <summary>
       /// Whether or not the entity reference has an entity key with a value present
       /// </summary>
       public static bool HasEntityKeyFirstValue<T>(this EntityReference<T> entityReference) where T : class, IEntityWithRelationships
       {
           return entityReference != null && entityReference.EntityKey.HasFirstValue<int>();
       }

       /// <summary>
       /// Get entity key with a value present
       /// </summary>
       public static int GetEntityKeyFirstValue<T>(this EntityReference<T> entityReference) where T : class, IEntityWithRelationships
       {
           if (entityReference != null)
               return entityReference.EntityKey.GetFirstValue<int>();
           return 0;
       }

 

EntityKey

 

/// <summary>
   /// Extension methods for EntityKey
   /// </summary>
   public static class EntityKeyExtensions
   {

       /// <summary>
       /// Gets the first entity key value
       /// </summary>
       /// <returns>the first entity key value</returns>
       public static T GetFirstValue<T>(this EntityKey entityKey)
       {
           if (entityKey != null && entityKey.EntityKeyValues != null && entityKey.EntityKeyValues.Length > 0)
               return (T)entityKey.EntityKeyValues.First().Value;
           return default(T);
       }

       /// <summary>
       /// Sets the first entity key value
       /// </summary>
       public static void SetFirstValue<T>(this EntityKey entityKey, T value)
       {
           if (entityKey != null && entityKey.EntityKeyValues != null && entityKey.EntityKeyValues.Length > 0)
               entityKey.EntityKeyValues.First().Value = value;
           return;
       }

       /// <summary>
       /// Whether or not the entity key has a first value
       /// </summary>
       public static bool HasFirstValue<T>(this EntityKey entityKey)
       {
           var firstValue = GetFirstValue<T>(entityKey);
           var defaultValue = default(T);
           return (!firstValue.Equals(defaultValue));
       }

Saturday, August 16, 2008 3:26:05 PM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, August 15, 2008

Tommy has a new bed

Friday, August 15, 2008 12:47:57 AM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [1]  |  Trackback

Tommy Goes on Holiday

Friday, August 15, 2008 12:37:04 AM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Saturday, August 09, 2008

Tamaki Drive Sunset

All i can say is roll on spring....Probably my favouritest part of auckland is the tamaki drive stretch out east. And sometimes you get blindingly beautiful sunsets back across the city view.

08042008231

Saturday, August 09, 2008 10:16:26 PM (New Zealand Standard Time, UTC+12:00)  #    Disclaimer  |  Comments [0]  |  Trackback