我正在尋找一些幫助,如何實現與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