有人可以帮忙吗?
我有一些代码在两个项目之间共享.代码指向一个模型,该模型基本上是来自db的属性集合.
问题在于某些属性在1个模型中使用可空类型而另一个属性则不在
真的dbs应该使用相同,但他们不..
所以例如有一个名为IsAvailble的属性,它在一个模型中使用"bool"而另一个使用bool?(可空类型)
所以在我的代码中我做了以下几点
objContract.IsAvailble.Value ? "Yes" : "No" //notice the property .VALUE as its a bool? (nullable type)
Run Code Online (Sandbox Code Playgroud)
但是这条线在使用标准"bool"(不可为空)的模型上会失败,因为在不可为空的类型上没有属性.VALUE
是否有某种辅助类,我检查属性是否为可空类型,我可以返回.Value ..否则我只是返回属性.
有人有解决方案吗?
编辑
这就是我现在所拥有的.....我正在检查可空类型版本中的HasValue
public static class NullableExtensions {public static T GetValue(this T obj)其中T:struct {return obj; public static T GetValue(this Nullable obj)其中T:struct {return obj.Value; }
public static T GetValue<T>(this T obj, T defaultValue) where T : struct
{
return obj;
}
public static T GetValue<T>(this Nullable<T> obj, T defaultValue) where T : struct
{
if (obj.HasValue)
return …Run Code Online (Sandbox Code Playgroud) 以下代码有什么区别,
QGraphicsScene * scence = new QGraphicsScene();
QBrush *brush = new QBrush((QColor(60,20,20)));
scence->setBackgroundBrush(*brush);
QGraphicsView *view = new QGraphicsView();
view->setScene(scence);
//view->setBackgroundBrush(*brush);
//view->setCacheMode(QGraphicsView::CacheBackground);
view->showFullScreen();
Run Code Online (Sandbox Code Playgroud)
给出黑色背景
QGraphicsScene * scence = new QGraphicsScene();
QBrush *brush = new QBrush();
brush->setColor(QColor(60,20,20));
scence->setBackgroundBrush(*brush);
QGraphicsView *view = new QGraphicsView();
view->setScene(scence);
//view->setBackgroundBrush(*brush);
//view->setCacheMode(QGraphicsView::CacheBackground);
view->showFullScreen();
Run Code Online (Sandbox Code Playgroud)
它什么都没有.
可能重复:
Facebook Sharer如何选择图像?
我正在制作一个闪光应用程序,以不同速度驾驶时显示出交通伤害.我希望用户能够在Facebook上分享这些信息.然而,这要求我可以自定义以某种方式出现在Facebook上的文本.
我正在制作一个在空白窗口中打开的URL(来自flash应用程序本身).我指定了u和t参数,将生成的消息作为t参数.但这似乎总是被页面标题所覆盖.如果我省略html代码中的title标签,则使用文件名(也覆盖指定的标题).
http://www.facebook.com/sharer.php?u=http://espentokerud.com/face/addiste.html&t=test;
我也尝试过url-encoding网址,但无济于事.
http://www.facebook.com/sharer.php?u=http%3a%2f%2fespentokerud.com%2fface%2faddiste.html&t=test;
我也尝试使用addthis API,但遇到了同样的缺点.有趣的是,如果我发布swf,标题和描述可以自定义,并且还可以指定屏幕截图.但如果我不发布瑞士法郎,这似乎被忽略了.
我知道我可以在html页面上使用元标记来指定缩略图图像,标题和描述,但是这些内容中的一些必须基于flash应用程序内的计算.
当我使用小块中的HttpWebRequest(在Silverlight上)发送/接收数据时,我通过"localhost"连接测量500字节/秒的非常小的吞吐量.当以大块发送数据时,我得到2 MB/s,这快了5000倍.
有谁知道什么可能导致这个令人难以置信的巨大开销?
附加信息:
更新:我使用的Silverlight客户端代码本质上是我自己的WebClient类实现.我写它的原因是因为我注意到WebClient存在相同的性能问题,我认为HttpWebRequest可以调整性能问题.遗憾的是,这没有用.实施如下:
public class HttpCommChannel
{
public delegate void ResponseArrivedCallback(object requestContext, BinaryDataBuffer response);
public HttpCommChannel(ResponseArrivedCallback responseArrivedCallback)
{
this.responseArrivedCallback = responseArrivedCallback;
this.requestSentEvent = new ManualResetEvent(false);
this.responseArrivedEvent = new ManualResetEvent(true);
}
public void MakeRequest(object requestContext, string url, BinaryDataBuffer requestPacket)
{
responseArrivedEvent.WaitOne();
responseArrivedEvent.Reset();
this.requestMsg = requestPacket;
this.requestContext = requestContext;
this.webRequest = WebRequest.Create(url) as HttpWebRequest;
this.webRequest.AllowReadStreamBuffering = true;
this.webRequest.ContentType = …Run Code Online (Sandbox Code Playgroud) 任何机构都可以告诉我如何将Java Date存储到Mysql datetime ......?
当我尝试这样做时...只存储日期,并且在这样的Mysql日期存储中时间保持00:00:00 ......
2009-09-22 00:00:00
Run Code Online (Sandbox Code Playgroud)
我不仅想要约会,还想要时间......就像
2009-09-22 08:08:11
Run Code Online (Sandbox Code Playgroud)
我正在使用JPA(Hibernate)和spring mydomain类使用java.util.Date但我使用手写查询创建了表...
这是我的创建声明
CREATE TABLE ContactUs (id BIGINT auto_increment,
userName VARCHAR(30),
email VARCHAR(50),
subject VARCHAR(100),
message VARCHAR(1024),
messageType VARCHAR(15),
contactUsTime datetime,
primary key(id))
TYPE=InnoDB;
Run Code Online (Sandbox Code Playgroud) 我有一个用于Linux的UI应用程序(使用GTK),需要以root身份运行(它读取和写入/ dev/sd*).
每次启动我的应用程序时,我都不想要用户打开root shell或手动使用"sudo",我想知道该应用程序是否可以使用某些操作系统提供的API来获取root权限.(注意:gtk应用程序不能使用"setuid"模式,因此这里不是一个选项.)
这里的优点是更简单的工作流程:用户可以从他的默认用户帐户双击桌面上的应用程序,而不必打开根终端并从那里启动它.
我问这个是因为OS X提供了这样的:应用程序可以要求操作系统启动具有root权限的可执行文件 - 操作系统(而不是应用程序)然后要求用户输入他的凭据,验证它们然后根据需要启动目标.
我想知道Linux是否有类似的东西(例如Ubuntu)
澄清:
所以,在PolicyKit的提示后,我想知道我是否可以使用它来获得对"/ dev/sd ..."块设备的r/w访问.我觉得这篇文章很难理解,所以我想在我花费数小时试图理解它之前我先问这是否可能.
更新:
该应用程序是一个远程操作的磁盘修复工具,为不称职的Linux用户,这些Linux新手不会太多了解使用sudo甚至更改其用户的组成员身份,特别是如果他们的磁盘刚开始表现,他们吓坏了.这就是为什么我寻求避免像这样的技术性的解决方案.
我一直在阅读有关Command Query Responsibility Segregation(CQRS)的信息.我有点想知道如何使用ASP.NET MVC?我从概念上理解了CQRS,听起来不错,肯定会引入一些复杂性(事件和消息模式)与"普通/常见"方法相比.CQRS的思想也在某种程度上反对使用ORM.我正在考虑如何在即将到来的项目中使用这种模式,所以如果有人有将CQRS与ASP.NET MVC和NHibernate结合的经验,请提供一些具体的例子来帮助我更好地理解CQRS并与ASP.NET MVC一起使用.谢谢!
更新:我一直在浏览Mark的示例代码.如果您正在学习CQRS,那必读.
http://github.com/MarkNijhof/Fohjin
http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young/
http://cre8ivethought.com/blog/2009/11/28/cqrs-trying-to-make-it-re-usable/
我有一个多模块maven项目,它成功构建,我想构建我所拥有的模块之一.如何使用配置文件?我可以通过两种方式从控制台执行此操作,一种方法是转到子模块,mvn package或者我可以使用reactor来构建一个模块.
我可以用配置文件做同样的事情吗?通过修改POM?谢谢
编辑
如果POM不可能,我可以在settings.xml中进行吗?
java ×2
.net ×1
asp.net-mvc ×1
brush ×1
c# ×1
colors ×1
cqrs ×1
datetime ×1
eclipse ×1
facebook ×1
flash ×1
gtk ×1
http ×1
javascript ×1
jpa ×1
linux ×1
maven-2 ×1
mysql ×1
nhibernate ×1
orm ×1
performance ×1
permissions ×1
qt ×1
qt4 ×1
root ×1
silverlight ×1
symbian ×1