Skip to content

Instantly share code, notes, and snippets.

@dadarek
Last active December 21, 2015 09:09
Show Gist options
  • Save dadarek/6283369 to your computer and use it in GitHub Desktop.
Save dadarek/6283369 to your computer and use it in GitHub Desktop.
How to inject globals without affecting client code.
class SomeClass{
private int someValue;
public SomeClass( int someValue ){
this.someValue = someValue;
}
public int SomeFunction(){
return someValue + GlobalReference.someFunction();
}
}
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