本文整理汇总了C#中TypeDefinition.ImplementsINotify方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition.ImplementsINotify方法的具体用法?C# TypeDefinition.ImplementsINotify怎么用?C# TypeDefinition.ImplementsINotify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeDefinition
的用法示例。
在下文中一共展示了TypeDefinition.ImplementsINotify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessType
public void ProcessType(TypeDefinition type)
{
var containsValidationAttribute = type.CustomAttributes.ContainsValidationAttribute();
if (!type.ImplementsINotify())
{
if (containsValidationAttribute)
{
throw new WeavingException($"Found [InjectValidationAttribute] on '{type.Name}' but it doesnt implement INotifyPropertyChanged so cannot inject.");
}
return;
}
if (!containsValidationAttribute)
{
return;
}
if (type.HasGenericParameters)
{
throw new WeavingException($"Failed to process '{type.FullName}'. Generic models are not supported. Feel free to send a pull request.");
}
var templateFieldInjector = new TemplateFieldInjector
{
ValidationTemplateFinder = templateFinder,
TargetType = type,
ModuleDefinition = ModuleDefinition
};
templateFieldInjector.AddField();
if (dataErrorInfoFinder.Found)
{
var injector = new DataErrorInfoInjector
{
TypeDefinition = type,
TypeSystem = ModuleDefinition.TypeSystem,
DataErrorInfoFinder = dataErrorInfoFinder,
ModuleWeaver = this,
ValidationTemplateField = templateFieldInjector.ValidationTemplateField
};
injector.Execute();
}
if (notifyDataErrorInfoFinder.Found)
{
var injector = new NotifyDataErrorInfoInjector
{
TypeDefinition = type,
NotifyDataErrorInfoFinder = notifyDataErrorInfoFinder,
TypeSystem= ModuleDefinition.TypeSystem,
ModuleWeaver = this,
ValidationTemplateField = templateFieldInjector.ValidationTemplateField
};
injector.Execute();
}
}