I try to create an application that is able to run in Windows Azure cloud but also on a local server.
Most parts of the application already works on both without problem. But there are some features that I don’t know how to make them run on both, for example:
Users are able to upload attachments. In Azure the files are stored in the Windows Azure Storage, on the local server they should be stored in a local folder.
I have no idea how to manage this.
I’d like to suggest you to learn about inversion of control, because you’ll be able to switch file storage and other things depending on selected hosting platform.
For example, you’d have an interface called
IFileStoragehaving such methods (and more):And two implementations for
IFileStorage:At the end of the day, you’ll be doing that:
And some inversion of control configuration will map the appropiate
IFileStorageimplementation depending on hosting platform.If you want to learn more about inversion of control:
Finally, if you think this is the right way, check Castle Windsor, which is a great, solid and stable inversion of control (and other things) framework on top of .NET: