我有 ASP.NET Core Web 应用程序,我在其中使用 swagger 使用以下内容:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSwaggerGen(c =>
{
c.OperationFilter<ExamplesOperationFilter>();
c.OperationFilter<DescriptionOperationFilter>();
c.SwaggerDoc("v1", new Info
{
Version = "v1",
Title = "API",
Description = "",
});
// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseSwagger();
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API"); });
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
当我导航到 url/swagger 时,出现以下错误:
失败:Microsoft.AspNetCore.Server.Kestrel[13] …
我尝试显示截图中的气球提示:
首先我创建了一个notifyIcon
然后我将此代码添加到Form1_Load函数:
private void Form1_Load(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
notifyIcon1.Icon = SystemIcons.Exclamation;
notifyIcon1.BalloonTipTitle = "Balloon Tip Title";
notifyIcon1.BalloonTipText = "Balloon Tip Text.";
notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
notifyIcon1.ShowBalloonTip(10000);
}
Run Code Online (Sandbox Code Playgroud)
我得到的只是一个小图标,如果我将鼠标悬停在它上面,那么我会看到通知图标的名称.
我也试过这个,notifyIcon1.ShowBalloonTip(10000, "Text", "Title", ToolTipIcon.Warning);
但后来没有任何反应.
我在功能描述中注意到,ShowBalloonTip
从windows vista开始不推荐使用参数"timeout",那么我该怎么做呢?
PS:我在Windows 10 64bit上运行它.
更新1/3:
我刚创建了一个新项目,气球提示也没有显示.也许我的OS中的设置会阻止这些消息?
更新2/3:
我从@ pisi1001下载了这个项目,但是我得到了同样的行为.
所以我认为它必须是Windows 10中的错误,错误的设置或组策略.
但是,如下一个屏幕截图所示,该应用甚至可以显示通知:
更新3/3:
我注意到,如果双击该设置,您甚至可以更深入地配置,例如,从上一个屏幕截图中的"WindowsFormsApp1".
在我激活了最后一个屏幕截图中红色框中的设置(基本上是在"信息中心显示通知")后,我现在至少在信息中心收到通知:
这必须是Windows 10 Bug.
最后更新:自从我问这个问题几周后,现在似乎工作了,我不知道为什么.也许微软在向我们报告之后修复了它.
为什么不允许这样做?
int A = 5, B = 10, X = 5, Y = 5;
var array = new[] { new { A, B }, new { X, Y } };
Run Code Online (Sandbox Code Playgroud)
当我尝试编译时,我得到:
CS0826:找不到隐式类型数组的最佳类型
感觉有点违反直觉,因为使用常规匿名类型我可以这样做:
int X = 5, Y = 5;
var point = new { X, Y };
Run Code Online (Sandbox Code Playgroud) 我需要恢复存储在RavenDb数据库中的JSON,知道它是Id
。棘手的是,在将其反序列化为实际对象之前,我需要获取它。这样做的原因是,无论CLR类发生了什么(它可能会发生很大的变化,甚至被删除),我都需要使用与它最初存储时完全相同的形式,因为它是对先前状态的审核(这只会是此时显示的内容,我将不再使用它)。
如果我去
using (var session = Store.OpenSession())
{
return JsonConvert.SerializeObject(session.Load<object>(id));
}
Run Code Online (Sandbox Code Playgroud)
我得到反映基础类型当前状态的JSON,可能是因为它存储在中@metadata.Raven-Clr-Type
。因此,我看不到已删除的属性,也看到了首次存储时不存在的空属性。
我想使用DocumentStore.DatabaseCommands.Get()
get RavenJObject
,但是为了支持它已经在4.1中删除了Advanced.DocumentQuery
,我找不到找到使用它的方法。
我也试过AbstractIndexCreationTask
像这样使用自己的:
class Object_AsJson : AbstractIndexCreationTask<JsonObject>
{
public Configuration_AsJson()
{
Map = configuration => configuration.Select(x => AsJson(x).Select(y => y.Value));
}
}
Run Code Online (Sandbox Code Playgroud)
但session.Load
不接受TIndexCreator
,和session.Query
我不能得到Id
,因为我没有对象,从使查询的任何属性。
例:
如果我有这堂课:
public class Person
{
string FullName { get; set; }
int Age { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
然后将新文档存储new Person { FullName = "John …
我似乎不明白为什么我在这个函数中不断收到Specify type annotations. dart(always_specify_types)
警告。PageRouteBuilder
我刚刚开始使用 Flutter/Dart,我真的很喜欢它!
我尝试将其转换为变量并将其注释为 aRoute
但仍然没有成功。
这是代码。请注意,这PageRouteBuilder
给了我类型注释警告。
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (BuildContext context, _, __) {
return DashboardPage();
},
transitionsBuilder: (_, Animation<double> animation, __, Widget child) {
return FadeTransition(
opacity: animation,
child: child,
);
},
),
);
Run Code Online (Sandbox Code Playgroud) 我正在尝试进行PATCH操作,如果请求正文包含未在合同中指定的字段,则该操作将失败。例如,如果我调用此方法:
[HttpPatch("{id}")]
public async Task<ActionResult> PatchResource(
[FromRoute][Required] Guid id,
[FromBody][Required] PatchRequest request) {/* whatever */}
Run Code Online (Sandbox Code Playgroud)
这里PatchRequest
是
public class PatchRequest
{
public string Name { get; }
public string Address { get; }
public PatchRequest(string name, string address) { Name = name; Address = address; }
}
Run Code Online (Sandbox Code Playgroud)
400 (Bad Request)
如果我收到这样的请求正文,我想返回并可能附带解释
{
"name": "Adam",
"address" "NY City",
"additional": true
}
Run Code Online (Sandbox Code Playgroud)
我想回来
400(错误请求)-没想到属性“附加”
我知道,如果我将自定义序列化程序设置为on PatchRequest
,则在这种情况下可以通过引发异常来轻松获得,但是这没有任何意义,因为这里的请求是错误的,而不是服务器。MissingMemberHandling
Error
500 (Internal Server Error)
我像往常一样在服务文件中创建了一个主题
editLectures = new Subject<Lecture>();
getEditLectureListener() {
return this.editLectures.asObservable();
}
Run Code Online (Sandbox Code Playgroud)
我正在从一个组件发送数据(我收到的是正确的数据console.log
)
onUpdate(lec: any) {
this.attendanceService.emitLecture(lec);
}
Run Code Online (Sandbox Code Playgroud)
在另一个组件上,我正在听主题:
this.updateLecture = this.attendanceService.getEditLectureListener().subscribe(result => {
// my code
// on console.log(result) i am not getting anything and other listeners
// are working perfectly, the only difference is that
// its not emitting data from http response
});
Run Code Online (Sandbox Code Playgroud)
在使用中,我正在发射数据:
emitLecture(lec: Lecture) {
this.editLectures.next(lec);
this.router.navigate(['edit-lecture']);
}
Run Code Online (Sandbox Code Playgroud) c# ×5
asp.net-core ×2
angular ×1
balloon-tip ×1
dart ×1
flutter ×1
json.net ×1
ravendb ×1
rxjs ×1
swagger ×1
typechecking ×1