public static void debug(cape.LoggingContext context, string message) { if (context != null) { context.logDebug(message); } }
public static void info(cape.LoggingContext context, string message) { if (context != null) { context.logInfo(message); } }
public bool loadFile(cape.LoggingContext ctx, cape.File file) { if (!(file != null)) { ctx.logError("DynamicModule" + ": Null file"); return(false); } if (!file.isFile()) { ctx.logError("DynamicModule" + ": Not a file: `" + file.getPath() + "'"); return(false); } ctx.logDebug("Loading dynamic module: `" + file.getPath() + "'"); string error = null; ctx.logError("Loading assemblies on UWP: Not supported"); if (assembly == null) { if (error != null) { ctx.logDebug(error); } ctx.logError("Failed to load assembly: `" + file.getPath() + "'"); return(false); } ctx.logDebug("Assembly successfully loaded: `" + file.getPath() + "'"); return(true); }
public static void error(cape.LoggingContext context, string message) { if (context != null) { context.logError(message); } }
public static void warning(cape.LoggingContext context, string message) { if (context != null) { context.logWarning(message); } }
private bool executeSelect(cape.LoggingContext ctx, System.Collections.Generic.List <object> reads, System.Collections.Generic.List <object> writes) { var fdsetr = new System.Collections.Generic.List <System.Net.Sockets.Socket>(); var fdsetw = new System.Collections.Generic.List <System.Net.Sockets.Socket>(); if (readlist != null) { var n = 0; var m = readlist.Count; for (n = 0; n < m; n++) { var myo1 = readlist[n] as capex.net.IOManagerDotNetSelect.MyEntry; if (myo1 != null) { fdsetr.Add(myo1.getNetSocket()); } } } if (writelist != null) { var n2 = 0; var m2 = writelist.Count; for (n2 = 0; n2 < m2; n2++) { var myo2 = writelist[n2] as capex.net.IOManagerDotNetSelect.MyEntry; if (myo2 != null) { fdsetw.Add(myo2.getNetSocket()); } } } try { System.Net.Sockets.Socket.Select(fdsetr, fdsetw, null, -1); } catch (System.Exception e) { cape.Log.error(ctx, "Call to Select failed: " + e.ToString()); return(false); } foreach (System.Net.Sockets.Socket socket in fdsetr) { var e = getEntryForSocket(socket, readlist); if (e != null) { cape.Vector.append(reads, e); } } foreach (System.Net.Sockets.Socket socket in fdsetw) { var e = getEntryForSocket(socket, writelist); if (e != null) { cape.Vector.append(writes, e); } } return(true); }
public static capex.util.DynamicModule forFile(cape.LoggingContext ctx, cape.File file) { var v = new capex.util.DynamicModule(); if (v.loadFile(ctx, file) == false) { v = null; } return(v); }
public static bool isModuleFile(cape.LoggingContext ctx, cape.File file) { if (!(file != null)) { return(false); } if (file.hasExtension("dll")) { return(true); } return(false); }
public object createObject(cape.LoggingContext ctx, string className) { if (!(assembly != null)) { ctx.logError("createObject: No assembly has been loaded."); return(null); } System.Type type = null; type = assembly.GetType(className); if (!(type != null)) { ctx.logError("Failed to find class `" + className + "' in dynamic module: `" + getModuleDescription() + "'"); return(null); } string error = null; System.Reflection.ConstructorInfo constructor = null; ctx.logError("GetConstructor on UWP: Not supported"); if (constructor == null) { if (error != null) { ctx.logDebug(error); } ctx.logError("Failed to find a default constructor in class `" + className + "' in module: `" + getModuleDescription() + "'"); return(null); } object v = null; try { v = constructor.Invoke(null); } catch (System.Exception e) { error = e.ToString(); } if (error != null) { ctx.logDebug(error); ctx.logError("Failed to call default constructor of class `" + className + "' in module: `" + getModuleDescription() + "'"); return(null); } if (v == null) { ctx.logError("Constructor called without error for class `" + className + "' in module `" + getModuleDescription() + "', but no object was created!"); return(null); } return(v); }
public bool executeStaticMethod(cape.LoggingContext ctx, string entityName, string methodName, object[] @params) { if (!(assembly != null)) { ctx.logError("executeStaticMethod: No assembly has been loaded."); return(false); } System.Type mainType = null; mainType = assembly.GetType(entityName); if (!(mainType != null)) { ctx.logError("Failed to find class `" + entityName + "' in dynamic module: `" + getModuleDescription() + "'"); return(false); } string error = null; System.Reflection.MethodInfo methodRef = null; ctx.logError("GetMethod on UWP: Not supported"); if (methodRef == null) { if (error != null) { ctx.logDebug(error); } ctx.logError("Failed to find method `" + methodName + "' in entity `" + entityName + "' in module: `" + getModuleDescription() + "'"); return(false); } try { methodRef.Invoke(null, @params); } catch (System.Exception e) { error = e.ToString(); } if (error != null) { ctx.logDebug(error); ctx.logError("Failed to call method `" + methodName + "' in entity `" + entityName + "' in module: `" + getModuleDescription() + "'"); return(false); } return(true); }
public static capex.util.DynamicModule forObject(cape.LoggingContext ctx, object oo) { if (!(oo != null)) { return(null); } System.Reflection.Assembly asm = null; var type = oo.GetType(); if (type != null) { asm = System.Reflection.IntrospectionExtensions.GetTypeInfo(type).Assembly; } if (!(asm != null)) { return(null); } var v = new capex.util.DynamicModule(); v.setAssembly(asm); return(v); }
public virtual bool execute(cape.LoggingContext ctx) { return(false); }
public static capex.net.SSLSocket forServer(capex.net.ConnectedSocket cSocket, cape.File certFile = null, cape.File keyFile = null, cape.LoggingContext ctx = null, bool acceptInvalidCertificate = false, string passphrase = null) { return(capex.net.SSLSocket.createInstance(cSocket, null, ctx, certFile, keyFile, true, acceptInvalidCertificate, passphrase)); }
public static capex.net.SSLSocket forClient(capex.net.ConnectedSocket cSocket, string hostAddress, cape.LoggingContext ctx = null, bool acceptInvalidCertificate = false, string passphrase = null) { return(capex.net.SSLSocket.createInstance(cSocket, hostAddress, ctx, null, null, false, acceptInvalidCertificate, passphrase)); }
public capex.data.SQLDatabase setLogger(cape.LoggingContext v) { logger = v; return(this); }
public static capex.text.TextTemplate forJSONString(string text, System.Collections.Generic.List <cape.File> includeDirs = null, cape.LoggingContext logContext = null) { var v = new capex.text.TextTemplate(); v.setLogContext(logContext); v.setText(text); v.setType(capex.text.TextTemplate.TYPE_JSON); v.setMarkerBegin("{{"); v.setMarkerEnd("}}"); if (v.prepare(includeDirs) == false) { v = null; } return(v); }
public static capex.text.TextTemplate forString(string text, string markerBegin, string markerEnd, int type = 0, System.Collections.Generic.List <cape.File> includeDirs = null, cape.LoggingContext logContext = null) { var v = new capex.text.TextTemplate(); v.setLogContext(logContext); v.setText(text); v.setType(type); v.setMarkerBegin(markerBegin); v.setMarkerEnd(markerEnd); if (v.prepare(includeDirs) == false) { v = null; } return(v); }
public static capex.text.TextTemplate forFile(cape.File file, string markerBegin, string markerEnd, int type = 0, System.Collections.Generic.List <cape.File> includeDirs = null, cape.LoggingContext logContext = null) { if (file == null) { return(null); } var text = file.getContentsString("UTF-8"); if (object.Equals(text, null)) { return(null); } var ids = includeDirs; if (ids == null) { ids = new System.Collections.Generic.List <cape.File>(); ids.Add(file.getParent()); } return(capex.text.TextTemplate.forString(text, markerBegin, markerEnd, type, ids, logContext)); }
public capex.text.TextTemplate setLogContext(cape.LoggingContext v) { logContext = v; return(this); }
public void reportAsUnsupported(cape.LoggingContext ctx) { cape.Log.error(ctx, "Unsupported command line parameter: `" + arg + "'"); }
public static capex.net.SSLSocket createInstance(capex.net.ConnectedSocket cSocket, string serverAddress = null, cape.LoggingContext ctx = null, cape.File certFile = null, cape.File keyFile = null, bool isServer = false, bool acceptInvalidCertificate = false, string passphrase = null) { if (!(cSocket != null)) { return(null); } capex.net.SSLSocket v = null; return(v); }
public static capex.data.SQLiteDatabase forFile(cape.File file, bool allowCreate = true, cape.LoggingContext logger = null) { if (!(file != null)) { return(null); } var v = capex.data.SQLiteDatabase.instance(); if (!(v != null)) { return(null); } if (logger != null) { v.setLogger(logger); } if (!file.isFile()) { if (allowCreate == false) { return(null); } var pp = file.getParent(); if (pp.isDirectory() == false) { if (pp.createDirectoryRecursive() == false) { cape.Log.error(v.getLogger() as cape.LoggingContext, "Failed to create directory: " + pp.getPath()); } } if (v.initialize(file, true) == false) { v = null; } } else if (v.initialize(file, false) == false) { v = null; } return(v); }
public override bool execute(cape.LoggingContext ctx) { exitflag = false; running = true; var signalSocket = openSignalSocket(); if (signalSocket != null) { var ee = add((object)signalSocket); if (ee != null) { ee.setReadListener(() => { onReadReady(signalSocket); }); } } var reads = new System.Collections.Generic.List <object>(); var writes = new System.Collections.Generic.List <object>(); var now = new cape.TimeValue(); cape.Log.debug(ctx, "IOManagerDotNetSelect" + " started"); while (exitflag == false) { if (executeSelect(ctx, reads, writes) == false) { continue; } if (reads != null) { var n = 0; var m = reads.Count; for (n = 0; n < m; n++) { var ele = reads[n] as capex.net.IOManagerDotNetSelect.MyEntry; if (ele != null) { ele.onReadReady(); } } } if (writes != null) { var n2 = 0; var m2 = writes.Count; for (n2 = 0; n2 < m2; n2++) { var ele1 = writes[n2] as capex.net.IOManagerDotNetSelect.MyEntry; if (ele1 != null) { ele1.onWriteReady(); } } } cape.Vector.clear(reads); cape.Vector.clear(writes); if (cape.Vector.isEmpty(timers) == false) { cape.SystemClock.update(now); System.Collections.Generic.List <capex.net.IOManagerDotNetSelect.MyTimer> timersToRemove = null; if (timers != null) { var n3 = 0; var m3 = timers.Count; for (n3 = 0; n3 < m3; n3++) { var timer = timers[n3]; if (timer != null) { if (timer.process(now) == false) { if (timersToRemove == null) { timersToRemove = new System.Collections.Generic.List <capex.net.IOManagerDotNetSelect.MyTimer>(); } timersToRemove.Add(timer); } } } } if (timersToRemove != null) { var n4 = 0; var m4 = timersToRemove.Count; for (n4 = 0; n4 < m4; n4++) { var timer1 = timersToRemove[n4]; if (timer1 != null) { cape.Vector.removeValue(timers, timer1); } } } } } if (signalSocket != null) { signalSocket.close(); signalSocket = null; } cape.Vector.clear(readlist); cape.Vector.clear(writelist); signalPort = -1; running = false; cape.Log.debug(ctx, "IOManagerDotNetSelect" + " ended"); return(true); }