是否可以将操作筛选器中的参数传递给控制器,尤其是通过参数传递(在ASP.NET Core中)?
例如:
public class CategoryController : Controller
{
[HttpGet]
[ServiceFilter(typeof(ApiFilter))]
public async Task<IActionResult> Index(string dataComingFromActionFilter)
{
//use dataComingFromActionFilter
}
}
Run Code Online (Sandbox Code Playgroud)
和
public class ApiFilter: IActionFilter
{
public void OnActionExecuting(ActionExecutingContext context)
{
//maybe something similar to
context.sendToActionAsArgument['dataComingFromActionFilter'] = "data";
}
}
Run Code Online (Sandbox Code Playgroud) 我还是c#的新手,我不知道如何每隔10秒调用一次updateTime()方法
public class MainActivity : Activity
{
TextView timerViewer;
private CountDownTimer countDownTimer;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
timerViewer = FindViewById<TextView> (Resource.Id.textView1);
// i need to invoke this every ten seconds
updateTimeinViewer();
}
protected void updateTimeinViewer(){
// changes the textViewer
}
}
Run Code Online (Sandbox Code Playgroud)
如果有办法创建一个新的线程或类似的东西,我会很乐意得到一些帮助.
我正在使用Xamarin Studio