小编Whi*_*uit的帖子

是否可以在appSettings键中添加&符号?

我有以下appSettings部分

<appSettings>
  <add key="Foo" value="http://foo.bar.com/?app=xxx&FormName=yyy" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)

但IDE给了我两个错误:

  1. 错误25实体'FormName'未定义.
  2. 错误26期待';'.

似乎&正在造成问题.我不想将值分成单独的键.这个问题有优雅的方法吗?

asp.net appsettings

22
推荐指数
2
解决办法
6865
查看次数

"后退"按钮和防伪令牌

我得到了Runtime error与防伪属性相关的信息.

执行以下步骤:

  1. 创建一个MVC Web应用程序并启动
  2. 注册joe@acme.org
  3. 登出
  4. 注册jane@acme.org
  5. 登出
  6. joe@acme.org身份登录
  7. 点击后退按钮
  8. 登录jane@acme.org

错误: The provided anti-forgery token was meant for a different claims-based user than the current user.

可以采取哪些措施来防止发生此错误?

asp.net-mvc razor

21
推荐指数
2
解决办法
1万
查看次数

如何使用Autofixture创建和填充我的模拟类?

目前我正在使用EF6在UnitOfWork中实现我的存储库.我还创建了一个In-Memory模拟实现(MockUnitOfWork和MockRepository),以便我可以在单元测试中使用它们,但是我现在必须处理对象的繁琐设置.

这不是Autofixture的设计目的吗?我如何获得可以在包含FooBarr存储库的测试中使用的MockUnitOfWork ?我正在使用NSubstitute作为我的模拟框架.

IUnitOfWork

public interface IUnitOfWork
{
    void Save();
    void Commit();
    void Rollback();

    IRepository<Foo> FooRepository { get; }
    IRepository<Bar> BarRepository { get; }
}
Run Code Online (Sandbox Code Playgroud)

IRepository

public interface IRepository<TEntity> where TEntity : class
{
    Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string         includeProperties = "");

    IEnumerable<TEntity> Get(Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null);
    TEntity GetByID(object id);

    void Insert(TEntity entity);
    void Delete(object id);
    void Delete(TEntity entityToDelete);
    void Update(TEntity entityToUpdate);
}
Run Code Online (Sandbox Code Playgroud)

c# autofixture nsubstitute

15
推荐指数
1
解决办法
2010
查看次数

在mercurial中,我如何找到包含字符串的变更集?

假设我有以下修订:

rev 1:
+ Dim Foo as integer

rev 2:
+ I like big butts, I cannot lie

rev 3
- Dim Foo as integer
Run Code Online (Sandbox Code Playgroud)

Foo在rev 1和2中,并从三个中移除.我可以发出什么命令将返回添加或删除Foo的所有更改集?

理想情况下,我也希望能够从toroisehg做到这一点

mercurial tortoisehg

12
推荐指数
1
解决办法
4941
查看次数

将DRY应用于自动混合"构建"语句

假设我有这个具体的类:

public partial class User
{
    public int ID { get; set; }
    public string Email { get; set; }
    public string FullName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我想创建一个具有有效电子邮件地址的匿名实例,并且fullname字段不超过20个字符.我可以做这个:

var fixture = new Fixture();
var anonUser = fixture.Build<User>()
    .With(x => x.Email, string.Format("{0}@fobar.com", fixture.Create<string>()))
    .With(x => x.FullName,  fixture.Create<string>()Substring(0,20))
    .Create();
Run Code Online (Sandbox Code Playgroud)

有没有办法可以在一个地方定义它,所以AF知道我可以通过使用以下方式获得我的自定义anon类:

var newAnon = fixture.Build<User>();
Run Code Online (Sandbox Code Playgroud)

c# autofixture

12
推荐指数
1
解决办法
1427
查看次数

更新后的SQL Server错误:提供给该函数的令牌无效

我正在使用我的机器(和SSMS),一切正常.我重新启动,然后Windows 10应用了以下更新:

Windows Malicious Software Removal Tool for Windows 8, 8.1, 10 and Windows Server 2012, 2012 R2, 2016 x64 Edition - April 2017 (KB890830)
Security Update for Adobe Flash Player for Windows 10 Version 1607 (for x64-based Systems) (KB4018483)
Security Update for Microsoft Silverlight (KB4017094)
Cumulative Update for Windows 10 Version 1607 for x64-based Systems (KB4015217)
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试登录SSMS时,我收到以下错误:

已成功与服务器建立连接,但在登录过程中发生错误.(提供者:SSL提供者,错误:0 - 提供给该函数的令牌无效(Microsoft SQL Server)

提供给该函数的令牌无效

这看起来与安全性有关,但我不知道如何解决它.我的计算机使用Windows Server Essentials进行备份(连接器为绿色).

sql-server

12
推荐指数
3
解决办法
3139
查看次数

拼写检查Excel函数中的单个单词

这个小的Excel VBA函数总是返回false,没有传入任何单词.

Function SpellCheck(SomeWord As String)

SpellCheck = Application.CheckSpelling(SomeWord)

End Function
Run Code Online (Sandbox Code Playgroud)

实际上,在IDE中,我可以验证Application.CheckSpelling("hello")是否失败,尽管Excel拼写检查程序确实检测到了拼写错误.

我要做的是,如果拼写正确,每个单词都会得到一个T/F值.

excel vba spell-checking

10
推荐指数
2
解决办法
8398
查看次数

使用VB和LI​​NQ对<Object>列表进行排序

我正在尝试一些LINQ表达式,但无法使它们与List类一起使用.基本上我希望能够按属性类型对自定义对象列表进行排序,但C#LINQ语法是杀了我,我无法弄清楚如何将它转换为VB

Class Foo
    Sub New(Name As String, Position As Integer)
        Me.Name = Name
        Me.Position = Position
    End Sub
    Public Name As String
    Public Position As Integer
End Class

Sub Main()
    Dim l As New List(Of Foo)
    l.Add(New Foo("C", 3))
    l.Add(New Foo("B", 2))
    l.Add(New Foo("A", 1))

    Dim asc = ..... (sort l by position asecnding)
    Dim desc = ..... (sort l by position descending)

End Sub
Run Code Online (Sandbox Code Playgroud)

linq vb.net

9
推荐指数
2
解决办法
3万
查看次数

如何使用GNU grep for windows/dos来避免双引号?

我正在努力寻找

大会="Foobar的

在所有文件中并将输出定向到tmp.txt

我试过(cmd /错误)

grep -r"Assembly = \"Foobar".>> tmp.txt错误(无效参数)

grep -r"Assembly =""Foobar".>> tmp.txt
错误(空间不够)

grep -r'Assembly ="Foobar'.>> tmp.txt
错误(空间不够)

很沮丧.有什么建议?

grep cmd gnu

7
推荐指数
1
解决办法
6021
查看次数

用于调试Lough测试的键盘快捷方式在Visual Studio IDE(2013)中运行

我知道有几个VS键盘快捷键用于运行单元测试,但我真正找不到的并且希望能够在调试模式下运行最后执行的测试.

Ctrl R,L将重复上次运行,但不会在调试模式下重复.

如果您正在调试测试,并且它将上下文更改为您实际运行的代码,然后您停止测试,是否有办法仅使用键盘再次以调试模式启动该测试?

unit-testing visual-studio-2013

7
推荐指数
2
解决办法
1187
查看次数