Last active
December 21, 2015 09:09
-
-
Save dadarek/6283369 to your computer and use it in GitHub Desktop.
How to inject globals without affecting client code.
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 SomeClass{ | |
private int someValue; | |
public SomeClass( int someValue ){ | |
this.someValue = someValue; | |
} | |
public int SomeFunction(){ | |
return someValue + GlobalReference.someFunction(); | |
} | |
} | |
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 SomeClass{ | |
private int someValue; | |
private Global myReference; | |
public SomeClass( int someValue ) : | |
this( GlobalReference, someValue ) | |
{ } | |
public SomeClass( Global global, int someValue ){ | |
this.myReference = global; | |
this.someValue = someValue; | |
} | |
public void SomeFunction(){ | |
return someValue + myReference.someFunction(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment