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地址的代码.但它没有这样做.请告知失败的地方.
我正在尝试为我的 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) 我创建了一个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) interface<T> where T : class
Run Code Online (Sandbox Code Playgroud)
例如
public interface iSend<T> where T : class
Run Code Online (Sandbox Code Playgroud)
上面的代码是什么意思?
为什么要用这个?
什么时候用?
以下是我的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不是一个函数
我不知道这里有什么不对.请帮助.
有没有办法将存储过程的结果映射到通用列表而不是数据集/数据表?
目前我按照以下步骤操作:
有没有办法消除步骤(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) 我是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) public class abc
{
public abc():this(new pqr())
{}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码表示构造函数abc()由某个类继承.
上面的代码是什么意思?
什么时候使用这样的代码?
为什么用它?
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中没有属性.
我已经动态创建了线程.
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"的消息
我怎样才能做到这一点.
为什么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)