小编bin*_*les的帖子

ASP.NET Web.Config ConfigurationManager.AppSettings文件缓存

我正在使用ConfigurationManager.AppSettings集合从ASP.NET应用程序中的Web.config文件中检索配置值.有没有人知道AppSettings中的值是否以某种方式缓存在内存中,或者每次检索设置时是否发生Web.config文件读取?

string someValue = ConfigurationManager.AppSettings["SomeSetting"];
Run Code Online (Sandbox Code Playgroud)

谢谢

asp.net caching configurationmanager web-config

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

TypeScript类型保护奇数

我在循环中的三元运算符中使用TypeScript类型保护,并看到我不理解的行为.

我的界面

interface INamed {
    name: string;
}

interface IOtherNamed extends INamed {
    otherName: string;
}
Run Code Online (Sandbox Code Playgroud)

我的打样

function isOther(obj: any): obj is IOtherNamed {
    ... // some check that returns boolean
}
Run Code Online (Sandbox Code Playgroud)

一般用法样本

var list: Array<{named: INamed}> = [];

for(let item of list) {
    var other: IOtherNamed = ...
}
Run Code Online (Sandbox Code Playgroud)

在我的for循环中,我使用我的类型保护器将当前项目或null分配给IOtherNamed变量.

这不起作用

// Compiler Error: INamed is not assignable to IOtherNamed
for(let item of list) {
    var other: IOtherNamed = isOther(item.named) ? item.named : null;
}
Run Code Online (Sandbox Code Playgroud)

这样做

for(let item of …
Run Code Online (Sandbox Code Playgroud)

typescript typescript1.6

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

VSCode Extension API-识别文件或文件夹,单击资源管理器上下文菜单

VSCode 1.3增加了将命令添加到上下文菜单的支持。有没有一种方法可以确定是否单击了文件或文件夹以打开资源管理器上下文菜单?

"menus": {
    "explorer/context": [
        {
            "when": "????",
            "command": "extension.myCommand",
            "group": "myGroup"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

另外,在此处的when子句中是否可以检查表达式的完整列表?

visual-studio-code vscode-extensions

6
推荐指数
2
解决办法
1978
查看次数

TypeScript:将联合类型映射到另一个联合类型

是否可以在TypeScript中将联合类型映射到另一个联合类型?

我希望能做什么

例如给定一个联合类型A:

type A = 'one' | 'two' | 'three';
Run Code Online (Sandbox Code Playgroud)

我希望能够将它映射到联合类型B:

type B = { type: 'one' } | { type: 'two'} | { type: 'three' };
Run Code Online (Sandbox Code Playgroud)

我试过了什么

type B = { type: A };
Run Code Online (Sandbox Code Playgroud)

但这会导致:

type B = { type: 'one' | 'two' | 'three' };
Run Code Online (Sandbox Code Playgroud)

这不是我想要的.

discriminated-union typescript

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

ASP.NET A/B拆分测试

有谁知道学习如何实施A/B split测试的任何好资源(书籍,文章,现有软件等)ASP.NET

asp.net testing asp.net-mvc

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

Internet Explorer嵌套表单发布

我正在使用ASP.NET MVC创建一个发布到Paypal沙箱的页面.发布到Paypal网站的表单嵌套在父表单中.我正在使用Internet Explorer 7,由于某种原因,嵌套表单发布到我的本地计算机而不是paypal网站.如果我在第一个之后直接添加相同嵌套表单的副本,则第一个发布到localhost,第二个发布到期望的位置.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>
    </title>
</head>
<body>
    <form name="aspnetForm" method="post" action="" id="aspnetForm">        
        <!--First form posts locally-->
        <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
            <input type="submit" value="Pay"/>
        </form>     

        <!--Second identical form posts to the expected destination-->
        <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">     
            <input type="submit" value="Pay"/>
        </form> 
    </form>
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc

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

TypeScript - 根据鉴别器将联合类型映射到另一个联合类型的函数

我有 2 个使用相同鉴别器字段 + 值的可区分联合类型。我正在尝试编写一个函数,可以根据鉴别器将 1 映射到另一个。

例如

输入类型:

type InA = {
    type: 'a',
    data: string
};

type InB = {
    type: 'b',
    data: number
};

type In = InA | InB;
Run Code Online (Sandbox Code Playgroud)

输出类型:

type OutA = {
    type: 'a',
    data: Object
};

type OutB = {
    type: 'b',
    data: Array<number>
};

type Out = OutA | OutB;
Run Code Online (Sandbox Code Playgroud)

映射功能

// This is the function I'd like to have a better type signature
// for inferring output type based on input …
Run Code Online (Sandbox Code Playgroud)

discriminated-union typescript

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

为什么宽度/高度适用于内联 img 元素

我的理解是内联元素通常不能使用 CSSwidthheight属性来调整大小。内联似乎img是一个例外,您可以使用width和调整它的大小height

img {
  display: inline;
  height: 35px; // this works
}
Run Code Online (Sandbox Code Playgroud)

我想了解这是否是特定于img标签的东西,或者是否还有其他一些细微差别使这项工作起作用。

有人可以指出一些描述此行为的规范或文档吗?

css

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

DynamoDB 邻接列表模式

我试图更好地理解在 AWS DynamoDB 中使用邻接列表模式进行多对多 (m:n) 关系设计。

查看此处的 AWS 文档: https: //docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-adjacency-graphs.html我们有一个示例,其中发票和账单实体具有 m:n 关系。

在此输入图像描述

I understand that I can get details of all bills associated with a particular invoice by reading a single partition. For example I can query for Invoice-92551 and know some attributes of the 2 bills that are associated with it based on the additional items in the partition.

My question is what do I have to do to get the full bill attributes for these 2 …

adjacency-list amazon-dynamodb

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

使用条件返回类型实现泛型函数

我正在尝试一个非常基本的(人为的)条件类型函数并遇到意外错误:

function test<
  T
>(
  maybeNumber: T
): T extends number ? number : string {
  if (typeof maybeNumber === 'number') {
    return maybeNumber // Type 'T & number' is not assignable to type 'T extends number ? number : string'.
  }

  return 'Not a number' // Type '"Not a number"' is not assignable to type 'T extends number ? number : string'.
}
Run Code Online (Sandbox Code Playgroud)

我认为这是条件类型的非常简单的用法,所以不确定发生了什么。有任何想法吗?

澄清一下,我并不是真的想实现这个特定的功能。我只是在试验条件类型,并想更好地理解为什么这实际上不起作用。

typescript

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