It have only three dictionaries. To shorten it, all my object models are "contained" as properties by one object of the types Persona
, Comunidad
or Concepto
. Also I've just "categorized" all my object models with interfaces, so I can recognize which type of object contains it and each object have an ID property given by the database which I use as a key, forced by the corresponding interface.
As a side note, I "stole" the TypeSwitch
class directly from this stackoverflow question this stackoverflow question.
It have only three dictionaries. To shorten it, all my object models are "contained" as properties by one object of the types Persona
, Comunidad
or Concepto
. Also I've just "categorized" all my object models with interfaces, so I can recognize which type of object contains it and each object have an ID property given by the database which I use as a key, forced by the corresponding interface.
As a side note, I "stole" the TypeSwitch
class directly from this stackoverflow question.
It have only three dictionaries. To shorten it, all my object models are "contained" as properties by one object of the types Persona
, Comunidad
or Concepto
. Also I've just "categorized" all my object models with interfaces, so I can recognize which type of object contains it and each object have an ID property given by the database which I use as a key, forced by the corresponding interface.
As a side note, I "stole" the TypeSwitch
class directly from this stackoverflow question.
The problem with that system is that it don't remove the objects at the correct time, since a reference is always stored at the dictionaries. Therefore my question about ConditionalWeakTable
.
The problem with that system is that it don't remove the objects at the correct time, since a reference is always stored at the dictionaries. Therefore my question about ConditionalWeakTable
.
Edit:
It seems that I wasn't clear enough of what I'm trying to achieve.
As I said early, the app have a Chrome alike principal tabcontrol, since I'm using WPF and MVVM, each tab have a view, a viewmodel and a model. Each tab is independent from the others so they don't know what object are using the other ones. Therefore, the user could open twice the same tab with the same objects, or tabs that share only some objects, which would lead to create the same objects twice or more, which I don't want, of course.
And that is it, I just want to not duplicate objects.
The APPModelControl
class have a single private instance created at the App
class, so there's no way to alter it directly, and "store" a reference of all objects created at different dictionaries.
The AppModelControlMessenger
class is just a messenger, it's static so it can be accessed from any part of the application. It sends a message to AppModelControl
asking if an object exists, so if the object exists, it don't get duplicated, I can just get the existant object through the messenger.
Edit:
It seems that I wasn't clear enough of what I'm trying to achieve.
As I said early, the app have a Chrome alike principal tabcontrol, since I'm using WPF and MVVM, each tab have a view, a viewmodel and a model. Each tab is independent from the others so they don't know what object are using the other ones. Therefore, the user could open twice the same tab with the same objects, or tabs that share only some objects, which would lead to create the same objects twice or more, which I don't want, of course.
And that is it, I just want to not duplicate objects.
The APPModelControl
class have a single private instance created at the App
class, so there's no way to alter it directly, and "store" a reference of all objects created at different dictionaries.
The AppModelControlMessenger
class is just a messenger, it's static so it can be accessed from any part of the application. It sends a message to AppModelControl
asking if an object exists, so if the object exists, it don't get duplicated, I can just get the existant object through the messenger.