Suppose I have some extension methods but also need to extend the object's state. Seeing as there is no support for extension properties in C#, would using shared static Dictionary be a good solution?
For example something like this:
class Foo
{
// 3rd party class
}
static class Helper
{
private static Dictionary<Foo, Guid> guidDict = new Dictionary<Foo, Guid>();
public static void DoSomething(this Foo foo)
{
Guid guid = guidDict[foo];
// do stuff
}
public static void DoAnotherthing(this Foo foo)
{
Guid guid = guidDict[foo];
// do stuff
}
}
What are some other solutions?