我有一个(字符串,十进制)字典,需要从第二个项目开始计算所有值(十进制值)的总和.使用LINQ可以实现吗?
我们正在开发一个通过ClickOnce部署的应用程序.我们有一个VeriSign代码签名证书,我们用它来签署我们的应用程序(通过signtool.exepost-build)和ClickOnce清单.我们目前有两个与签名有关的问题:
我们正在使用我们的证书签署.exe.构建我们的应用程序后,我们可以看到它已签名(例如,通过"signtool verify/pa TheExecutable.exe").但是在通过ClickOnce安装应用程序后,.exe不再签名.
我们正在使用我们的证书签署ClickOnce清单.但是当我们尝试通过ClickOnce安装应用程序时,ClickOnce安装程序会显示"Unknown Publisher".
问题#1总是发生.问题#2有时会神秘地消失,但此后不久就会回来,我们已经持续了几个星期了.
有任何想法吗?
我正在使用.net 4.0 c#.
我希望能够从当前的http请求中获取url,包括任何虚拟目录.例如(请求和寻求的价值):
http://www.website.com/shop/test.aspx - > http://www.website.com/shop/
http://www.website.com/test.aspx - > http://www.website.com/
http://website.com/test.aspx - > http://website.com/
怎么可能实现这个目标?
测试时,以下行以空引用失败:
var awards = _session.QueryOver<Body>().Where(x => x.BusinessId == (int)business).List();
Run Code Online (Sandbox Code Playgroud)
我的测试是这样的:
var mockQueryOver = new Mock<IQueryOver<Body, Body>>();
mockQueryOver.Setup(q => q.List()).Returns(new List<Body> {_awardingBody});
_mockSession.Setup(c => c.QueryOver<Body>()).Returns((mockQueryOver.Object));
_mockCommandRunner = new Mock<ICommandRunner>();
_generator = new CertificateGeneratorForOpenSSLCommandLine(_mockSession.Object, _mockCommandRunner.Object, _mockDirectory.Object, _mockFile.Object, _mockConfig.Object);
Run Code Online (Sandbox Code Playgroud)
说实话,我在黑暗中徘徊 - 我对nHibernate和Moq相对较新,所以我不太确定要google什么才能获得正确的信息.
我正在学习QueryOver,但我不能为我的生活弄清楚如何做多个简单的查询.
我写了以下内容:
var result = Session.CreateCriteria(typeof (Product))
.CreateAlias("Categories", "categories")
.Add(Property.ForName("categories.Id").Eq(categoryId))
.List<Product>();
Run Code Online (Sandbox Code Playgroud)
这实现了期望的结果.基本上我有
产品> ProductCategory <类别
ProductCategory只有ProductId/CategoryId,我正在尝试选择特定类别中的所有产品.
我不知道从哪里开始尝试使用queryover执行此操作.
有人可以解释为什么下面的C#行与下面的foeach块的行为不一样吗?
string [] strs = {"asdf", "asd2", "asdf2"};
strs.Select(str => doSomething(str));
foreach(string str in strs){
doSomething(str);
}
Run Code Online (Sandbox Code Playgroud)
我在doSomething()中放置了一个断点,它不会在Select中触发,但它与foreach一起触发.
TIA
在c#中询问用户名和密码的更好方法是什么?
我需要他们传递一个DirectoryContextClass调用.
我需要在Powershell中使用类似Get-Credential的东西,将用户名和密码存储在变量中.
谷歌搜索它我发现这个工作有一些有趣的类,但框架4.0中没有内置类(例如:var cred = new credentialDialog()?
强安全性是可选的,只需掩盖输入密码字段即可.
谢谢你们
有没有办法添加注释来记录 Dictionary 或 ConcurrentDictionary 以了解键/值的含义?
例如:
Dictionary<guid, string> _users;
Run Code Online (Sandbox Code Playgroud)
This example has a dictionary of users. The guid is the UserId and the string is the username, but it's hard to tell other than just "knowing".
Is there a way to add docs so that when you add items, intellisense tells the developer a note about the key & value?
I know I can add a <summary> comment above it and it puts that note in the object itself, but …
为了使我的查询保持独立并可能重复使用,我倾向于在NH2中执行此操作:
public class FeaturedCarFinder : DetachedCriteria
{
public FeaturedCarFinder(int maxResults) : base(typeof(Car))
{
Add(Restrictions.Eq("IsFeatured", true));
SetMaxResults(maxResults);
SetProjection(BuildProjections());
SetResultTransformer(typeof(CarViewModelMessage));
}
}
Run Code Online (Sandbox Code Playgroud)
我现在想使用QueryOver,我已经转移到了NH3,但我不确定如何使用QueryOver进行上述操作?
我想知道一种正确的方法来启动和停止强制和非强制的线程作业.这是停止线程的正确方法吗?
public class ProcessDataJob : IJob
{
private ConcurrentQueue<byte[]> _dataQueue = new ConcurrentQueue<byte[]>();
private volatile bool _stop = false;
private volatile bool _forceStop = false;
private Thread _thread;
private int _timeOut = 1000;
public void Start()
{
_stop = false;
_forceStop = false;
_thread = new Thread(ProcessData);
_thread.Start();
}
private void ProcessData()
{
while (!_stop || _dataQueue.Count > 0)
{
if(_forceStop) return;
byte[] data;
if(_dataQueue.TryDequeue(data))
{
//Process data
//.....//
}
}
}
public void Stop(bool force)
{
_stop = true; …Run Code Online (Sandbox Code Playgroud) 尝试获取按月分组的总行数并与QueryOver进行对抗.从我发现的有限资源,似乎线索是Projections.SqlGroupProjection但我无法正确.
这是我到目前为止:
var jobs = _statelessSession.QueryOver<Job>()
.SelectList(list => list
.Select(Projections.SqlGroupProjection("MONTH(DateCreated) AS Month", "MONTH(DateCreated)",new string[]{"DateCreated"},new[]{NHibernateUtil.Int32}))
.SelectCount(m => m))
.List<object>();
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
1: ids = GetAnArrayOfIds();
2: jobEntities = jobEntities.Where(j => j.Locations.Select(l => l.Id).Any(ids.Contains));
Run Code Online (Sandbox Code Playgroud)
如何使用QueryOver编写2?
谢谢,
c# ×7
nhibernate ×5
queryover ×5
.net ×3
linq ×2
asp.net ×1
c#-3.0 ×1
clickonce ×1
deployment ×1
dictionary ×1
intellisense ×1
moq ×1
request ×1
unit-testing ×1
url ×1
winforms ×1