我正在寻找有关如何使用 ninjects 作为 DI 框架来实现 fluentvalidation 框架的帮助。
有一个 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