小编tho*_*rn̈的帖子

为什么IDictionary(非泛型)不从IEnumerable <DictionaryEntry>继承?

IDictionary<TKey, TValue>继承自IEnumerable<KeyValuePair<TKey, TValue>>,但IDictionary由于某种原因不继承IEnumerable<DictionaryEntry>.我想知道为什么?.OfType<DictionaryEntry>()每当我需要对一个查询进行查询时,我讨厌写这个丑陋的IDictionary.

.net generics ienumerable idictionary base-class-library

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

HTML/DOM:什么是与document.body.scrollHeight等效的标准?

近十年来我一直在使用:

document.body.scrollHeight 
Run Code Online (Sandbox Code Playgroud)

返回浏览器窗口的" 理想 "高度.当我通过使用quirks-mode doctype 强制 Internet Explorer进入怪癖模式时,这很好用:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Run Code Online (Sandbox Code Playgroud)

现在我想选择标准模式,除了意义scrollHeight已经改变:

  • 怪癖模式:document.body.scrollHeight=文档的高度
  • 标准模式:document.body.scrollHeight= <body>元素的高度

什么是标准模式相当于document.body.scrollHeight

也可以看看

html html5 internet-explorer dom quirks-mode

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

正则表达式(.NET方言):捕获组的奇怪行为

我被卡住了.为什么path此代码中的组的值为2/3/4,而不是1/2/3/4?哪里1 /去?表达式的哪一部分匹配1 /

var re = new Regex(@"^-/?(?'folder'((?'path'.+?)/)??[^/]*)/?$");
var m = re.Match("-1/2/3/4/5");
m.Groups["folder"].Value.Dump("Folder");
m.Groups["path"].Value.Dump("Path");
Run Code Online (Sandbox Code Playgroud)

.net regex

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

如何在ASP.NET WebForms中显示用户控件的列表

这不是一个真正的问题所以我希望不要被解雇!因此,我必须像时间轴一样制作推特,包含信息的块的叠加.

我真的不知道如何制作这个..问题是每次的块数都不一样,有时它只会是1块,有时是2块或者有时候更多..

那么我可以让一些HtmlWriter直接编写html吗?我在asp.net中很新,所以也许可以更容易地做到这一点!使用WebUserControl可能,一个块=一个wuc所以我可以添加我需要的wuc的数量..我很丢失所以也许有人已经做过这种事情并且可以让我以正确的方式...

谢谢你的阅读!

c# asp.net webforms

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

将.net DateTime对象转换为Javascript Date对象

我有以下问题:

我从SQL Server检索DateTime对象,并通过JSON(使用$ .ajax)将其传递给Javascript.我在尝试将检索到的对象转换为javascript中的Date对象时遇到了困难.检索到的对象是值"/ Date(615592800000)/"的字符串.我认为价值是一个纪元时间.

我的问题是,是否有另一种检索日期对象的方法,而不是使用正则表达式来选择纪元值,然后创建一个新的Date对象?

我对JS很新,所以任何帮助都会受到赞赏.

javascript c# jquery json

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

如何使用PHP检查URL是外部URL还是内部URL?

我正在通过这个循环获取页面的所有ahref:

foreach($html->find('a[href!="#"]') as $ahref) {
    $ahrefs++;
}
Run Code Online (Sandbox Code Playgroud)

我想做这样的事情:

foreach($html->find('a[href!="#"]') as $ahref) {
    if(isexternal($ahref)) {
        $external++;
    }
    $ahrefs++;
}
Run Code Online (Sandbox Code Playgroud)

外在的地方是一个功能

