小编Mat*_*t W的帖子

调用变量中命名的JavaScript函数

我有一个JavaScript变量,其中包含JavaScript函数的名称.通过使用$ .ajax等加载和放置页面上存在此函数.

谁能告诉我如何调用变量中命名的javascript函数,好吗?

函数的名称位于变量中,因为用于加载页面片段的URL(插入到当前页面中)包含要调用的函数的名称.

我对如何实施此解决方案的其他建议持开放态度.

javascript variables function

148
推荐指数
4
解决办法
20万
查看次数

找不到testhost.dll。请发布您的测试项目,然后重试

我有一个具有单个XUnit测试方法的简单dotnet核心类库:

TestLib.csproj:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.SDK" Version="15.9.0" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.console" Version="2.4.1">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="xunit.runners" Version="2.0.0" />
  </ItemGroup>

</Project>

BasicTest.cs:
using Xunit;

namespace TestLib
{
    public class BasicTest
    {
        [Fact(DisplayName = "Basic unit test")]
        [Trait("Category", "unit")]
        public void TestStringHelper()
        {
            var sut = "sut";
            var verify = "sut";

            Assert.Equal(sut, verify);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我在CLI上输入项目并键入dotnet build项目构建。如果输入, …

c# unit-testing xunit.net .net-core

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

T-SQL Pivot?可以从行值创建表列

实际上是否可以旋转T-SQL(2005)以便(为了参数)第一列的行的值成为输出表列的标题?

我知道这不是PIVOT的真正含义,但它正是我所需要的 - 能够请求一个表格,其中列之前是未知的,因为它们已作为值输入到表格中.

即使是黑客也会很好,tbh.

t-sql pivot database-table

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

aws_iam_policy 和 aws_iam_role_policy 之间的区别

我有一个aws_iam_role想要添加策略的项目。通常,我会创建一个策略aws_iam_role并将其附加到角色aws_iam_role_policy_attachment

然而,我看过一些文档,aws_iam_role_policy在我看来,它似乎做了同样的事情。

我是正确的还是我错过了细微的差别?

amazon-web-services amazon-iam terraform-provider-aws terraform0.14.7

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

使用t-SQL检索XML元素名称

如果我有:

<quotes>
  <quote>
    <name>john</name>
    <content>something or other</content>
  </quote>
  <quote>
    <name>mary</name>
    <content>random stuff</content>
  </quote>
</quotes>
Run Code Online (Sandbox Code Playgroud)

如何使用T-SQL获取元素名称'name'和'content'的列表?

我到目前为止最好的是:

declare @xml xml
set @xml = ...
select r.value('quotes/name()[1]', 'nvarchar(20)' as ElementName
from @xml.nodes('/quotes') as records(r)
Run Code Online (Sandbox Code Playgroud)

但是,当然,我不能让这个工作.

xml sql t-sql sql-server xpath

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

使用动态查询语言修剪()字符串列表以生成修剪的IQueryable <string>

这是可能的,还是我只是试图过度缩短我的代码?

我认为它可能是这样的:

IQueryable<string> trimmedStrs = untrimmedStrsArr.AsQueryable<string>().All(s => s.Trim());
Run Code Online (Sandbox Code Playgroud)

但那并不好:(

c# linq string trim

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

File.Exists是一项昂贵的操作吗?

回复:http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx

有谁知道这是一个特别慢或锁定的操作,可能会影响大型环境中的服务器性能?

.net io file exists

16
推荐指数
4
解决办法
8694
查看次数

请求失败,HTTP状态为401:未授权

我有一个在我的IIS6(XP专业版SP2)中运行的.NET 2.0网站(VB)和一个托管ASMX Web服务的.NET 3.5(在IIS的ASP.NET选项卡下配置为.NET2).

在Chrome中,我可以调用ASMX并成功调用Web方法.但是,在使用.NET 2.0网站调用代码中的Web方法时,我得到:

请求失败,HTTP状态为401:未授权.

我该如何解决这个问题?

web-services .net-3.5 http-status-code-401

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

使用CSS检测不同的设备平台

我想说我已阅读并尝试了许多说明的变体:

我想让我的页面使用不同的CSS文件,具体取决于所使用的设备.我已经看到了许多解决方案,都使用了上面的某种形式.

然而,当在HTC Desire上进行测试时,我始终获得用于iPad的输出或完全未经过滤的输出.目前,我的测试代码基于:

http://www.cloudfour.com/ipad-css/
Run Code Online (Sandbox Code Playgroud)

这是我的HTML文件:

<html>
<head>
    <title>orientation and device detection in css3</title>

    <link rel="stylesheet" media="all and (max-device-width: 480px) and (orientation:landscape)" href="iphone-landscape.css" />
    <link rel="stylesheet" media="all and (max-device-width: 480px) and (orientation:portrait)" href="iphone-portrait.css" />

    <link rel="stylesheet" media="all and (device-width: 768px) and (device-height: 1024px) and (orientation:landscape)" href="ipad-landscape.css" />
    <link rel="stylesheet" media="all and (device-width: 768px) and (device-height: 1024px) and (orientation:portrait)" href="ipad-portrait.css" />

    <link rel="stylesheet" media="all and (device-width: 480px) and (device-height: 800px) and (orientation:landscape)" href="htcdesire-landscape.css" /> …
Run Code Online (Sandbox Code Playgroud)

css mobile-devices platform-detection

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

如何在 VS Code 中调试 dotnet 测试?

本文介绍如何设置 VS Code 设置以将调试目标指向单元测试项目的构建输出。因此,我将我的设置如下:

{
    "explorer.confirmDragAndDrop": false,
    "git.allowForcePush": true,
    "git.autofetch": true,
    "window.zoomLevel": 0,
    "csharp.unitTestDebuggingOptions": {
        "sourceFileMap": {
            "C:\\git\\MsTester\\bin\\Debug\\netcoreapp2.1": "C:\\git\\MsTester\\bin\\Debug\\netcoreapp2.1"
        }
    },
    "files.autoSave": "afterDelay",
    "files.exclude": {
        "**/bin": true,
        "**/node_modules": true,
        "**/obj": true
    },
    "csharpfixformat.style.spaces.insideEmptyBraces": false,
    "csharpfixformat.style.braces.allowInlines": false,
    "csharpfixformat.style.spaces.beforeParenthesis": false,
    "csharpfixformat.style.spaces.afterParenthesis": false,
    "csharp.format.enable": false,
    "extensions.ignoreRecommendations": true
}
Run Code Online (Sandbox Code Playgroud)

但是,我不确定如何设置launch.json以启动dotnet test它以便它可以附加调试器。

这是我目前所拥有的:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "MsTester",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/MsTester/bin/Debug/netcoreapp2.1/MsTester.dll",
            "windows": {
                "args": [
                    "--filter",
                    "TestCategory=lbshell",
                    "--logger",
                    "trx",
                    "--results-directory",
                    ".\\TestResults",
                    "--settings", …
Run Code Online (Sandbox Code Playgroud)

unit-testing vscode-settings dotnet-test vscode-debugger

12
推荐指数
2
解决办法
7132
查看次数