Is it possible to define a compiler constant based on PER-FILE / project-item?
Background: I want to achieve a database abstraction layer (DAL) that separates all read and write tasks, but retains a DAL that can do both, but without implementing the same methods several times (an abstract class means that for each instance there will be 1 instance class for each supported database type).
So, I want to separate my DAL as follows:
abstract class ReadDAL abstract class WriteDAL abstract class ReadWriteDAL (multiple-inheritance from Read&Write-DAL).
Unfortunately, this does not work, because C # does not support multiple inheritance.
Thus, one way to solve this problem would be to define interfaces:
abstract class ReadDAL : IReadDAL abstract class WriteDAL : IWriteDAL abstract class ReadWriteDAL : IReadDAL, IWriteDAL
However, if I do this, I will have to change the interface definition every time I change the method in one of the DALs and change the methods defined in ReadWriteDAL, and I need to copy-paste somewhere the implementation of the method, which means there will be a DRY mess - mismatch.
I realized what I could do by adding the same file a second time as a link and having a definition for each project element:
#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 determine the compiler constant for each file?
Or achieve the same effect?