runtime

Adding rows to a WPF datagrid where columns are not known until runtime

吃可爱长大的小学妹 提交于 2019-12-06 00:26:12
问题 I'm trying to add data to a datagrid (in fact, any control that presents data in a grid will do), but the columns (both names and numbers) are not known until runtime. The columns I DO know how to create: E.g DataGridTextColumn textColumn = new DataGridTextColumn(); textColumn.Header = column.DisplayName; MyDataGrid.Columns.Add(textColumn); But how do I add rows? I don't see how I can use binding because my data is not contained in an object with known properties. For example, data for each

iOS - runtime - getProperty - getIvar

拟墨画扇 提交于 2019-12-05 23:47:22
iOS 中的runtime可以获取一个类的所有属性,成员变量,方法,协议等 通过获取到方法名,项目中可以直接通过selector 去调用第三方的方法,实现我们直接调用第三方api无法实现的方法 //属性 +(void)getProperties:(NSString*)className { u_int count = 0; objc_property_t *properties = class_copyPropertyList(NSClassFromString(className), &count); for (int i = 0; i < count; i++) { const char *propertyName = property_getName(properties[i]); const char *attributes = property_getAttributes(properties[i]); NSString *str = [NSString stringWithCString:propertyName encoding:NSUTF8StringEncoding]; NSString *attributesStr = [NSString stringWithCString:attributes encoding:NSUTF8StringEncoding];

Print callstack at runtime (XCode)

爱⌒轻易说出口 提交于 2019-12-05 21:37:20
Is it possible? I have found solution for Visual Studio Print n levels of callstack? To print a backtrace at runtime programmatically, you can use this function: #import <execinfo.h> void PrintBacktrace ( void ) { void *callstack[128]; int frameCount = backtrace(callstack, 128); char **frameStrings = backtrace_symbols(callstack, frameCount); if ( frameStrings != NULL ) { // Start with frame 1 because frame 0 is PrintBacktrace() for ( int i = 1; i < frameCount; i++ ) { printf("%s\n", frameStrings[i]); } free(frameStrings); } } Use bt (or backtrace command in gdb console). Here's more info on

Setting Clojure “constants” at runtime

