我正在使用应用程序/域层中的DDD来处理事件源 CQRS实现.我有一个如下所示的对象模型:
public class Person : AggregateRootBase
{
private Guid? _bookingId;
public Person(Identification identification)
{
Apply(new PersonCreatedEvent(identification));
}
public Booking CreateBooking() {
// Enforce Person invariants
var booking = new Booking();
Apply(new PersonBookedEvent(booking.Id));
return booking;
}
public void Release() {
// Enforce Person invariants
// Should we load the booking here from the aggregate repository?
// We need to ensure that booking is released as well.
var booking = BookingRepository.Load(_bookingId);
booking.Release();
Apply(new PersonReleasedEvent(_bookingId));
}
[EventHandler]
public void Handle(PersonBookedEvent @event) …Run Code Online (Sandbox Code Playgroud) 我在我的摩托罗拉Droid上测试了它,它按预期工作.但是,我担心这可能是:
码:
/* Create a simple 100 by 100 bitmap */
Bitmap myBitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
/* Create a canvas with which to draw on my bitmap */
Canvas myCanvas = new Canvas(myBitmap);
/* Draw a subset of my bitmap onto itself, with the source rectangle and destination rectangle overlapping */
Rect sourceRect = new Rect(10, 0, 99, 99);
Rect destRect = new Rect(0, 0, 89, 99);
myCanvas.drawBitmap(myBitmap, sourceRect, destRect, null);
Run Code Online (Sandbox Code Playgroud)
正如我所说,这似乎在我的测试中运行良好,但是当在其他平台上执行bit blits时,我并不总能保证将一个grpahics区域复制到另一个grpahics区域是安全的,内存和性能方面的.源和目的地相交.
我欢迎任何有关此事的见解.
说我有一个结构:
struct MyStruct
{
public int X
public int Y
}
Run Code Online (Sandbox Code Playgroud)
并且在某些类中的方法在其他地方多次迭代:
public bool MyMethod( MyStruct myStruct )
{
return ...
}
Run Code Online (Sandbox Code Playgroud)
是否将MyMethod签名更改为以下可接受的优化?
public bool MyMethod( ref MyStruct myStruct )
Run Code Online (Sandbox Code Playgroud)
如果是这样,它真的有多大的优势?如果没有,那么使用ref这种方式,结构需要多少字段以获得足够大的优势?
我正在写博客,想在东部时区展示我的帖子.我认为存储所有UTC都是正确的方法.这会带来一些挑战:
我必须将所有时间从UTC转换为东部.这不是一个大问题,但增加了很多代码.
而"biggie"就是我通过传递一个查询ala blogger来使用短日期时间来引用这些帖子.问题是没有办法将短日期时间转换为正确的UTC日期,因为我缺少发布的时间信息.
嗯,在东部时间存储所有日期有什么问题吗?这肯定会使应用程序的其余部分更容易,但如果我需要更改时区,一切都将存储错误.
更新
@Jon,非常重视您的专业知识,但我已经决定在数据库中存储UTC时间是错误的.不过你可能会说服我!
所以,让我给你一个完整的瘦身.我将所有时间都转换为UTC,这需要在代码的声明部分中添加更多"语法".
我正在编码的是一个博客,所以我有2条路线,一条列表路线和一条细节路线.详细信息路径需要较短的日期,并且帖子的名称假设组合为唯一.这就是它崩溃的原因.我在查询中传递短路线.
根据时间的不同,我们可以将它包裹起来,使其为29或30.所以短日期必须正确,因为我在查询中没有足够的信息来确定如何将东部时间转换回UTC.
我存储了一个DatePosted"短日期",所有时间都是@ 12 AM用于SQL目的和FirstModified长日期.所以,我说,没问题,我只会将短日期存储在东部,然后将长日期转换为东部.不行,因为我无法使这些查询工作.
所以,我认为我错了.日期应始终存储在东部时间(我想要使用的时间).然后,如果用户想要更改时区(不是要求),我们只需浏览所有条目并进行更改.
也许,我正在考虑这个错误,但在我的情况下,只会使用东部时区,所以无论如何都浪费时间.
期待对此有任何意见!
关键问题:
再次感谢您的帮助!
这是我的班级定义:
class MyClass {
public:
void test(int val = 0);
}
void MyClass::test(int val = 0) {
//
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译此代码时,我收到错误:"为参数1指定的默认参数"
这只是一个简单的功能,我不知道出了什么问题.我正在使用Eclipse + MinGW.
我有一个提供日志,我使用的WebForms项目,现在想在一个ASP.Net MVC 2项目中使用它的DLL.
该DLL的某些方面在app.config中配置:
<configuration>
<configSections>
<section name="Tools.Instrumentation.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<Tools.Instrumentation.Properties.Settings>
<setting name="LogLevel" serializeAs="String">
<value>DEBUG</value>
</setting>
<setting name="AppName" serializeAs="String">
<value>MyApp</value>
</setting>
<setting name="Port" serializeAs="String">
<!--value>33333</value-->
<value>0</value>
</setting>
</Tools.Instrumentation.Properties.Settings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但是,当我创建一个类似的条目时Web.config,我收到错误:
无法识别的配置部分applicationSettings
我的两部分问题:
Web.config?我注意到现在有很多站点将所有图像都放在单个文件中然后使用background-position来偏移屏幕上显示的矩形.
这是出于性能原因吗?如果是这样的话?
我正在做一些长形式的Web开发.我可以填写很多字段来填写表格.
而不是每次都输入相同的东西(联系信息,地址,商业信息),我希望有一些工具/工具组合将帮助我填补这一点.
要求:我在Win 7系统上进行FF,IE和Chrome的开发/测试,因此该工具将利用其中一个平台.哦,是的,还有一件事:它必须是自由和轻量级的,否则,我宁愿只输入对表单字段的响应.
以下是一些观点:
那么,如何获取当前缩放级别上所有可见标记的列表?我通过互联网搜索并没有找到有用的东西.可以在这里找到我想要实现的某种东西
我注意到,如果我在Visual Studio 2010中省略字符串常量的终止双引号,则没有错误甚至是警告,即
Dim foo as String = "hi
Run Code Online (Sandbox Code Playgroud)
但是,我们使用的持续集成工具标记错误:
error BC30648: String constants must end with a double quote.
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?在VB.Net中是否有一些语言规则使得终止双引号可选"有时"?Visual Studio中是否有一些设置会将其标记为错误,因此我可以避免以这种方式"破坏构建"?
asp.net ×2
.net ×1
android ×1
automation ×1
c# ×1
c++ ×1
class-design ×1
cqrs ×1
css ×1
datetime ×1
default ×1
eclipse ×1
firefox ×1
google-maps ×1
mingw ×1
optimization ×1
repository ×1
sql ×1
string ×1
testing ×1
vb.net ×1
web-config ×1