【问题标题】:Is there something like interceptor in Windows 8.1?Windows 8.1 中有类似拦截器的东西吗?
【发布时间】:2015-03-18 16:29:01
【问题描述】:

我在我的 ViewModel 中重复了这段代码(使用 MVVM Light):

        OperationInProgress = true;
        ServerConectionError = false;
        SomeData = null;

        try
        {

            SomeData = await _dataRepository.GetData();
        }
        catch (Exception e)
        {
            Debug.WriteLine(e.Message);
            ServerConectionError = true;
        }
        finally
        {
            OperationInProgress = false;
        }

我的所有 ViewModel 中实际上都重复了这段代码(仅更改了 GetData 方法和 SomeData 属性)

使用 AngularJS 可以很容易地重用这些代码,但是....Windows 8.1 呢?有什么想法吗?

【问题讨论】:

  • 你的问题我不清楚。尝试对这段代码使用单独的方法。

标签: c# .net mvvm windows-8.1 interceptor


【解决方案1】:

结帐postsharp

在 PostSharp 中,您可以将方面属性附加到您的程序集、命名空间、类和方法。 因此,这些方面可用于横切关注点,例如日志记录、异常、安全等。

【讨论】:

    猜你喜欢
    • 2011-03-31
    • 1970-01-01
    • 1970-01-01
    • 2020-04-10
    • 1970-01-01
    • 2021-08-04
    • 2012-05-31
    • 2012-11-27
    • 2017-11-21
    相关资源
    最近更新 更多