我有一些代码,它将演示Liskov替换,但我很困惑base关键字在2个参数上做了什么.谁能解释一下?
class Rectangle
{
public Rectangle(int width, int height)
{
Width = width;
Height = height;
}
public virtual int Height {get;set;}
public virtual int Width {get;set;}
public int Area
{
get { return Height*Width }
}
Run Code Online (Sandbox Code Playgroud)
现在,对于使用2个参数继承基类的square类.我也很好奇为什么下一个方法广场(int)可以在基类中使用不同名称的方法
private class Square : Rectangle
{
public Square(int size) : base(size, size) {} ///here is my confusion
public override int Width
{
get {return base.Width}
set { base.Width = value; base.Height = value}
}
public override int Height
{ /// same thing …Run Code Online (Sandbox Code Playgroud) 我正在使用 rust 和 webassembly。我收到此错误消息operation not supported on wasm yet。所以两件事中的任何一件正在发生,我很好奇是否有人知道答案。所以要么我的文件路径不正确,这是最没有帮助的错误消息,要么 wasm 不支持加载文件。
#[wasm_bindgen]
#[macro_use]
pub fn file() -> () {
let mut data: Vec<u8> = Vec::new();
///I would load the png with the same path in my javascript.
let opened = File::open("./png/A_SingleCell.png");
let unwraped = match opened {
Ok(a) => log(&format!("opened {}", "worked")),
Err(e) => log(&format!("{}", e)),
};
// .read_to_end(&mut data)
// .unwrap();
return ();
}
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
fn log(msg: &str);
}
Run Code Online (Sandbox Code Playgroud)
并且 javascript …
我有一个已经设置好的服务器,可以在生产环境中运行,有很多应用程序调用此Web服务器。下面的代码演示了它允许任何原始请求。
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseExceptionHandler("/Home/Error");
app.UseStaticFiles();
app.UseCors(builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
Run Code Online (Sandbox Code Playgroud)
这适用于当前设置的所有服务器。它在我们的内部网络上,其他内部服务器将使用此服务。
我正在创建一个概念证明,以尝试通过使用缓慢并使我们的应用程序现代化Vue。除非此axios请求出现错误。其他调用此方法的服务器也使用.net,但它应建立相同的请求。
这是错误。
无法加载https:// {server} / api / application / 36626:所请求的资源上没有“ Access-Control-Allow-Origin”标头。因此,不允许访问源' http:// localhost:8080 '。
这显然是axios的疯狂话题。我允许任何来源。我无法想象我们只想使用“简单请求”,因此简单请求的w3标准可能无法正常工作。考虑到这是octet-stream服务器返回的消息,我认为这可能是不正确的错误。代码如下。
<script>
import axios from 'axios'
export default {
name: 'AppList',
data () {
return {
applist: [],
errors: []
}
},
created: function() {
axios.get('https://{server}/api/application/36626')
.then(r => { console.log(response); })
.catch(ex => {
this.errors.push(ex);
})
}
} …Run Code Online (Sandbox Code Playgroud) 我已经为我的对象定义了序列化idAssignmentResult.但是,如何将IS XML的HttpResponseMessage转换为它的类?我收到一个错误:
"System.Net.Http.HttpContent"类型的值无法转换为"System.Xml.XmlReader"
我会做vb.net和c#
vb.net
Dim response As New HttpResponseMessage()
Try
Using client As New HttpClient()
Dim request As New HttpRequestMessage(HttpMethod.Post, "url")
request.Content = New StringContent(stringWriter.ToString, Encoding.UTF8, "application/xml")
response = client.SendAsync(request).Result
End Using
Catch ex As Exception
lblerror.Text = ex.Message.ToString
End Try
Dim responseString = response.Content
Dim xmls As New XmlSerializer(GetType(idAssignmentResult))
Dim assignmentResult As New idAssignmentResult()
xmls.Deserialize(responseString, assignmentResult) /// cannot convert HttpContent to XmlReader
Run Code Online (Sandbox Code Playgroud)
C#
StringWriter stringWriter = new StringWriter();
XmlSerializer serializer = new XmlSerializer(typeof(personV3R));
personV3R person = …Run Code Online (Sandbox Code Playgroud) 我在控制台中没有错误.但是控制台没有记录console.log我放入的构造函数top-nav.js.但更重要的是.简单的jumbotron div没有呈现,Aurelia在控制台中说它发现了正确的top-nav.html.这里是App.html
<template>
<require from="bootstrap/css/bootstrap.css"></require>
<require from="htmlreq/top-nav"></require>
<h1>${message}</h1>
</template>
Run Code Online (Sandbox Code Playgroud)
App.js 为了一致性
export class App {
message = "Hello Pathways";
}
Run Code Online (Sandbox Code Playgroud)
top-nav.html
<template>
<div class="jumbotron">
<div class="container">
<p>Career & Technical Education </p>
</div>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
top-nav.js控制台语句未触发.并且在大教堂的任何地方都没有看到或列出超大按钮.
export class TopNav {
_topnav = true;
constructor() {
console.log('constructed');
}
}
Run Code Online (Sandbox Code Playgroud) 我有这个Where条款
Select * From Student_Info si
Inner Join Certifications cc
Inner Join Cert_Earned ce
Where si.grad_date = @grad_date
AND cc.org_no = @org_no
Run Code Online (Sandbox Code Playgroud)
但是我需要一个额外的AND,如果结果是值为false,我应该忽略所有证书
AND cc.industrial = CASE WHEN @industrial = 0 THEN Do Nothing
Else @industrial
Run Code Online (Sandbox Code Playgroud) 我有一个针对.net核心的WebApplication。我还创建了一个针对.net核心的类库。
我正在按照此Dapper教程在此处创建用户存储库
能够提供在WebApplication启动时注入到将成为数据访问层的项目中的选项将是很好的。
这是一个单独项目中用户存储库的代码。
class UsersRepository
{
private readonly MyOptions _options;
private string connectionString;
public UsersRepository(IOptions iopt/// insert Option here )
{
_options = iopt.Value;
connectionString = _options.connString;
}
public IDbConnection Connection
{
get
{
return new SqlConnection(connectionString);
}
}
Run Code Online (Sandbox Code Playgroud)
WebApplication项目启动看起来如下。
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddOptions();
services.Configure<MyOptions>(Configuration);
services.AddMvc();
}
Run Code Online (Sandbox Code Playgroud)
当然MyOptions是Web应用程序中的一个类,只有一个属性connString
http://jsfiddle.net/yjxq7bae/1/
我试图在输入标签中选择复选框prop.输入标记的id和名称被重用,所以我必须使用<nobr>文本来缩放dom并获取值.
<tr>
<td nowrap="true" valign="top" width="190px" class="ms-formlabel">
<h3 class="ms-standardheader">
<nobr>Confirmation Sent</nobr>
</h3>
</td>
<td valign="top" class="ms-formbody">
<span dir="none">
<input id="ctl00_m_g_ed53ee23_de9d_4105_ba24_00e2a21cef5e_ctl00_ctl05_ctl50_ctl00_ctl00_ctl04_ctl00_ctl00_BooleanField" type="checkbox" name="ctl00$m$g_ed53ee23_de9d_4105_ba24_00e2a21cef5e$ctl00$ctl05$ctl50$ctl00$ctl00$ctl04$ctl00$ctl00$BooleanField" checked="checked" /><br />
</span>
</td>
</tr>
<div>Click Here</div>
Run Code Online (Sandbox Code Playgroud)
我尝试过各种可能的方式.如果你注意到.closest()失败,我会从<h3>元素中再增加一个.通过首先更改h3的css,然后尝试隐藏td,小提琴演示了这个负载.
var mop = $('nobr').filter(function () {
return $(this).text() === 'Confirmation Sent'
}).closest("tr").find("input[type=checkbox]").prop('checked');
alert(typeof mop);
$('nobr:contains(Confirmation Sent)').closest("h3").css("background", "yellow");
$('nobr:contains(Confirmation Sent)').closest("h3").closest("td").hide();
$('div').on("click ", function (event) {
var toast = $('nobr').filter(function () {
return $(this).text() === 'Confirmation Sent'
}).closest("tr").find("input[type='checkbox']").prop('checked');
alert(typeof toast);
});
Run Code Online (Sandbox Code Playgroud) javascript ×3
asp.net-core ×2
c# ×2
html ×2
.net-core ×1
aurelia ×1
axios ×1
base-class ×1
case ×1
cors ×1
jquery ×1
overloading ×1
rust ×1
sql ×1
sql-server ×1
t-sql ×1
vb.net ×1
vue.js ×1
vuejs2 ×1
webassembly ×1
xml ×1