method-names

Catching calling method name in IDbCommandInterceptor

旧巷老猫 提交于 2021-02-10 05:06:34
问题 I am using IDbCommandInterceptor to catch Entity Framework queries. This way I can access some crucial information such as DbParameter s and DbCommand etc. Bu I also need to get where this query is called from. I have tried to get this by by using StackTrace : StackTrace stackTrace = new StackTrace(); System.Reflection.MethodBase methodBase = stackTrace.GetFrame(1).GetMethod(); This might work in regular method calls, but in this instance since I am intercepting the Entity Framework mechanism

Catching calling method name in IDbCommandInterceptor

*爱你&永不变心* 提交于 2021-02-10 05:05:36
问题 I am using IDbCommandInterceptor to catch Entity Framework queries. This way I can access some crucial information such as DbParameter s and DbCommand etc. Bu I also need to get where this query is called from. I have tried to get this by by using StackTrace : StackTrace stackTrace = new StackTrace(); System.Reflection.MethodBase methodBase = stackTrace.GetFrame(1).GetMethod(); This might work in regular method calls, but in this instance since I am intercepting the Entity Framework mechanism

G++ compiler cannot distinguish variable and function with the same name? [duplicate]

牧云@^-^@ 提交于 2020-02-02 11:16:22
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Class method and variable with same name, compile error in C++ not in Java? The G++ compiler would complain when my class member name and member function name are the same. It seems that whenever a variable name happens to be the same as a function name, the compiler would complain. In Java, it is not the case. I just wonder why the G++ compiler cannot distinguish a variable name from a function name since the

G++ compiler cannot distinguish variable and function with the same name? [duplicate]

断了今生、忘了曾经 提交于 2020-02-02 11:14:04
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Class method and variable with same name, compile error in C++ not in Java? The G++ compiler would complain when my class member name and member function name are the same. It seems that whenever a variable name happens to be the same as a function name, the compiler would complain. In Java, it is not the case. I just wonder why the G++ compiler cannot distinguish a variable name from a function name since the

Java, method name via reflection for logging

折月煮酒 提交于 2019-12-24 15:19:07
问题 Working on a quick logging utility method. Normally I would use Aspects for this but working in the Android SDK where there isnt support for that. How would I go about grabbing a method name in a generic way using reflection? Also any performance hit in java with reflection ? 回答1: Something like this will probably work: Thread.currentThread().getStackTrace()[0].getMethodName() 来源: https://stackoverflow.com/questions/28948076/java-method-name-via-reflection-for-logging

Is there a particular naming convention for Java methods that throw exceptions?

我与影子孤独终老i 提交于 2019-12-23 07:37:08
问题 I'm tempted to add a suffix like "Ex" to differentiate methods (with similar signatures) that throw Exceptions from those that don't. Is there such a convention? 回答1: Yes, you name them the same as methods that don't. Isn't the exception specification enough? Edit: If you have similar methods that throw/not throw, I recommend the Parse / TryParse pattern ( Parse being replaced by the operation). .NET Framework uses it frequently ( Dictionary<T,K>.TryGetValue , Monitor.TryEnter , int.TryParse

How to disambiguate links to methods in scaladoc?

和自甴很熟 提交于 2019-12-20 11:05:49
问题 I'm documenting a Scala class with overloaded methods. How can I distinguish them when referring to them in scaladoc comments? For example, if I have /** * The most important method is [[Doc.foo]]. */ object Doc { def foo[A]: A = throw new UnsupportedOperationException; def foo[A,B >: A](x: A): B = x; } and run sbt doc I get Doc.scala:1: warning: The link target "Doc.foo" is ambiguous. Several (possibly overloaded) members fit the target: method foo[A,B>:A](x:A):B in object Doc [chosen]

Is the method naming for property getters/setters standardized in IL?

纵饮孤独 提交于 2019-12-18 05:48:25
问题 I have the following two methods that I am wondering if they are appropriate: public bool IsGetter(MethodInfo method) { return method.IsSpecialName && method.Name.StartsWith("get_", StringComparison.Ordinal); } public bool IsSetter(MethodInfo method) { return method.IsSpecialName && method.Name.StartsWith("set_", StringComparison.Ordinal); } While this code works, I'm hoping to avoid the portion that checks the StartsWith and programmatically get the naming convention. Basically, are there

Anybody know why mono SQLite uses SqliteConnection but Windows uses SQLiteConnection?

白昼怎懂夜的黑 提交于 2019-12-13 07:15:09
问题 I am adapting a large open-source Windows program to Linux, using MonoDevelop. I find that the SQLite method names in Windows look like this: SQLiteConnection but in Mono.Data.Sqlite they look like this: SqliteConnection with different case, so I got lots of reference errors. With help from others at stackexchange here I was able to get the projects to compile. Do any of you know why the two different versions of SQLite have different case in the method names? 来源: https://stackoverflow.com

Get a function name like printed in Chrome console

自古美人都是妖i 提交于 2019-12-12 13:59:58
问题 Considering this code : var o = {}; o.f = function(){}; new o.f; Chrome prints o.f {} into the console. Do you know how this o.f part is called? More importantly, is there any way to get this result without using the console? I'd like to extract the name of a method from the function itself, that is to say, without any additional information. I already know how to get the name in this case : function f(){} f+'' // "function f(){}" But it does not behave the same way in the situation described