public static PythonModule CreateModule(dynamic instance, PythonHelper pythonHelper) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } if (pythonHelper == null) { throw new ArgumentNullException(nameof(pythonHelper)); } return(ObjectFactory.GetActivator <PythonModule>( typeof(PythonModule).GetConstructors().First())(instance, pythonHelper)); }
public string Register(string id, dynamic func, PythonHelper pythonHelper) { if (string.IsNullOrEmpty(id)) { throw new ArgumentException(nameof(id)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } object LateBoundMethod(params object[] args) { var objs = PythonParser.Parse(args); return(pythonHelper.Call(func, objs)); } RpcRegister.RegisterMethod(id, LateBoundMethod); return(id); }
public static ClassWrapper <IPythonPacket> CreatePacket(string interfaceName, dynamic instance, PythonHelper pythonHelper) { if (string.IsNullOrEmpty(interfaceName)) { throw new ArgumentNullException(nameof(interfaceName)); } if (instance == null) { throw new ArgumentNullException(nameof(instance)); } if (pythonHelper == null) { throw new ArgumentNullException(nameof(pythonHelper)); } var luaPacket = ObjectFactory.GetActivator <IPythonPacket>( typeof(PythonPacket).GetConstructors().First())(interfaceName, instance, pythonHelper); return(new ClassWrapper <IPythonPacket>(luaPacket)); }