Created
March 20, 2016 23:44
-
-
Save AlphaGit/3012634ea3085fe80ccc to your computer and use it in GitHub Desktop.
Decoupled Producer/Consumer classes
This file contains hidden or 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
| public class Consumer { | |
| private IProducer _producer; | |
| // Constructor | |
| public Consumer(IProducer producer) { | |
| _producer = producer; | |
| } | |
| public void DoConsumption() { | |
| var value = _producer.DoProduction(); | |
| // do something with value | |
| } | |
| } |
This file contains hidden or 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
| public interface IProducer { | |
| object DoProduction(); | |
| } |
This file contains hidden or 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
| public class Producer: IProducer { | |
| public object DoProduction() { | |
| return someObject; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment