小编Abd*_*rim的帖子

将参数从操作过滤器传递给控制器

是否可以将操作筛选器中的参数传递给控制器​​,尤其是通过参数传递(在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)

action-filter .net-core asp.net-core

4
推荐指数
2
解决办法
795
查看次数

在C#中制作一个简单的计时器

我还是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

c# android xamarin

0
推荐指数
1
解决办法
5801
查看次数

标签 统计

.net-core ×1

action-filter ×1

android ×1

asp.net-core ×1

c# ×1

xamarin ×1