。_饼干妹妹 提交于 2019-12-05 20:25:42
问题 I have a Clojure program that I build as a JAR file using Maven. Embedded in the JAR Manifest is a build-version number, including the build timestamp. I can easily read this at runtime from the JAR Manifest using the following code: (defn set-version "Set the version variable to the build number." [] (def version (-> (str "jar:" (-> my.ns.name (.getProtectionDomain) (.getCodeSource) (.getLocation)) "!/META-INF/MANIFEST.MF") (URL.) (.openStream) (Manifest.) (.. getMainAttributes) (.getValue

Spring优雅关闭之:ShutDownHook

你。 提交于 2019-12-05 20:05:06
转载自: https://blog.csdn.net/qq_26323323/article/details/89814410 1. Runtime.addShutDownHook(Thread hook) // 创建HookTest,我们通过main方法来模拟应用程序 public class HookTest { public static void main(String[] args) { // 添加hook thread,重写其run方法 Runtime.getRuntime().addShutdownHook(new Thread(){ @Override public void run() { System.out.println("this is hook demo..."); // TODO } }); int i = 0; // 这里会报错,我们验证写是否会执行hook thread int j = 10/i; System.out.println("j" + j); } } 2. Runtime.addShutDownHook(Thread hook)应用场景 * 程序正常退出 * 使用System.exit() * 终端使用Ctrl+C触发的中断 * 系统关闭 * OutofMemory宕机 * 使用Kill pid杀死进程(使用kill -9是不会被调用的

Android动态获取U盘路径

不问归期 提交于 2019-12-05 20:03:38
网上很多博客说了很多的办法,大多数不是获取的外接U盘,而获取到的是内置SD,可以通过系统mount命令来查找挂载的设备,具体的解决办法如下: Runtime runtime = Runtime.getRuntime(); Process proc = runtime.exec(new String[] { "/system/bin/sh", "-c", "mount | grep usb |busybox awk '{if($3~/usb/)print $3}'" }); InputStream is = proc.getInputStream(); InputStreamReader isr = new InputStreamReader(is, "GBK"); String line = ""; int loop = 0; BufferedReader br = new BufferedReader(isr); while ((line = br.readLine()) != null) { Log.d(TAG, "loop " + loop + " readLine = " + line); //此处保存至路径的buffer中供使用 } 这样获取到的是动态挂载在系统的所有USB路径,其中不同的方案商肯awk命令中截取的字段不一样,可以按需修改(即$后的数字)

javaSE_获取java虚拟机信息

我只是一个虾纸丫 提交于 2019-12-05 19:45:05
获取 java 虚拟机信息 程序是在 java 虚拟机中运行的,动态获取虚拟机中的运行时环境: 如: //Java 虚拟机中的内存总量,以字节为单位 int total = ( int )Runtime. getRuntime ().totalMemory()/1024/1024; System. out .println( "内存总量 :" + total + "mb" ); int free = ( int )Runtime. getRuntime ().freeMemory()/1024/1024; System. out .println( "空闲内存量 : " + free + "mb" ); int max = ( int ) (Runtime. getRuntime ().maxMemory() /1024 / 1024); System. out .println( "最大内存量 : " + max + "mb" ); 输出: 内存总量 : 120mb 空闲内存量 : 118mb 最大内存量 : 1790mb 其他信息,如: public static void main(String[] args ) { //==========================Memory========================= System. out .println

Java常见异常(Runtime Exception )小结

放肆的年华 提交于 2019-12-05 19:43:58
java.lang.NullPointerException 程序遇上了空指针 UnsupportedOperationException 不支持的操作 IllegalArgumentException 非法参数 IndexOutOfBoundsException 索引出界 IllegalStateException 非法状态 SQLException 操作数据库异常类。 ClassCastException 数据类型转换异常。 NumberFormatException 字符串转换为数字类型时抛出的异常。 ArithmeticException 除数为0的异常 BufferOverflowException 缓冲区上溢异常 BufferUnderflowException 缓冲区下溢异常 IndexOutOfBoundsException 出界异常 NullPointerException 空指针异常 EmptyStackException 空栈异常 IllegalArgumentException 不合法的参数异常 NegativeArraySizeException NoSuchElementException SecurityException SystemException UndeclaredThrowableException java.lang

Delphi - Referencing Components created at Runtime

自作多情 提交于 2019-12-05 19:39:49
I'm using Delphi 5 and I'm creating a number of panels at runtime, then creating buttons on the panels, obviously again at runtime. I need to do it this way because I may need to dynamically create more panel/button combinations in the future. I can do all of this, but I'm at a loss as to how to reference the panels I've created, because I can't find a way to access the panels' component name. Hunting around the Internet I've found that I can use FindComponent to find the panel components by name, but I still don't know how to use that name, because I can't use a string variable to refer to it

JavaScript 关于setTimeout与setInterval的小研究

时光怂恿深爱的人放手 提交于 2019-12-05 19:33:40
说明 在开发功能“轨迹播放”时,遇到了一个情况。 原先同事已经开发了一版,这次有个新功能:点击线上任意一点后可以从点击处重新播放。 看了一下原来的版本,发现同时使用了setTimeout和setInterval,两者配合实现点线播放。 简单结构如下 function test() { setInterval(function () { console.log("interval"); //省略插值方法得到arr (...) play(arr); }, 2000); } function play(arr) { setTimeout(function () { play(arr); console.log("setTimeout"); }, 40); } 我觉得这个结构欠妥,两个定时器配合必定会出现失误!因此重构了一版,将两个定时器改为一个,用setInterval解决。 但是此时我并不知道欠妥欠在什么地方,缺乏理论支持,现在闲下来仔细研究了一下 找问题 在仔细研究了旧版本后,我先把旧版本结构扒了出来,排除其他因素,自己模拟了一个简单版(就是上面的代码) setTimeout:在执行时,是在载入后延迟指定时间后,去执行一次表达式,仅执行一次 setInterval:在执行时,它从载入后,每隔指定的时间就执行一次表达式 实验一:在使用setInterval和setTimeout方法上