我想使用.NET Core中的蓝牙LE功能(特别是BluetoothLEAdvertisementWatcher)来编写将信息记录到文件的扫描程序.这是作为桌面应用程序运行,最好是作为命令行应用程序运行.
System.IO.StreamWriter(string)这样的构造函数显然不可用.如何创建文件并写入文件?
我会很高兴能够做一个System.Console.WriteLine(字符串),但似乎在.NET Core下也没有.
更新:为了澄清,如果我有一个看起来像这样运行的程序没有错误,我将参加比赛.
using System;
using Windows.Devices.Bluetooth.Advertisement;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
BluetoothLEAdvertisementWatcher watcher = new BluetoothLEAdvertisementWatcher();
Console.WriteLine("Hello, world!");
}
}
}
Run Code Online (Sandbox Code Playgroud)
更新2:这是project.json文件:
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
Run Code Online (Sandbox Code Playgroud)
该命令的输出dotnet -v run包含此错误消息:
W:\src\dotnet_helloworld>dotnet -v run
...
W:\src\dotnet_helloworld\Program.cs(2,15): error CS0234: The type or namespace name 'Devices' does …Run Code Online (Sandbox Code Playgroud) 我希望我的MathJax在IPython Notebook中显示的方程在左边对齐而不是居中.这是通过一个核心配置选项控制displayAlign在MathJax如所描述的在这里.
我试图在IPython Notebook中设置此选项,方法是将其添加到我的config.js文件中
MathJax.Hub.Config({
displayAlign: "left"
});
Run Code Online (Sandbox Code Playgroud)
但它没有任何影响.
如何在IPython Notebook中设置MathJax核心配置选项?
[更新]我找到了一种方法:将上述配置行添加到config.js而不是mathjaxutils.js.在我的情况下(Windows 8),此文件位于:C:\Anaconda\Lib\site-packages\IPython\html\static\notebook\js\mathjaxutils??.js.这不是一个很好的解决方案,因为它涉及修改一个文件,可能会在下次更新IPython时被覆盖.
[更新] @Ian在评论中提出的技术确实有效,但一次只能使用一个笔记本.总而言之,我创建了一个文件my_css.css,其内容是
<script>
MathJax.Hub.Config({
displayAlign: 'left'
});
</script>
Run Code Online (Sandbox Code Playgroud)
在笔记本中,如果我运行这个单元格
from IPython.core.display import HTML
css_file = 'my_css.css'
HTML(open(css_file, "r").read())
Run Code Online (Sandbox Code Playgroud)
显示的方程式根据需要左对齐.
但是,我希望这是我所有笔记本电脑的默认设置.我尝试将此添加到我的custom.js
MathJax.Hub.Config({
displayAlign: 'left'
});
Run Code Online (Sandbox Code Playgroud)
并且为了好的措施将此添加到我的custom.css中
<script>
MathJax.Hub.Config({
displayAlign: 'left'
});
</script>
Run Code Online (Sandbox Code Playgroud)
但都没有任何影响.如果有一种方法可以在不修改核心IPython文件的情况下将此设置设置为所有笔记本的默认设置,那将是完美的.
我有一些使用非常标准的异常模式的C++代码:
try {
// some code that throws a std::exception
}
catch (std::exception &e) {
// handle the exception
}
Run Code Online (Sandbox Code Playgroud)
问题是异常没有被捕获,我无法弄清楚原因.
代码编译为OS X中的静态库(通过Xcode).该库链接到一个Cocoa应用程序,通过Objective-C++ thunk调用所讨论的函数.我怀疑Objective-C和C++之间的相互作用是罪魁祸首,但我所有试图将其解决的尝试都失败了.
我无法创建一个简单的示例,在一个简单的示例中重现此行为.当我从大型程序的上下文中取出相关代码时,一切正常.
任何人都可以建议为什么我的例外没有被抓住?
我可以使用以下代码在类似 HTML 的标签中成功左对齐前两行,但不能左对齐第三行:
digraph TTS {
node [shape="box"];
a [label=<line 1 --------<BR ALIGN="LEFT"/>line 2 ----<BR ALIGN="LEFT"/>line 3>];
}
Run Code Online (Sandbox Code Playgroud)
结果是这样的
我怎样才能得到这个呢?
在C++中使用模板时,我在Xcode中遇到错误.谁能告诉我有什么问题?
第一个版本在Xcode中报告错误,但在Visual Studio中报告错误.
// Version 1: Error in Xcode, but not Visual Studio
template<typename LengthT, typename VertexT>
int MyGraphAlgorithm(...arguments omitted...)
{
using namespace boost;
typedef property<vertex_distance_t, LengthT> VertextProperties_t;
typedef adjacency_list<vecS, vecS, directedS, VertextProperties_t> Graph;
// In next line Xcode reports: "error: expected `;' before 'vertexInitial'"
graph_traits<Graph>::vertex_descriptor vertexInitial(100);
}
Run Code Online (Sandbox Code Playgroud)
第二个没有错误.不同之处在于模板化typedef中模板参数LengthT的使用.
// Version 2: No error in Xcode or Visual Studio
template<typename LengthT, typename VertexT>
int MyGraphAlgorithm(...arguments omitted...)
{
using namespace boost;
// In the following line, LengthT has been …Run Code Online (Sandbox Code Playgroud) 这似乎非常基本但是这里.如果你是面向键盘的,你习惯于在OS X中一直使用Command-W关闭窗口.我想将这个功能添加到我在Interface Builder中为我的程序创建的对话框中.我可以看到如何添加一个等效于按钮动作的键盘但是如果我没有按钮怎么办?
我应该添加一个隐形按钮并将快捷方式放在那里吗?看起来很笨拙.当然有一些我可以覆盖的方法,但到目前为止我尝试过的方法都没有用.