function isexternal($url) {
    // FOO...

    // Test if link is internal/external
    if(/*condition is true*/) {
        return true;
    }
    else {
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

救命!

html php backend

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

Grunt构建不暴露我需要的全局变量

当我使用我的grunt:server任务在本地运行我的项目时,该项目按预期工作.但是,在构建了所有供应商代码并将其放入一个文件之后,我需要的两个模块不可用,并且项目不起作用.

这是我的requirejs配置:

requirejs.config
  baseUrl: './js'
  shim:
    'underscore':
      exports: '_'
    'backbone':
      deps: ['underscore', 'jquery']
      exports: 'Backbone'
    'stack':
      deps: ['d3.global']
      exports: 'stack'
    'highlight':
      exports: 'hljs'

  paths:
    'underscore': '../components/underscore/underscore'
    'backbone': '../components/backbone/backbone'
    'jquery': '../components/jquery/jquery'
    'd3': '../components/d3/d3'
    'd3.global': '../components/d3.global/d3.global'
    'stack': '../components/stack/stack'
    'highlight': '../components/highlightjs/highlight.pack'

require ['app/vendors'],->
  console.log("Backbone", Backbone)
  console.log("_", _)
  console.log("$", $)
  console.log("d3", d3)
  console.log("stack", stack)
  console.log("hljs", hljs)
Run Code Online (Sandbox Code Playgroud)

app/vendor看起来像

define [
  'underscore'
  'jquery'
  'backbone'
  'text'
  'd3.global'
  'stack'
  'highlight'
], ->
Run Code Online (Sandbox Code Playgroud)

当我通过grunt在本地运行项目时,我看到打印出的所有全局变量.但是,当我构建项目时,Backbone Underscore和JQuery打印出来,而堆栈失败(hljs也不可用,如果我从app/vendor中删除堆栈,它不会修复突出显示,所以它可能不是订单的事情) .

使用以下配置调用requirejs优化器:

requirejs:
  compile:
    options:
      baseUrl: 'js/'
      appDir: './<%= yeoman.tmp_dist %>/'
      dir: './<%= yeoman.dist …
Run Code Online (Sandbox Code Playgroud)

javascript amd requirejs gruntjs r.js

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

我必须在可读事件处理程序中重复调用 readable.read() 吗?

假设我创建了一个名为的转换流Parser,它可以像普通流一样写入,但作为对象流读取。我正在将readable事件用于使用此转换流的代码:

var parser = new Parser();
parser.on('readable', function () {
    var data = parser.read();
    console.log(data);
});
Run Code Online (Sandbox Code Playgroud)

在这个事件处理程序中,我必须重复调用parser.read()吗?或者,是否会readable针对从我的转换流中推送的每个对象自行触发?

node.js node.js-stream

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

主路由器插座内的辅助路由器插座

我正在尝试在主路由器插座内使用辅助路由器插座.

app.routing

export const appRoutes: Routes = [
    { path: '', component: HomeComponent },
    {
        path: 'page',
        loadChildren: () => new Promise(function (resolve) {
            (require as any).ensure([], function (require: any) {
                resolve(require('../pages/page.module').default);
            });
        })
    }
];
Run Code Online (Sandbox Code Playgroud)

app.component

@Component({
    template: `<h1>My App!</h1>
        <a [routerLink]="['/page']">Page</a>
        <router-outlet></router-outlet>`
})
Run Code Online (Sandbox Code Playgroud)

page.module

@NgModule({
    imports: [
        CommonModule,
        RouterModule.forChild([
            {
                path: '',
                component: PageComponent
            },
            {
                path: 'auxpath',
                component: AuxComponent,
                outlet: 'auxoutlet'
            }
        ])
    ],
  declarations: [PageComponent],
  exports: [PageComponent]
})
export default class PageModule {}
Run Code Online (Sandbox Code Playgroud)

page.component

@Component({
    template: …
Run Code Online (Sandbox Code Playgroud)

angular-routing angular angular-auxiliary-routes

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

TypeScript:如何将现有的命名空间设为全局?

我正在尝试停止使用 TSD 在通过全局变量使用许多库的项目中获取类型定义(如果这很重要,outFile则使用该选项tsconfig.json)。特别是,它以这种方式使用 Moment 库。Moment 提供了自己的类型定义作为 NPM 包的一部分。但是,这些定义并未在全局范围内声明任何内容。请注意,moment这既是类型的全局变量,moment.MomentStatic又是类型命名空间。使用 NPM 包,我怎样才能扩大全局范围,使一切都开始工作,因为它现在可以使用从 TSD 获得的旧类型定义?即,moment应该在任何文件中作为变量和类型命名空间在全局范围内可用。基本上,我想要的是这样的东西:

import * as _moment from 'moment';
declare global {
    const moment: _moment.MomentStatic;
    import moment = _moment;
}
Run Code Online (Sandbox Code Playgroud)

这不编译:

[ts] Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.
[ts] Import declaration conflicts with local declaration of 'moment'
Run Code Online (Sandbox Code Playgroud)

有解决方法吗?

momentjs typescript definitelytyped tsd typescript-typings

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