我想使用'diff'来获得字符差异和字符差异.例如,考虑:
档案1
abcde
abc
abcccd
Run Code Online (Sandbox Code Playgroud)
档案2
abcde
ab
abccc
Run Code Online (Sandbox Code Playgroud)
使用diff -u我得到:
@@ -1,3 +1,3 @@
abcde
-abc
-abcccd
\ No newline at end of file
+ab
+abccc
\ No newline at end of file
Run Code Online (Sandbox Code Playgroud)
但是,它只向我显示这些行的变化.我希望看到的是:
@@ -1,3 +1,3 @@
abcde
-ab<ins>c</ins>
-abccc<ins>d</ins>
\ No newline at end of file
+ab
+abccc
\ No newline at end of file
Run Code Online (Sandbox Code Playgroud)
你得到我的漂移.
现在,我知道我可以使用其他引擎来标记/检查特定线路上的差异.但我宁愿使用一种可以完成所有工作的工具.
我将文本框绑定到对象,如下所示:
<TextBlock d:DataContext="{d:DesignInstance ViewModel:TaskVM }"
Text="{Binding Title}" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown">
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
现在我想知道如何在设计过程中显示模拟数据.我尝试过这样的事情:
<TextBlock Text="{Binding Path=Title}" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown">
<d:DesignProperties.DataContext>
<ViewModel:TaskVM Title="Mock"/>
</d:DesignProperties.DataContext>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
但是,由于TaskVM没有默认的ctor,我找到了"No default constructor".
我知道当我使用d:DataContext="{d:DesignInstance ViewModel:TaskVM }"它时会创建一个模拟数据类型.有没有办法让我设置这个模拟类型的属性?
谢谢!
我试图将一个数字传递给一个React组件,但它被解析为字符串(jsfiddle).如何让React了解我正在传递一个号码?我应该将字符串转换为组件中的数字吗?
var Rectangle = React.createClass({
render: function() {
return <div>
<div>{this.props.intValue + 10}</div>
<div>{this.props.stringValue + 10}</div>
</div>;
}
});
React.render(<Rectangle intValue="10" stringValue="Hello" />
, document.getElementById('container'));Run Code Online (Sandbox Code Playgroud)
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>Run Code Online (Sandbox Code Playgroud)
在以下代码中,$ q promise 的catch函数捕获异常:
// Fiddle - http://jsfiddle.net/EFpn8/6/
f1().then(function(data) {
console.log("success 1: "+data)
return f2();
})
.then(function(data) {console.log("success 2: "+data)})
.catch(function(data) {console.log("error: "+data)});
function f1() {
var deferred = $q.defer();
// An exception thrown here is not caught in catch
// throw "err";
deferred.resolve("done f1");
return deferred.promise;
}
function f2() {
var deferred = $q.defer();
// An exception thrown here is handled properly
throw "err";
deferred.resolve("done f2");
return deferred.promise;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我查看控制台日志输出时,我看到以下内容:

该异常是在Angular中捕获的,但也被浏览器的错误处理所捕获.此行为确实与Q库重现.
这是一个错误吗?我怎样才能真正捕获$ q的异常?
请考虑以下场景:我正在运行我的应用程序,在执行期间,必须运行另一个进程,并且只有在第二个进程完成内部特定初始化之后,我的第一个进程才能继续.例如:
...
// Process1 code does various initializations here
Process.Start("Process2.exe");
// Wait until Process2 finishes its initialization and only then continue (Process2 doesn't exit)
...
Run Code Online (Sandbox Code Playgroud)
我看到几个选项:
我很高兴听到你对这个案子的意见.
谢谢!
我试图从C#中的控制台读取unicode字符串,例如,让我使用他的:
C:\ SVN \D³ebugger的\ src \виталик\的Program.cs
起初我只是试着Console.ReadLine()回复了我c:\SVN\D3ebugger\src\???????\Program.cs
我已经尝试将Console.InputEncoding设置为UTF8,Console.InputEncoding = Encoding.UTF8但是返回了我c:\SVN\D³ebugger\src\???????\Program.cs,基本上将字符串的Cyrillic部分弄糟了.
所以随机磕磕绊绊,我试图设置这样的编码,Console.InputEncoding = Encoding.GetEncoding(1251);这回来了c:\SVN\D?ebugger\src\???????\Program.cs,这次破坏了³角色.
此时似乎通过切换InputStream的编码,我一次只能获得一种语言.
我也尝试过本地人做这样的事情:
// Code
public static string ReadLine()
{
const uint nNumberOfCharsToRead = 1024;
StringBuilder buffer = new StringBuilder();
uint charsRead = 0;
bool result = ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), buffer, nNumberOfCharsToRead, out charsRead, (IntPtr)0);
// Return the input minus the newline character
if (result && charsRead > 1) return buffer.ToString(0, (int)charsRead - 1);
return string.Empty;
} …Run Code Online (Sandbox Code Playgroud) 我需要我的文本框是只读的.但是,当我将IsReadOnly设置为true时,用户无法再使用键盘与文本框进行交互,因为光标不再出现.
在.NET 4中有一个IsReadOnlyCaretVisible属性,但是,我被迫使用.NET 3.5.
有一个很好的解决方案吗?
谢谢!
我使用Android模拟器与Android 2.1的AVD我有以下问题:尝试使用webView.loadUrl在WebView中加载URL 导致它在浏览器中打开.
注意:我说的是初始打开,而不是 WebView在浏览器中打开的链接的问题,但也许它以某种方式连接.
我尝试了几件事:
<uses-permission android:name="android.permission.INTERNET" />清单中删除了.这实际上使它正常工作,即将html加载到webview中.但是,正如人们所预料的那样,它唯一加载的是"无法连接互联网"错误页面.05-23 22:54:06.858:INFO/ActivityManager(51):开始活动:Intent {act = android.intent.action.VIEW cat = [android.intent.category.BROWSABLE] dat = http://m.walla .co.il/ErrorPage.aspx?ReturnUrl =/Default.aspx cmp = com.android.browser/.BrowserActivity}
我没有发现其他任何人抱怨它.为什么会这样?
谢谢,维塔利
我在包中做了一个扩展,我调用了下面的代码(当用户按下工具栏中的按钮时发生):
DocumentEvents documentEvents = (DTE2)GetService(typeof(DTE));
_dte.Events.DebuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;
_dte.Events.DebuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
_dte.Events.DebuggerEvents.OnContextChanged += DebuggerEvents_OnContextChanged;
_dte.Events.DocumentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(DocumentEvents_DocumentSaved);
_dte.Events.DocumentEvents.DocumentOpened += new _dispDocumentEvents_DocumentOpenedEventHandler(DocumentEvents_DocumentOpened);
void DocumentEvents_DocumentOpened(Document Document)
{
}
void DocumentEvents_DocumentSaved(Document Document)
{
}
void DebuggerEvents_OnEnterBreakMode(dbgEventReason Reason, ref dbgExecutionAction ExecutionAction)
{
}
void DebuggerEvents_OnContextChanged(Process NewProcess, Program NewProgram, Thread NewThread, StackFrame NewStackFrame)
{
}
private void DebuggerEvents_OnEnterDesignMode(dbgEventReason reason)
{
}
Run Code Online (Sandbox Code Playgroud)
第一个和主要问题是订阅该事件不起作用.我试过了:
这些似乎都没有任何效果,并且从不调用回调函数.
第二个问题是对事件行的订阅是USUALLY(订阅本身,回调不能像上面描述的那样工作)但是在运行订阅行一段时间之后,例如:
_dte.Events.DebuggerEvents.OnEnterBreakMode -= DebuggerEvents_OnEnterBreakMode;
Run Code Online (Sandbox Code Playgroud)
导致异常:
Exception occured!
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个简单的异常处理程序,它将帮助我调试应用程序.现在,当我遇到异常时,我被迫连接Eclipse调试器只是为了查看异常细节.
为了避免这种情况,我使用了setUncaughtExceptionHandler来处理任何未处理的异常并在异常上显示Toast.不幸的是,这不起作用.
public class TicTacToe extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
Toast.makeText(TicTacToe.this, "TOAST", Toast.LENGTH_LONG).show();
}
});
setContentView(R.layout.main);
Button continueButton = (Button) findViewById(R.id.cell01);
continueButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int i = 5;
i = 5 / 0;
Toast.makeText(TicTacToe.this, "BUTTON", Toast.LENGTH_LONG).show();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
基本上我用一个按钮制作了一个表单,按下它,它将抛出一个零度异常.但是,按下按钮不会导致显示全局Toast处理程序.相反,按钮保持橙色(按下),没有任何反应.
不用说,如果我评论出i = 5/0; 我看到吐司说按了一个按钮.
两个问题:1)为什么在 …