I am working on a game project using the Microsoft XNA infrastructure, although this question is a general one related to the decoupling of classes / systems.
Let's say I have a class (simplified for this example) as shown here:
public class GameCell
{
public Color Color { get; set; }
}
I would like to reuse as much code as possible between multiple platforms using C #.
The problem with direct redirection of the Color structure is that this type is defined in XNA assemblies, creating a strong connection (or dependency) between my code and XNA.
In another structure that I will use, it may (or not) have its own Color object with its own set of properties and API.
I would like to have the same “know” source file to automatically use XNA or another framework implementation.
I know other types of decoupling methods, such as IoC, but that would mean that I would connect different versions of the system / class instead of reusing the same class in different contexts.
Can this be done? how would you suggest keeping such a system portable?
I saw some cases (in your own development in C ++) where you would define a set of classes that reflect the classes you use in the structure (for example, here, define the color again), and so you can "re-display" it later, so that use different classes as needed.
#IFDEF using ( XNA ).
?