You are correct in that you cannot maintain state using extension methods, but you also cannot have the ability to expand. They can only manipulate how you could have access anyway.
However, I do not believe that a static dictionary will also help. It would be good, perhaps, to maintain the general state, but not the state of the object. Are you doing something like the following? Is there a unique unique identifier for each object object, so that you can add a state variable to the dictionary that will be bound to this object? It seems like a good round, if that's what you are trying
Assuming you have no control over the class itself (hence the need to extend it in some way), can you inherit this object? Then, of course, you can do what you need.
source share