我正在寻找一些帮助,如何实现与ninjects作为DI框架fluentvalidation框架。流利的验证Ninject
有一个ninject扩展名,但我找不到关于如何使用它的文档。 哪里可以找到文档/教程来设置这些非常漂亮的框架?
Vb.net解决方案
Public Class Dinner
Public Property DinnerID As Guid
Public Property Title As String
Public Property EventDate As DateTime
Public Property Address As String
Public Property HostedBy As String
Public Overridable Property RSVPs As ICollection(Of RSVP)
End Class
Imports FluentValidation
Public Class dinnervalidator
Inherits AbstractValidator(Of Dinner)
Public Sub New()
RuleFor(Function(x) x.EventDate).NotEmpty().WithMessage("Gelieve een geldige eventdatum op te geven")
RuleFor(Function(x) x.Address).NotEmpty().WithMessage("Gelieve een adres in te vullen").Length(5, 50).WithMessage("Gelieve een Geldig adres in te vullen aub")
End Sub
End Class
Public Class fluentvalidationmodule
Inherits NinjectModule
Public Overrides Sub Load()
AssemblyScanner.FindValidatorsInAssemblyContaining(Of dinnervalidator) _
.ForEach(Function(x) Bind(x.InterfaceType).To(x.ValidatorType))
End Sub
End Class