它容易得到a method Name的Class在运行时
BUT
我怎样才能得到一个JavaDoc在运行时的方法吗?
如下例所示
我们的类包括JavaDoc我们的目标方法
public class MyClass {
/**
*
* @param x value of ....
* @return result of ....
*/
public String myMethod(int x) {
return "any value";
}
}
Run Code Online (Sandbox Code Playgroud)
我们的类有一个主要方法
public class TestJava {
public static void main(String[] args) {
// get Class method Name at run time
String methodName = MyClass.class.getMethods()[0].getName();
System.out.println(methodName); // will print myMethod
// How to get a JavaDoc of myMethod `method` …Run Code Online (Sandbox Code Playgroud) 可能重复:
类型的默认值
在C#中,要获取Type的默认值,我可以写...
var DefaultValue = default(bool);`
Run Code Online (Sandbox Code Playgroud)
但是,如何为提供的Type变量获取相同的默认值?
public object GetDefaultValue(Type ObjectType)
{
return Type.GetDefaultValue(); // This is what I need
}
Run Code Online (Sandbox Code Playgroud)
或者,换句话说,"默认"关键字的实现是什么?
我想在Java应用程序执行时将光标图标更改为我自定义的32x32图像.我查找并搜索,我发现的只是在JComponent上设置光标.但是,只要Java应用程序仍在运行,或者您可以说程序运行时,我希望将光标更改为指定的图标,无论它在何处移动,浏览和单击.
非常感谢.
所以我正在开发一个包含许多模块的相当大的python项目."main"(可运行)模块是一个守护进程(实际上是一个Thrift守护进程),它调用其他模块来实现其实际功能.启动守护程序需要很长时间,因为某些模块具有相当冗长且涉及的初始化过程.
因此,当我启动守护进程时,我等待......让我们说......加载所有内容需要2分钟,这在宏伟计划中并不算太糟糕.然而,对于开发而言,它变成了一个主要的痛苦,因为我需要每次都重新启动守护程序,这已经浪费了我很多时间.
大多数模块只需几秒钟即可加载.理想情况下,我想要做的是检测特定模块中的任何文件何时发生更改,然后重新加载该特定模块.我已经想出了如何重新加载模块,但此时我无法弄清楚如何观察特定模块的变化.请记住,.py在这种情况下,模块不是单个文件,而是具有__init__.py5-10个.py文件的目录,因此我需要检测其中任何文件何时发生更改.
这是项目布局(如果它有任何区别)
project
| -- daemonize.py
| -- main.py
| -- moduleA
| | -- __init__.py
| | -- happy_panda.py
| ` -- sad_panda.py
| -- moduleB
| | -- __init__.py
| | -- takes_forever_to_load.py
| ` -- seriously_get_some_coffee.py
| -- moduleC
| | -- __init__.py
| | -- frequently_changes.py
| | -- reasons_i_hate_my_job.txt
| ` -- home_address_of_moduleB_developer.txt
` -- service.py <-- uses modules A, B, and C …Run Code Online (Sandbox Code Playgroud) 我有:
class Car {..}
class Other{
List<T> GetAll(){..}
}
Run Code Online (Sandbox Code Playgroud)
我想要做:
Type t = typeof(Car);
List<t> Cars = GetAll<t>();
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我想从运行时使用反射发现的类型的数据库中返回一个泛型集合.
在普通Java中,可以在运行时以编程方式覆盖类的方法(甚至创建新方法)?
即使我在编译时不知道类,我也希望能够这样做.
我在运行时重写的意思是:
abstract class MyClass{
public void myMethod();
}
class Overrider extends MyClass{
@Override
public void myMethod(){}
}
class Injector{
public static void myMethod(){ // STATIC !!!
// do actual stuff
}
}
// some magic code goes here
Overrider altered = doMagic(
MyClass.class, Overrider.class, Injector.class);
Run Code Online (Sandbox Code Playgroud)
现在,这个调用......
altered.myMethod();
Run Code Online (Sandbox Code Playgroud)
...将调用Injector.myMethod()而不是Overrider.myMethod().
Injector.myMethod()是静态的,因为在执行"magic"之后,它会从不同的类实例(它是Overrider)调用,(因此我们阻止它访问本地字段).
我使用的是Win8 x64 + Office 2013 x64.
我有一个excel文件,其中包含一些模块,并在Office(Excel)x86中完美运行.它使用Swiss Ephemeris文件(swedll32.dll)进行大量的天文计算.
但是,当我尝试在Excel x64上运行它时,ASAP它已打开,VBA编辑器启动并给我以下错误:
Compile error:
The code in this project must be updated for use on 64-bit systems.
Please review and update Declare statements and then mark them with the PtrSafe attribute.
Run Code Online (Sandbox Code Playgroud)
正如我上面所说,它只适用于32位办公室(Excel),但它不能在我的x64 Excel中工作但是似乎有一个解决方法,但我太过新手了.
我不喜欢VBA,但是,在通过互联网挖掘后,一些网站建议对于64位办公室(Excel),我们应该修改(对于每个声明)代码到这样的:
不幸的是,在各处添加' PtrSafe ' 之后,尽管VBA错误已停止,但未在单元格中正确显示/计算值.
从微软VBA的64位帖子来看,似乎我们还需要修改一些数据类型,例如:
这个网站(在"Who Longs应该成为LongPtr?"下)提供了一个线索,关于如何知道要修改哪一个.
我不明白它的事情,并且不知道应该做些什么才能在Office(Excel)x64中完成这项工作.对此非常擅长的人,请帮助我.请.
注意:
模块名称中的问题:MainCalculations
'Swiss Ephemeris Release 1.60 9-jan-2000
'
' Declarations for …Run Code Online (Sandbox Code Playgroud) 这是关于在请求权限时Android Marshmallow中引入的新运行时权限模型Manifest.permission.WRITE_EXTERNAL_STORAGE.
简而言之,我所遇到的是,如果我请求(和用户允许)Manifest.permission.WRITE_EXTERNAL_STORAGE权限,应用程序将无法从外部存储目录读取和写入,直到我销毁并重新启动应用程序.
这就是我正在做/经历的事情:
我的应用程序从以下状态开始:
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
Run Code Online (Sandbox Code Playgroud)
这是,我没有权限访问外部存储.
然后,我就像Google解释的那样请求Manifest.permission.WRITE_EXTERNAL_STORAGE的许可
private void requestWriteExternalStoragePermission() {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
new AlertDialog.Builder(this)
.setTitle("Inform and request")
.setMessage("You need to enable permissions, bla bla bla")
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ActivityCompat.requestPermissions(MendeleyActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, RC_PERMISSION_WRITE_EXTERNAL_STORAGE);
}
})
.show();
} else {
ActivityCompat.requestPermissions(MendeleyActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, RC_PERMISSION_WRITE_EXTERNAL_STORAGE);
}
}
Run Code Online (Sandbox Code Playgroud)
一旦用户允许该权限,onRequestPermissionsResult就会被调用.
@Override …Run Code Online (Sandbox Code Playgroud) permissions android file-permissions runtime android-6.0-marshmallow
我的目标是为此激发应用程序的序列图我需要在运行时有关调用者和被调用者类名的信息.我可以成功检索调用函数但无法获取调用者类名称?
#Scenario caller.py:
import inspect
class A:
def Apple(self):
print "Hello"
b=B()
b.Bad()
class B:
def Bad(self):
print"dude"
print inspect.stack()
a=A()
a.Apple()
Run Code Online (Sandbox Code Playgroud)
当我打印堆栈时,没有关于调用者类的信息.那么可以在运行时检索调用者类吗?
我尝试将表单EF 3.5迁移到6(使用SQLite作为数据库).我们无法在app配置文件中设置连接字符串(这对ef6没有问题).我们必须在运行时以编程方式设置连接字符串(在用户选择SQLite文件之后).
这是我们的app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="testContext" connectionString="data source=Data\testdb.sqlite;Foreign Keys=True"
providerName="System.Data.SQLite" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<remove invariant="System.Data.SQLite.EF6" />
<add name="System.Data.SQLite" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
</DbProviderFactories> …Run Code Online (Sandbox Code Playgroud)