有没有办法定义如何使用Resharper(6)"清理"注释?我没有找到解决这个问题的方法.
在代码清理之前:
/// <summary>
/// This is a comment.
/// </summary>
public class MyClass
{
... <not yet cleaned code is here>
}
Run Code Online (Sandbox Code Playgroud)
代码清理后:
/// <summary>
/// This is a comment.
/// </summary>
public class MyClass
{
... <cleaned code is here>
}
Run Code Online (Sandbox Code Playgroud)
通缉结果:
/// <summary>
/// This is a comment.
/// </summary>
public class MyClass
{
... <cleaned code is here>
}
Run Code Online (Sandbox Code Playgroud)
备注:我不想为单个类等禁用清理.我只想更改意外添加的注释中的缩进.
我想让QWidget(或QDialog)以其父窗口小部件为中心.是否真的需要连接到父窗口小部件的信号,还是有更简单的方法(要设置的东西)?
我有一个 QListWidget 里面有一些小部件:
QListWidgetItem* w = new QListWidgetItem(ui->listWidget);
ui->listWidget->addItem(w);
w->setSizeHint(widget->sizeHint());
ui->listWidget->setItemWidget(w, widget);
Run Code Online (Sandbox Code Playgroud)
但是,一切似乎都正常,直到我调整了QListWidget( 它被嵌入到QDockwidget) 的大小。我是否必须遍历所有项目并手动调整它们的大小,还是有一个简单的技巧?
它只是一个列表,其中的项目在左侧有一个按钮,在右侧有一个按钮。如果列表被调整大小(QSize更改),则按钮将被隐藏并出现滚动条。我想根据列表宽度设置项目的大小。
我有两个简单的观察处理程序,它们订阅了同一源。然而,这两种订阅都以不同的类型运行。我希望他们保持可观察源(Subject())的顺序。我尝试使用 Synchronize() 扩展,但没有找到按预期方式完成这项工作的方法。
这是我的单元测试代码:
[Test]
public void TestObserveOn()
{
Console.WriteLine("Starting on threadId:{0}", Thread.CurrentThread.ManagedThreadId);
var source = new Subject<object>();
var are = new AutoResetEvent(false);
using (source.ObserveOn(TaskPoolScheduler.Default).Synchronize(source).OfType<int>().Subscribe(
o =>
{
Console.WriteLine("Received {1} on threadId:{0}", Thread.CurrentThread.ManagedThreadId, o);
int sleep = 3000 / o; // just to simulate longer processing
Thread.Sleep(sleep);
Console.WriteLine("Handled {1} on threadId: {0}", Thread.CurrentThread.ManagedThreadId, o);
},
() =>
{
Console.WriteLine("OnCompleted on threadId:{0}", Thread.CurrentThread.ManagedThreadId);
are.Set();
}))
using (source.ObserveOn(TaskPoolScheduler.Default).Synchronize(source).OfType<double>().Subscribe(
o =>
{
Console.WriteLine("Received {1} on threadId:{0}", Thread.CurrentThread.ManagedThreadId, o);
Console.WriteLine("Handled {1} on threadId: {0}", …Run Code Online (Sandbox Code Playgroud) 当我尝试使用 init[db] 调用 pg_ctl 时,无法识别设置编码的选项:
pg_ctl init -D=D:\testdata -E=UTF8 -U=postgres
pg_ctl: illegal option -- E
Run Code Online (Sandbox Code Playgroud)
这有改变吗?我使用最新的 PostgreSQL 9.6(zip 下载,x64)。当我不使用 -E 开关时,一切正常,但数据库集群使用错误的编码进行初始化。
我已使用此函数成功将值分配给Properties和嵌套属性
private static void AssignValueToProperty(ObjectAccessor accessor, object value, string propertyLambdaString)
{
var index = propertyLambdaString.IndexOf('.');
if (index == -1)
{
accessor[propertyLambdaString] = value;
// problem above: throws Exception if assigning value to Nullable<T>
}
else
{
var property = propertyLambdaString.Substring(0, index);
accessor = ObjectAccessor.Create(accessor[property]);
AssignValueToProperty(accessor, value, propertyLambdaString.Substring(index + 1));
}
}
Run Code Online (Sandbox Code Playgroud)
但是,赋值会抛出InvalidCastException.如何使用FastMember指定可空值?例如
public class A
{
public double? SomeValue {get; set;}
}
...
var a = new A();
var accessor = ObjectAccessor.Create(a);
accessor["SomeValue"] = 100; // throws Exception, when assigning …Run Code Online (Sandbox Code Playgroud) 可以在WP7上使用Spring.net吗?你会为WP7推荐其他DI/IoC-Containers吗?为什么?
如果集合或列表同时实现IEnumerable <T>和IEnumerator <T>,foreach会使用什么?
我想向池(组?)添加和删除参与者,该池应该使用一致的哈希映射通过路由器接收消息(消息具有与实体路径一致的 ID)。但是在创建池后,只有 IActorRef 返回,我不知道如何“告诉”要添加的新演员。
我已经阅读了几个关于路由的教程和提示,例如:https : //github.com/petabridge/akka-bootcamp/tree/master/src/Unit-3/lesson2 但这些不适合。
也许我需要自己用这些消息编写一个自己的路由器?
我有一个来自QWidget的MyListWidget类.我将parent和flags传递给基类QWidget构造函数(在测试中尝试了Qt :: Dialog和Qt :: Popup),但是自定义小部件显示在屏幕的中心,而不是以其父级为中心.
MyListWidget* myListWidget = new MyListWidget(this, Qt::Dialog);
Run Code Online (Sandbox Code Playgroud)
这是构造函数:
MyListWidget::MyListWidget(QWidget* parent, Qt::WindowFlags flags)
: QWidget(parent, flags),
ui(std::auto_ptr<Ui::MyListWidget>(new Ui::MyListWidget))
{
ui->setupUi(this);
}
Run Code Online (Sandbox Code Playgroud)
如果我将此小部件放入单独的对话框中,则任何内容都可以按预期工 但为什么?
包装工作:
QDialog* popup = new QDialog(this, Qt::Popup);
QVBoxLayout* hLayout = new QVBoxLayout(popup);
// ... doing list creation like above
hLayout->addWidget(mmyListWidget);
popup->setLayout(hLayout);
const int width = mapListWidget->width();
const int height = mapListWidget->height();
popup->resize(width, height);
Run Code Online (Sandbox Code Playgroud)
任何想法可能会发生在这里?
如果使用名称空间来分隔模块/结构化,则头文件中的嵌套和缩进会显着增加.有没有办法以较短的方式编写以下代码?
namespace A
{
namespace B
{
namespace C
{
namespace D
{
namespace E
{
template <typename T>
public class X
{
public: ...
Run Code Online (Sandbox Code Playgroud)
例如喜欢
namespace A::B::C::D::E
{
template<typename T> ...
}
Run Code Online (Sandbox Code Playgroud)
在c ++的头文件中?
您如何使用Rx编写类似于以下简单EventBus示例的内容?
public class EventBus
{
private readonly Dictionary<Type, List<Action<Event>>> routes = new Dictionary<Type, List<Action<Event>>>();
public void RegisterHandler<T>(Action<T> handler) where T : Event
{
List<Action<Event>> handlers;
if (!this.routes.TryGetValue(typeof(T), out handlers))
{
handlers = new List<Action<Event>>();
this.routes.Add(typeof(T), handlers);
}
handlers.Add(x => handler((T)x));
}
public void Publish<T>(T @event) where T : Event
{
List<Action<Event>> handlers;
if (!this.routes.TryGetValue(@event.GetType(), out handlers))
{
return;
}
foreach (var handler in handlers)
{
var apply = handler;
apply(@event);
}
}
}
Run Code Online (Sandbox Code Playgroud) c# ×6
c++ ×3
qt ×3
.net ×1
akka.net ×1
coding-style ×1
fastmember ×1
foreach ×1
iterator ×1
namespaces ×1
nullable ×1
pg-ctl ×1
postgresql ×1
properties ×1
qdialog ×1
qlistwidget ×1
resharper ×1
routing ×1
sizehint ×1
spring.net ×1