Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save darscan/593798 to your computer and use it in GitHub Desktop.
Save darscan/593798 to your computer and use it in GitHub Desktop.
private injection from troy
package
{
import private_injection;
class ClassWithPrivateInjection
{
include "inject.include.as";
private var mySecretWord:String;
public function speakSecretWord():void
{
trace(mySecretWord);
}
}
}
package
{
public function doPrivateInjection(instance:*, name:String, value:*):void
{
try
{
instance.private_injection::injectPrivates(name, value);
}
catch (e:Error)
{
// do nothing, ignore errors
}
}
}
private_injection function injectPrivates(name:String, value:*):void
{
try
{
this[name] = value;
}
catch (e:Error)
{
// ignore errors, do nothing
}
}
package
{
public namespace private_injection;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment