static NKScriptTypeInfo() { var methods = NKScriptTypeInfo <T> .instanceMethods(typeof(NKScriptExport)); // Add/remove any extra exclusions here exclusion = methods; }
public async Task <NKScriptValue> bindPlugin(object obj, string ns) { await this.prepareForPlugin(); if ((this.id != null) || (context == null)) { return(null); } if (this.userContentController == null) { return(null); } this.id = (this.sequenceNumber++).ToString(); this.userContentController.NKaddScriptMessageHandler(this, id); if (obj.GetType() == typeof(Type)) { // Class, not instance, passed to bindPlugin -- to be used in Factory constructor/instance pattern in js isFactory = true; typeInfo = new NKScriptTypeInfo((Type)obj); // Need to store the channel on the class itself so it can be found when native construct requests come in from other plugins obj.setNKScriptChannel(this); } else { // Instance of Princpal passed to bindPlugin -- to be used in singleton/static pattern in js isFactory = false; typeInfo = new NKScriptTypeInfo(obj.GetType()); } _principal = new NKScriptValueNative(ns, this, obj); this.instances[0] = _principal; var script = new NKScriptSource(_generateStubs(typeInfo.Name), ns + "/plugin/" + typeInfo.Name + ".js"); NKLogging.log(script.source); await script.inject(context); return(_principal); }
internal void unbind() { if (id == null) { return; } id = null; instances.Clear(); if (isFactory) { _principal.nativeObject.setNKScriptChannel(null); } _principal = null; userContentController.NKremoveScriptMessageHandlerForName(id); _userContentController.SetTarget(null); _context.SetTarget(null); typeInfo = null; queue = null; instances = null; }