【发布时间】: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