早些时候我问过这个问题.答案导致了另一个问题,就像你在你面前所说的那样.
我的问题是,我有一个自定义的MembershipProvider使用AccountRepository使用ObjectContext.因为它MembershipProvider是一个SingletonMVC(据我所知),AccountRepository它ObjectContext应该被注入一次,并在其余MembershipProvider的生命时间内保持不变.
但是,在我的控制器中,我还使用具有对象上下文的存储库.在这些控制器中,我需要在存储库与请求之间共享对象上下文.我有以下绑定:
Bind<IMyContext>().To<MyObjectContext>().InRequestScope();
// put bindings here
Bind<IAccountRepository>().To<EFAccountRepository>
Run Code Online (Sandbox Code Playgroud)
并在 Application_Start()
kernel.Inject(Membership.Provider);
Run Code Online (Sandbox Code Playgroud)
问题是Ninject在认为请求完成时显然会调用对象上下文(我想30秒后).
我注意到,当您设置绑定时,您可以指定"何时注入".问题是,我需要"注入时注入".即注射时对象上下文到该帐户控制器注入时的帐户控制器到成员资格提供.我似乎没有...
MyMembershipProvider在MVC中.只需将它的一个实例(后面和接口)传递给需要它的控制器,就像我使用存储库一样.然后Ninject将根据请求实例化提供程序.我不喜欢它,因为我确信MVC有理由将成员资格提供者实例化为单身人士.kernel.Inject在每个事件中再次调用.每次请求重新初始化提供程序几乎等同于重新实例化,除了更脏.恕我直言,第一次解决方案是最好的.但是,我更愿意找到一种方法来将Ninject设置为以我想要的方式绑定.
我该怎么办?
CodeSign "build/Release-iphoneos/Nice Saying123.app"
cd "/Users/c28/Documents/Office Projects/Nice Saying123"
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv _CODESIGN_ALLOCATE_ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
/usr/bin/codesign -f -s "iPhone Developer: dipak kasabwala (29QJU3WV6X)" "--resource-rules=/Users/c28/Documents/Office Projects/Nice Saying123/build/Release-iphoneos/Nice Saying123.app/ResourceRules.plist" --entitlements "/Users/c28/Documents/Office Projects/Nice Saying123/build/Nice Saying123.build/Release-iphoneos/Nice Saying123.build/Nice Saying123.xcent" "/Users/c28/Documents/Office Projects/Nice Saying123/build/Release-iphoneos/Nice Saying123.app"
/Users/c28/Documents/Office Projects/Nice Saying123/build/Release-iphoneos/Nice Saying123.app: replacing invalid existing signature
/Users/c28/Documents/Office Projects/Nice Saying123/build/Release-iphoneos/Nice Saying123.app: CSSMERR_TP_NOT_TRUSTED
Command /usr/bin/codesign failed with exit code 1
Run Code Online (Sandbox Code Playgroud) 我们有一些创建一个Windows Java桌面应用程序的配置文件的%APPDATA%,并创建日志的%TEMP%位置.现在我们计划发布适用于Mac OS X的桌面应用程序.我们面临以下困难:
.app(文件扩展名应用程序)中,因此请建议我们在哪里可以保留配置文件.%TEMP%在Mac OS X 中的位置,因为Mac OS X会%TEMP%根据计划自动清除位置.所以我们不希望数据从temp中丢失,也不希望在.app中保存数据.请建议.
谢谢
我很难理解zipfile模块的zipfile.ZIP_DEFLATED和zipfile.ZIP_STORED压缩模式之间的区别.
有人可以帮帮我吗?
谢谢,
马克斯
我的代码中有一个DataTable,比如pdt.我只想选择all table["id"]并在整数数组中填充.
我可以继续,foreach但我正在尝试学习Lambda表达式.我无法弄清楚如何处理这个问题.
我试过了
List<int> Ids = pdt.Select(row => row["Id"]; return Convert.ToInt32(r));
Run Code Online (Sandbox Code Playgroud)
和
int[] Ids = pdt.Select(row => row["Id"]);
Run Code Online (Sandbox Code Playgroud)
但似乎没什么用.我很确定这是一个基本问题,请帮助新手.
我正在使用C#为Office 2007创建一个插件.只要用户在"收件箱"窗格中单击电子邮件列表中的电子邮件,此插件就会负责在新窗格中显示电子邮件标头信息.现在,我不确定当用户选择电子邮件并阅读该电子邮件标题信息时,如何在"收件箱"窗格中显示鼠标单击事件.任何有用的指针?
我目前正在为客户进行网站开发.该站点将托管在客户主站点的子域中.客户的主要网站是
www.xyz.com
我正在处理的网站将托管在
funds.xyz.com
访问www.xyz.com的任何人都会在其计算机上写入一个cookie,其中包含指定用户所在区域的数据.我需要在我的网站上提供这些数据.我可以访问这个cookie吗?
正如标题所说,现在我可以简单地将HTML转换NSAttributedString为initWithHTML:documentAttributes:,但我想在这里做的是反向.是否有任何第三方库来实现这一目标?
@implementation NSAttributedString(HTML)
-(NSString *)htmlForAttributedString{
NSArray * exclude = [NSArray arrayWithObjects:@"doctype",
@"html",
@"head",
@"body",
@"xml",
nil
];
NSDictionary * htmlAtt = [NSDictionary
dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType,
NSDocumentTypeDocumentAttribute,
exclude,
NSExcludedElementsDocumentAttribute,
nil
];
NSError * error;
NSData * htmlData = [self dataFromRange:NSMakeRange(0, [self length])
documentAttributes:htmlAtt error:&error
];
//NSAttributedString * htmlString = [[NSAttributedString alloc]initWithHTML:htmlData documentAttributes:&htmlAtt];
NSString * htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
return htmlString;
}
@end
Run Code Online (Sandbox Code Playgroud) 我想创建Custom UISwitch按钮,我该怎么办?
use warnings;
my @array = (0, 1);
my $scalar1 = $array[0];
my $scalar2 = @array[0];
if($scalar1 == $scalar2) {
print "scalars are equal\n";
}
Run Code Online (Sandbox Code Playgroud)
这是我运行时的输出/usr/bin/perl5.10.1 test.pl:
Scalar value @array[0] better written as $array[0] at test.pl line 4.
scalars are equal
Run Code Online (Sandbox Code Playgroud)
我很担心这个警告.