0
我有一个很奇怪的问题。目前,我正在用Prism将带有MvvmCross的Windows Universal App(Win 8.1 + WinPhone 8.1)移植到CrossPlattform解决方案中。首先,非常感谢MvvmCross的所有工作 - 这真是太棒了。激活器与MvvmCross和PCL
我的问题现在与System.Activator
类。我在我的通用应用程序中使用了this approach进行验证,并尝试将其移植。现在一切都编译好了,但是在运行时会抛出一个nullreference异常。我发现它是无效的Acitivator。当我尝试访问它在即时窗口,它说:
error CS0103: The name 'Activiator' does not exist in the current context
的代码在每一个模型执行和实施了基类的构造函数:
protected ModelBase()
{
foreach (var property in this.GetType().GetRuntimeProperties())
{
var type = typeof(Property<>).MakeGenericType(property.PropertyType);
var prop = (IProperty)Activator.CreateInstance(type);
this.Properties.Add(property.Name, prop);
prop.ValueChanged += (s, e) =>
{
RaisePropertyChanged(property.Name);
Validate();
};
}
}
任何想法?
Activator在错误消息中拼写错误,但我认为这是您输入问题时的错字? :-) –
MvvmCross本身使用激活码 - 例如https://github.com/MvvmCross/MvvmCross/blob/c306ba37afd9024f68b7a4f1fedcaf4cf7d01b8d/CrossCore/Cirrious.CrossCore/Platform/MvxBootstrapRunner.cs#L32和https://github.com/MvvmCross/MvvmCross/blob/c306ba37afd9024f68b7a4f1fedcaf4cf7d01b8d/Cirrious/Cirrious。 MvvmCross.Binding/Binders/MvxNamedInstanceRegistryFiller.cs#L90和... – Stuart