Created
September 17, 2016 21:26
-
-
Save tpresthus/4854f319e91d72167dc8616e0b69de42 to your computer and use it in GitHub Desktop.
Example of IoC with ServiceLocator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Autopilot | |
{ | |
// Attempt to overtake the next car | |
// by signalling a turn, shifting to a lower gear | |
// and turning left (hoping that we're not in Britain) | |
public async void Overtake() | |
{ | |
using(BlinkerService.Current.SignalLeft()) | |
{ | |
await ShifterService.Current.GearDown(); | |
await SteeringService.Current.TurnLeft(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment