小编Ufu*_*arı的帖子

jQuery qTip - 创建前触发

我尝试someFunction()在创建qtip之前触发

$('.selector').qtip({
   content: {
      text: someFunction(this.id) }
});
Run Code Online (Sandbox Code Playgroud)

这段代码有效,但我认为这是一个肮脏的解决方案.start: event在大多数jquery插件中是否有类似的东西(例如draggable)?我在文档中没有发现它.

编辑:好的,这段代码不起作用.他在pageload上触发了该功能而不是onhover.

更新:

function someFunction(someId)
{
    // some code ...
    var searchResult = ' ... some results from the search -> from '+someId+' ... ';
    return searchResult;

}
Run Code Online (Sandbox Code Playgroud)

jquery events qtip

6
推荐指数
1
解决办法
1533
查看次数

使用NCrunch运行测试时如何查看控制台输出?

我不知道它是否已实现,但在"输出"窗口中有一个NCrunch输出选项.

在此输入图像描述

在运行测试时,TestDriven.NET已经这样做了,我意识到在快速尝试时很有用.有没有办法让它在NCrunch中运行?

.net unit-testing visual-studio ncrunch

6
推荐指数
1
解决办法
628
查看次数

具体类如何隐藏它实现的接口的成员

我将举一个.NET的例子.

ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary
Run Code Online (Sandbox Code Playgroud)

在这里您可以看到ConcurrentDictionary实现字典接口.但是我无法Add<TKey,TValue>从ConcurrentDictionary实例访问方法.这怎么可能?

IDictionary<int, int> dictionary = new ConcurrentDictionary<int, int>();
dictionary.Add(3, 3); //no errors

ConcurrentDictionary<int, int> concurrentDictionary = new ConcurrentDictionary<int, int>();
concurrentDictionary.Add(3, 3); //Cannot access private method here
Run Code Online (Sandbox Code Playgroud)

更新:

我知道如何访问它,但我不知道显式实现接口可以允许将访问修饰符更改为内部.它仍然不允许将其设为私有.它是否正确?关于该部分的更详细解释将是有帮助的.另外,我想知道一些有效的用例.

.net c#

6
推荐指数
3
解决办法
593
查看次数

将查询字符串中的参数值映射到DTO属性

我试图找到一种方法来获取此查询字符串中的值到我的DTO对象.

example.org?code=abc
Run Code Online (Sandbox Code Playgroud)

我必须将代码值映射到AuthorizationCode属性(参数名称也不匹配).我试过像这样的路由,但它不起作用.

[Route("?code={AuthorizationCode}", "GET")]
public class Registration
{
    public string AuthorizationCode { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

由于这是一个回调网址,我没有机会更改它.我怎么能做到这一点?

routing servicestack

6
推荐指数
1
解决办法
4083
查看次数

我的构建脚本是否针对多个目标框架正常工作?

我写了一个小的MSBuild脚本来构建我的多个版本的项目.当我从VS2012命令提示符运行它时,它没有任何错误或异常.但是,当我比较生产的组件时,它们是相同的.我的剧本有什么问题吗?

<Target Name="Build">

  <MSBuild Projects=".\WcfClientBase\WcfClientBase.csproj" 
           Properties="Configuration=Release;OutputPath=.\BuildArtifacts\net45;TargetFrameworkVersion=v4.5" />

  <MSBuild Projects=".\WcfClientBase\WcfClientBase.csproj"
           Properties="Configuration=Release;OutputPath=.\BuildArtifacts\net40;TargetFrameworkVersion=v4.0" />

  <MSBuild Projects=".\WcfClientBase\WcfClientBase.csproj"
           Properties="Configuration=Release;OutputPath=.\BuildArtifacts\net35;TargetFrameworkVersion=v3.5" />

</Target>
Run Code Online (Sandbox Code Playgroud)

我安装了VS2012 Professional.我还注意到.NET 4.5没有自己的MSBuild.exe.它是使用4.0版本的吗?

更新

我使用Visual Studio为每个版本构建它,并且所有程序集都不同.我的脚本有问题.我故意错误输入TargetFrameworkVersion参数名称,但它仍然构建并生成相同的输出.也许它无法从项目文件中覆盖该参数,或者我还缺少其他参数.还有什么想法吗?

.net msbuild visual-studio .net-4.5 visual-studio-2012

5
推荐指数
1
解决办法
824
查看次数

将GET请求发送到路由中给出的路径

我试图从这样的URL调用REST服务:

example.org/account/someusername
Run Code Online (Sandbox Code Playgroud)

我已经定义了请求和响应DTO.

[Route("/account/{UserName}", "GET")]
public class AccountRequest : IReturn<AccountResponse>
{
    public string UserName { get; set; }
}

public class AccountResponse
{
    public int Id { get; set; }
    public string UserName { get; set; }
    public string Bio { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

致电服务:

JsonServiceClient client = new JsonServiceClient("http://example.org");
AccountRequest request = new AccountRequest { UserName = "me" };

AccountResponse response = client.Get(request); 
Run Code Online (Sandbox Code Playgroud)

但是当我在客户端上调用Get时,它不尊重该路由.当我在调试器中检查客户端实例时,AsyncOneWayBaseUri值为example.org/json/asynconeway/.这部分是无关紧要的,因为它并不意味着请求被发送到此URL.我实际上不知道它发送请求的位置.我没有得到任何错误,响应对象中的所有属性都为null.

我在这里错过了什么?

servicestack

5
推荐指数
2
解决办法
5620
查看次数

在单个测试类中测试接口的多个实现

我需要通过上一流水平的测试数据,但是TheoryInlineData属性只能在方法中使用.

public class ContainerTests : TestFixture
{
    private IContainer _container;

    public ContainerTests(string containerName)
    {
        _container = CreateContainer(containerName);
    }

    [Fact]
    public void ResolveJobFactory()
    {
        IJobFactory jobFactory = _container.Resolve<IJobFactory>();
    }

    private IContainer CreateContainer(string containerName)
    {
        if (containerName == "CastleWindsor")
        {
            return new WindsorContainerAdapter();
        }
        //other adapters

        throw new NotImplementedException();
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法在xUnit.net中实现类似的东西?

.net c# unit-testing xunit.net

5
推荐指数
1
解决办法
912
查看次数

具有不同签名的控制器操作方法

我试图以文件/ id格式获取我的URL .我猜我的控制器中应该有两个Index方法,一个带参数,一个带不带.但我在下面的浏览器中收到此错误消息.

无论如何这里是我的控制器方法:

public ActionResult Index()
{
    return Content("Index ");
}

public ActionResult Index(int id)
{
    File file = fileRepository.GetFile(id);
    if (file == null) return Content("Not Found");
    else return Content(file.FileID.ToString());
}
Run Code Online (Sandbox Code Playgroud)

更新:完成添加路线.谢谢Jeff

c# model-view-controller asp.net-mvc controller asp.net-mvc-routing

4
推荐指数
2
解决办法
2641
查看次数

ReSharper为事件方法命名样式

Resharper不检测用户或VS是否生成了方法.它总是突出显示由VS生成的事件方法,它们在其中有下划线(如button1_Click()偶数).

在这种情况下如何例外?

c# resharper

4
推荐指数
1
解决办法
311
查看次数

这两个比较陈述之间有什么区别?

这两个比较法的差异是什么?

var result = EqualityComparer<T>.Default.Equals(@this, null);
var result = @this == null;
Run Code Online (Sandbox Code Playgroud)

显然,目的是测试对象'@this'是否为空.

.net c#

4
推荐指数
1
解决办法
128
查看次数