Is it possible to define a compiler constant on a PER-FILE/project-item basis ?
Background: I want to achieve a Database Abstraction Layer (DAL), that separates all read, and write tasks, but retain a DAL that can do both, but without implementing the same methods multiple times (abstract class means there will be 1 instance class for every supported database type).
So I want to separate my DAL like this:
abstract class ReadDAL
abstract class WriteDAL
abstract class ReadWriteDAL (multiple-inheritance from Read&Write-DAL).
Unfortunately, that doesn't work, because C# doesn't support multiple inheritance.
So one way around this problem would be by defining interfaces:
abstract class ReadDAL : IReadDAL
abstract class WriteDAL : IWriteDAL
abstract class ReadWriteDAL : IReadDAL, IWriteDAL
However, if I do this, I'll have to change the interface definition every time I change a method in one of the DALs, and change the methods defined in ReadWriteDAL, and I have to copy-paste somewhere the method implementation, which means there will be a DRY-noncompliance mess.
I figured what I could do was adding the same file a second time as link, and having a define on a per-project-item basis:
#if SOMECONSTANT // true if file is PartialReadDAL.cs
public partial abstract class ReadDAL
#else // false if "file" is link called "PartialReadWriteDAL.cs" symlinking to PartialReadDAL.cs
public partial abstract class ReadWriteDAL
#endif
and here some implementation.
But can I somehow define a compiler constant per file ?
Or achieve a similar effect somehow ?