NHibernate的ISession公开了一个带有两个重载的方法Persist().我无法在任何地方找到有关此方法的文档.在http://nhibernate.info/doc/nh/en/index.html上的NHibernate参考资料中甚至没有提到它.
这种方法是否已弃用,还是会被弃用?什么时候应该使用?它与SaveOrUpdate()相比如何?
任何指针都将非常感激.
更新:现在使用基于以下评论的只读集合
我相信下面的代码应该是线程安全的"锁定免费"代码,但是要确保我没有遗漏某些东西......
public class ViewModel : INotifyPropertyChanged
{
//INotifyPropertyChanged and other boring stuff goes here...
private volatile List<string> _data;
public IEnumerable<string> Data
{
get { return _data; }
}
//this function is called on a timer and runs on a background thread
private void RefreshData()
{
List<string> newData = ACallToAService();
_data = newData.AsReadOnly();
OnPropertyChanged("Data"); // yes, this dispatches the to UI thread
}
}
Run Code Online (Sandbox Code Playgroud)
具体来说,我知道我可以使用一个lock(_lock)
甚至是一个Interlocked.Exchange()
但我不相信在这种情况下需要它.volatile关键字应该足够(以确保不缓存该值),不是吗?有人可以确认一下,或者让我知道我对线程的理解不清楚:)
我int32
在Core Data数据库中有一个属性.我用它int
作为一个enum
位字段.
是否可以NSPredicate
根据此int的二进制值创建查询项?有点像@"bitFieldAttribute & 0x0001"
?
我也想知道这是否可以使用二进制类型属性?
我试图在我的CSS选择器中排除两种情况.目前选择器如下所示:
$$('select:not([class=session])').each(function(){
//blah blah
})
Run Code Online (Sandbox Code Playgroud)
但我想排除另一个名为"sessionproperties"的类
有没有办法在单个选择器语句中排除多个?对此有任何帮助表示赞赏.
注意:我尝试使用〜=运算符来表示"会话",但它对我来说完全不起作用.
我得到了一些其他开发人员的代码,他们创建了一些登录安全策略.例如,如果您尝试使用数据库中存在的用户名登录,它将开始记录失败的登录尝试次数.然后在达到3次登录尝试后,它会在日志中添加另一个条目,但将第1位添加到LockedOut.
你们相信这是一个很好的安全政策吗?尝试获取条目的人不会尝试大量随机用户名并强行锁定所有人的帐户吗?对于安全而言,这似乎是一种糟糕的哲学.
我认为更好的安全程序是锁定任何根据跟踪各种用户尝试的IP表进行3次尝试的人,并在30分钟左右到期以防止DDoS.
你们是如何设计登录安全性的?这是开发人员基本上做的:
if username is in database:
if first login: increase fail-attempt counter.
if second login: lock out username.
else: don't let him in.
else:
incorrect password.
Run Code Online (Sandbox Code Playgroud)
编辑:最终程序:
public void ResolveTimeouts()
{
if (data.Expire <= DateTime.Now)
{ // it will only delete ONE single entry from the database,
// that happens to be this user's IP
// If and only if, The expiration date is older than right now.
Delete(this.data);
data.Attempts = 0;
}
}
int uid = …
Run Code Online (Sandbox Code Playgroud) 当我尝试使用问题类时,我收到以下错误:
Fatal error: Class 'database' not found in path/problem.php on line 25
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我得到这个错误,在problem.php的顶部我需要database.php.怎么了?
problem.php
<?php
require("common.php");
require("database.php");
...
?>
Run Code Online (Sandbox Code Playgroud)
为database.php
<?php
class database
{
...
}
?>
Run Code Online (Sandbox Code Playgroud) 假设我有一个具有以下值的对象(另请注意我不希望使用datetime对象,只是下面的值,我希望在比较器本身中解决这个问题):
int year;
int month;
int day;
int sec;
int min;
Run Code Online (Sandbox Code Playgroud)
如何将我的Comparer中的所有多个值相互比较,以便按日期列出?
然后我想创建一个Comparer.cs类:
class MyComparer: IComparer
{
int sort;
public MyComparer(int s)
{
sort= s;
}
public int Compare(object x, object y)
{
Date d1 = (Date)x;
Date d2 = (Date)y;
int result= 0;
// d1.Year.CompareTo(d2.Year); //get accessors from other class
// i seem to be limited here by comparing only 1 single value to a other?
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
}
使用jquery技术从css-tricks.com有一个滚动/后面的侧边栏,如果你不知道我在说什么,这里是代码:
$(function() {
var $sidebar = $("#scroll-menu"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 15;
$window.scroll(function() {
if ($window.scrollTop() > offset.top) {
$sidebar.stop().animate({
marginTop: $window.scrollTop() - offset.top + topPadding
});
} else {
$sidebar.stop().animate({
marginTop: 0
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
这里也是链接http://css-tricks.com/scrollfollow-sidebar/
我遇到的唯一问题是它有一个容器,但是当你滚动到足够的页脚时,侧边栏会滚出容器.有没有办法限制它向下滚动多远?
以下是正在发生的事情的图像:http: //tinypic.com/r/2mcj2mv/7
提前致谢
我刚刚开始iOS/iPhone开发,我想开始使用XCode 4而不是XCode 3.2.XCode 4的稳定/功能是否足以开始iPhone开发,还是应该坚持使用XCode 3.2?