所以我有我的枚举
public enum Sample {
ValueA{
@Override
public String getValue(){ return "A"; }
},
ValueB{
@Override
public String getValue(){ return "B"; }
public void doSomething(){ }
};
abstract public String getValue();
};
Run Code Online (Sandbox Code Playgroud)
我有一些其他代码试图使用枚举.
Sample.ValueB.doSomething();
Run Code Online (Sandbox Code Playgroud)
这似乎应该是有效的,但产生错误"方法doSomething()未定义类型Sample".相反
Sample value = Sample.ValueB;
value.doSomething();
Run Code Online (Sandbox Code Playgroud)
产生相同的错误,似乎合理.
我假设有一个合理的答案,为什么第一个不起作用,它涉及两个例子在引擎盖下等效.我希望有人能指出我为什么会那样的文件.
我有一个应用程序,它是下一个方式启动浏览器:
Uri uri = Uri.parse(getURL());
Context context = widget.getContext();
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
我有另一个AndroidJUnit项目,我希望在其中捕获该活动.
接下来的步骤,我可以捕获运行浏览器的MYProjectActivity,但我无法捕获浏览器.
Instrumentation instrumentation = getInstrumentation();
// Register we are interested in the authentication activiry...
Instrumentation.ActivityMonitor monitor = instrumentation.addMonitor(MYProjectActivity.class.getName(), null, false);
// Start the authentication activity as the first activity...
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(instrumentation.getTargetContext(), MYProjectActivity.class.getName());
instrumentation.startActivitySync(intent);
// Wait for it to start...
Activity currentActivity = getInstrumentation().waitForMonitorWithTimeout(monitor, 5);
Run Code Online (Sandbox Code Playgroud)
有人知道怎么做这个吗?
在我刚刚接手的一个应用程序中发现了这一行,并没有多大意义。
using (new TransactionScope(TransactionScopeOption.Suppress, new TimeSpan(1,0,0))) {
这会立即发生在 nservicebus 消息处理程序方法内并覆盖整个处理程序。
它似乎试图抑制环境事务并在一小时后中止。超时到期后会发生什么?我认为这只是选项的组合,并不意味着任何合理的事情。但它会导致什么情况发生呢?
我正在编写软件,我经常需要做图形插图来解释代码的行为,例如几何地说明如何从三角形中的一个边到该三角形中的一个点找到最短距离.
在评论中使用和发明ascii表示变得有点乏味,所以我想是否有可能将绘图(在绘图程序中创建的图片)嵌入到项目/解决方案中并在评论块中链接到它们.