Tuesday, June 20, 2006

Everybody loves Anonymous Delegates


public override int AddResource(T resource, string externalKey)
{
int internalKey = base.AddResource(resource, externalKey);

// When a resource is added it's reference is auto set one

resource.ReferencesAreZero += delegate(object sender, EventArgs eventArgs)
{
RemoveResource(internalKey);
};

return internalKey;
}

No comments: