小编MAR*_*att的帖子

使用regex从字符串中提取ip地址

 var r = "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"; //http://www.regular-expressions.info/examples.html

var a = "http://www.example.com/landing.aspx?referrer=10.11.12.13";

var t = a.match(r); //Expecting the ip address as a result but gets null
Run Code Online (Sandbox Code Playgroud)

以上是我从字符串中提取ip地址的代码.但它没有这样做.请告知失败的地方.

javascript regex jquery

3
推荐指数
1
解决办法
5535
查看次数

如何在实体框架 Include() 中使用 Moq

我正在尝试为我的 DAL 层编写单元测试。

复杂的是 DAL 层有一个使用 Include() 的查询。

我不知道如何模拟 Include() 方法。

楷模

    public class Apps
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DataMember]
        public int ID { get; set; }

        [DataMember]
        [Required(ErrorMessage = "App name required.")]
        public string Name { get; set; }

        public virtual ICollection<AppDataPermission> AppDataPermissions { get; set; }

    }

public class AppDataPermission{
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DataMember]
        public int ID { get; set; }

        public DataPermissions DataPermission { get; set; }

        public virtual Apps App { get; set; }
    }

public enum DataPermissions …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework moq

3
推荐指数
1
解决办法
706
查看次数

在Azure Web App上部署vueJs应用程序

我创建了一个vueJs应用程序.

我想将它部署在Azure Web应用程序上.

    "scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "prod": "webpack --progress --config build/webpack.prod.conf.js",
    "start": "npm run prod",
    "lint": "eslint --ext .js,.vue src",
    "build": "node build/build.js"
  },
  "dependencies": {
    "moment": "^2.20.1",
    "vue": "^2.5.2",
    "vue-router": "^3.0.1",
    "webpack": "^3.6.0"
  }
Run Code Online (Sandbox Code Playgroud)

这就是package.json的样子

部署时,我从Azure获得以下错误.

webpack:找不到

错误日志

INFO  - Container logs
Generating app startup command
Found scripts.start in package.json
Running npm start
> myapp@1.0.0 start /home/site/wwwroot
> npm run prod
> myapp@1.0.0 prod /home/site/wwwroot
> webpack --progress --config build/webpack.prod.conf.js
sh: 1: webpack: not …
Run Code Online (Sandbox Code Playgroud)

azure azure-web-sites webpack vue.js

3
推荐指数
1
解决办法
3513
查看次数

interface <T>其中T:class

interface<T> where T : class
Run Code Online (Sandbox Code Playgroud)

例如

public interface iSend<T> where T : class
Run Code Online (Sandbox Code Playgroud)

上面的代码是什么意思?

为什么要用这个?

什么时候用?

c# generics

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

module.exports:不是函数

以下是我的sqlhelper.js

var req = require("request");
var tp = require('tedious-promises');
var dbConfig = require('../config/connectionString.json');
var TYPES = require('tedious').TYPES;

function SQLHelper() {
}

SQLHelper.prototype.ExecuteDataset = function(query, params, callback, failure) {

    tp.setConnectionConfig(dbConfig);
    tp.sql(q);
    $(params).each(function(idx) {
        var p = params[idx];
        tp.parameter(p.name, p.value);
    });

    tp.execute()
        .then(function(results) {
            callback(results)
        }).fail(function(err) {
            failure(err);
        });
};

module.exports = SQLHelper;
Run Code Online (Sandbox Code Playgroud)

我这样用它

var sqlHelper = require('../SQLHelper.js');
sqlHelper.ExecuteDataset(q, params, function(results) {//Here I get error
                console.log(results)
            },
            function(err) {
                console.log(err);
            });
Run Code Online (Sandbox Code Playgroud)

我得到以下错误TypeError:sqlHelper.ExecuteDataset不是一个函数

我不知道这里有什么不对.请帮助.

javascript node.js

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

将存储过程结果填充到List <T>

有没有办法将存储过程的结果映射到通用列表而不是数据集/数据表?

目前我按照以下步骤操作:

  1. 执行存储过程
  2. 在数据集中获取结果
  3. 填充数据集中的列表.

有没有办法消除步骤(2).

OleDbCommand cm = new OleDbCommand();
cm.Connection = AccessConnection();
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "seltblContacts";

OleDbDataAdapter adp = new OleDbDataAdapter(cm);

DataTable dt = new DataTable();
adp.Fill(dt);

List<tblContacts> LstFile = new List<tblContacts>();

if (dt.Rows.Count > 0)
{
    tblContacts t;

    foreach (DataRow dr in dt.Rows)
    {
        t = PopulateContacts(dr);
        LstFile.Add(t);
    }
}
Run Code Online (Sandbox Code Playgroud)

c#

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

类型Promise <void>不能分配给Promise <customType []>类型

我是angularJs2的新手.我创建了以下服务:

import { Injectable, OnInit } from '@angular/core';
import { customType } from '../models/currentJobs';
import { Headers, Http } from '@angular/http';

import 'rxjs/add/operator/toPromise';

@Injectable()
export class JobService implements OnInit {

    constructor(private http: Http) { }

    ngOnInit(): void {
        this.getCurrentJobs();
    }

    private headers: Headers = new Headers({ 'Content-Type': 'application/json' });
    private ordersUrl: string = 'http://localhost:35032/api/order/';

    public orders: customType[];

    getCurrentJobs(): Promise<customType[]> {
        var jobs =  this.http.get(this.ordersUrl)
            .toPromise()
            .then(response => {
                this.orders = response.json() as customType[];
            })
            .catch(this.handleError);
        return jobs;//this line throws error …
Run Code Online (Sandbox Code Playgroud)

javascript typescript visual-studio-2017 angular

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

将类继承到构造函数

public class abc
{
    public abc():this(new pqr())
    {}
}
Run Code Online (Sandbox Code Playgroud)

上面的代码表示构造函数abc()由某个类继承.

上面的代码是什么意思?

什么时候使用这样的代码?

为什么用它?

c# oop

0
推荐指数
1
解决办法
108
查看次数

获取类的变量列表

Class foo
{
   public string name;
   public int age;
   public datetime BirthDate;
}
Run Code Online (Sandbox Code Playgroud)

我有上面的课.

我想要foo类的变量列表.

我试过了

foo fooObj= new foo();
fooObj.GetType().GetProperties()
Run Code Online (Sandbox Code Playgroud)

这给了我0个属性.

显然这不会起作用,因为类foo中没有属性.

c#

0
推荐指数
1
解决办法
164
查看次数

获取多线程中的线程状态

我已经动态创建了线程.

static void Main(string[] args)
{

    int ThreadCount =Convert.ToInt32ConfigurationManager.AppSettings["Threads"]);
    List<Thread> th = new List<Thread>();
    for (int i = 0; i < ThreadCount; i++)
    {
      Thread t = new Thread(print);
      th.Add(t);
    }
    foreach (Thread t in th)
    {
       t.Start();
    }
 }
 public static void print()
 {
    console.writeline("123");
 }
Run Code Online (Sandbox Code Playgroud)

我想知道这个线程何时完成.完成这些线程后,我想打印一条"DONE"的消息

我怎样才能做到这一点.

c# multithreading

-2
推荐指数
1
解决办法
72
查看次数

LINQ和sql中的SELECT关键字

为什么SELECT关键字在LINQ查询中结束

from m in myClass1 
where m.myfield == value 
select m
Run Code Online (Sandbox Code Playgroud)

而它在SQL查询的开头呢?

select * from myTable
Run Code Online (Sandbox Code Playgroud)

linq

-2
推荐指数
1
解决办法
255
查看次数