In this paper we provide a foundation of a theory of contextual reasoning from the perspective of a theory of knowledge representation. Starting from the so-called metaphor of the box, we firstly show that the mechanisms of contextual reasoning proposed in the literature can be classified into three general forms (called localised reasoning, push and pop, and shifting). Secondly, we provide a justification of this classification, by showing that each mechanism corresponds to operating on a fundamental dimension along which context dependent representations may vary (namely, partiality, approximation, and perspective). From the previous analysis, we distill two general principles of a logic of contextual reasoning. Finally, we show that these two principles can be adequately formalised in the framework of MultiContext Systems. In the last part of the paper, we provide a practical illustration of the ideas discussed in the paper by formalising a simple scenario, called the Magic Box pro...