小编Pav*_*vel的帖子

在F#Web Api项目中使用可选的查询参数

我正在使用F#ASP.NET模板将C#webapi项目转换为F#.除了可选的查询参数,一切都很好.我一直收到这个错误

{
    "message": "The request is invalid.",
    "messageDetail": "The parameters dictionary contains an invalid entry for parameter 'start' for method 'System.Threading.Tasks.Task`1[System.Net.Http.HttpResponseMessage] GetVendorFiles(Int32, System.Nullable`1[System.DateTime])' in 'Thor.WebApi.VendorFilesController'. The dictionary contains a value of type 'System.Reflection.Missing', but the parameter requires a value of type 'System.Nullable`1[System.DateTime]'."
}
Run Code Online (Sandbox Code Playgroud)

F#功能签名:

[<HttpGet; Route("")>]
member x.GetVendorFiles( [<Optional; DefaultParameterValue(100)>] count, [<Optional; DefaultParameterValue(null)>] start : Nullable<DateTime> ) =
Run Code Online (Sandbox Code Playgroud)

C#函数签名:

[HttpGet]
[Route("")]
public async Task<HttpResponseMessage> GetVendorFiles(int count = 100,DateTime? start = null)
Run Code Online (Sandbox Code Playgroud)

有谁知道任何变通方法?

更新: 我找出了这个问题的原因.ASP.NET 使用ParameterInfo提取控制器操作的默认值.显然,F#编译器不会像C#一样编译默认值(即使使用DefaultParameterValueAttribute)

什么是最好的方法或解决这个问题?我需要注入或实现自己的过滤器ParameterBinding …

.net f# c#-to-f# asp.net-web-api

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

MVVM模式的动画

使用MVVM模式时触发动画的最佳方法是什么?更具体地说,我的表格有几个字段.当用户点击保存时Button,我想显示一个动画.我已经能够通过暴露属性ShowMessage并将其设置为True 来实现这一点,并DataTrigger获取此值并启动动画.但是,当动画仍处于活动状态时,我想将表单重置为干净状态.到目前为止,我通过订阅Complete事件Storyboard并重置视图模型在该事件上的状态来完成重置.

理想情况下,我希望能够以某种方式从视图模型触发动画(因为保存将是一个异步操作)并让动画运行完成.我现在拥有它的方式不起作用,因为一旦我更改了ShowMessage属性的值(在重置时),动画就会停止并且不会运行完成.

有没有人有更好的解决方案?

谢谢!

wpf animation datatrigger mvvm storyboard

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

标签 统计

.net ×1

animation ×1

asp.net-web-api ×1

c#-to-f# ×1

datatrigger ×1

f# ×1

mvvm ×1

storyboard ×1

wpf ×1