我正在尝试处置XmlWriter对象:
try
{
[System.Xml.XmlWriter] $writer = [System.Xml.XmlWriter]::Create('c:\some.xml')
}
finally
{
$writer.Dispose()
}
Run Code Online (Sandbox Code Playgroud)
错误:
方法调用失败,因为[System.Xml.XmlWellFormedWriter]不包含名为"Dispose"的方法.
另一方面:
$writer -is [IDisposable]
# True
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
什么是PowerShell中的Class,Interface,Mixin等概念?它支持OOP吗?如果是这样,我在哪里可以读到这个?
我的应用程序有两个活动,我按此顺序开始:
HOME > A > B
Run Code Online (Sandbox Code Playgroud)
现在我按HOME并再次启动"A".我想在"A"的顶部看到活动"B",但我得到"A" - 所以活动堆栈被清除.
表现:
<activity android:name=".activity.A" android:label="A" android:alwaysRetainTaskState="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.B" android:label="B">
<intent-filter>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
当我在此代码上运行FindBugs时,它报告没有问题.
boolean _closed = false;
public void m1(@Nullable String text) {
if(_closed)
return;
System.out.println(text.toLowerCase());
}
Run Code Online (Sandbox Code Playgroud)
虽然在这里找到了预期的问题:
public void m1(@Nullable String text) {
System.out.println(text.toLowerCase()); // FindBugs: text must be nonnull but is marked as nullable
}
Run Code Online (Sandbox Code Playgroud)
为什么在第一种情况下会失败?
我需要得到一个ascender/descender和x-height ..
通过使用以下代码,我可以找到下降器和总高度:
descender_height = paint.descent();
total_height = descender_height - paint.ascent();
//ascender = ?; is this always equal to descender height?
//x_height = ?; total_height - 2*descender_height ?
Run Code Online (Sandbox Code Playgroud)
谢谢
我有这样的WPF绑定代码:
TestModel source = new TestModel();
TestModel target = new TestModel();
Bind(source, target, BindingMode.OneWay);
source.Attribute = "1";
AssertAreEqual(target.Attribute, "1");
target.Attribute = "foo";
source.Attribute = "2";
AssertAreEqual(target.Attribute, "2");
Run Code Online (Sandbox Code Playgroud)
第二个断言失败了!这对我来说似乎很奇怪.
此外,我尝试了'OneWayToSource'而不是'OneWay',并且都按预期工作.
Bind(source, target, BindingMode.OneWayToSource);
target.Attribute = "1";
AssertAreEqual(source.Attribute, "1");
source.Attribute = "foo";
target.Attribute = "2";
AssertAreEqual(source.Attribute, "2");
Run Code Online (Sandbox Code Playgroud)
其他详情:
void Bind(TestModel source, TestModel target, BindingMode mode)
{
Binding binding = new Binding();
binding.Source = source;
binding.Path = new PropertyPath(TestModel.AttributeProperty);
binding.Mode = mode;
BindingOperations.SetBinding(target, TestModel.AttributeProperty, binding);
}
class TestModel : DependencyObject
{
public static …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来捕获传递给方法的实际参数,以便稍后检查它.想法是获取传递的参数,然后对它执行断言.
例如:
var foo = Mock<Foo>();
var service = Mock<IService>();
service.Expect(s => s.Create(foo));
service.Create(new Foo { Currency = "USD" });
Assert(foo.Object.Currency == "USD");
Run Code Online (Sandbox Code Playgroud)
或者更复杂的例子:
Foo foo = new Foo { Title = "...", Description = "..." };
var bar = Mock.NewHook<Bar>();
var service = new Mock<IService>();
service.Expect(s => s.Create(bar));
new Controller(service.Object).Create(foo);
Assert(foo.Title == bar.Object.Title);
Assert(foo.Description == bar.Object.Description);
Run Code Online (Sandbox Code Playgroud) 我尝试在Android的/ data/data/pkg/files目录中创建'foo/bar.txt'.
这似乎是文档中的矛盾:
要写入文件,请使用名称和路径调用Context.openFileOutput().
http://developer.android.com/guide/topics/data/data-storage.html#files
要打开的文件的名称; 不能包含路径分隔符.
当我打电话的时候
this.openFileOutput("foo/bar.txt", Context.MODE_PRIVATE);
Run Code Online (Sandbox Code Playgroud)
抛出异常:
java.lang.IllegalArgumentException: File foo/bar.txt contains a path separator
Run Code Online (Sandbox Code Playgroud)
那么我如何在子文件夹中创建文件?
在Android源代码中我看到了这样的字符串
<string name="app_name" msgid="8095131950334945205">"Calculadora"</string>
Run Code Online (Sandbox Code Playgroud)
请注意'msgid',这表示存在一些管理字符串转换的工具.它的工具是什么?
android ×4
powershell ×2
wpf ×2
.net ×1
binding ×1
css ×1
dispose ×1
file ×1
findbugs ×1
fontmetrics ×1
fonts ×1
idisposable ×1
java ×1
localization ×1
mocking ×1
oop ×1