Coder Social home page Coder Social logo

ninject.web.mvc.fluentvalidation's Introduction

Ninject

Build status codecov NuGet Version NuGet Downloads

Ninject is a lightning-fast, ultra-lightweight dependency injector for .NET applications. It helps you split your application into a collection of loosely-coupled, highly-cohesive pieces, and then glue them back together in a flexible manner. By using Ninject to support your software's architecture, your code will become easier to write, reuse, test, and modify.

Write your code so it's flexible...

public class Samurai {
    public IWeapon Weapon { get; private set; }
    public Samurai(IWeapon weapon) 
    {
        this.Weapon = weapon;
    }
}

...and let Ninject glue it together for you.

public class WarriorModule : NinjectModule
{
    public override void Load() 
    {
        this.Bind<IWeapon>().To<Sword>();
    }
}

Features:

  1. Focused. Too many existing dependency injection projects sacrifice usability for features that aren't often necessary. Each time a feature is added to Ninject, its benefit is weighed against the complexity it adds to everyday use. Our goal is to keep the barrier to entry - the baseline level of knowledge required to use Ninject - as low as possible. Ninject has many advanced features, but understanding them is not required to use the basic features.

  2. Sleek. Framework bloat is a major concern for some projects, and as such, all of Ninject's core functionality is in a single assembly with no dependencies outside the .NET base class library. This single assembly's footprint is approximately 85KB when compiled for release.

  3. Fast. Instead of relying on reflection for invocation, Ninject takes advantage of lightweight code generation in the CLR. This can result in a dramatic (8-50x) improvement in performance in many situations.

  4. Precise. Ninject helps developers get things right the first time around. Rather than relying on XML mapping files and string identifiers to wire up components, Ninject provides a robust domain-specific language. This means that Ninject takes advantage of the capabilities of the language (like type-safety) and the IDE (like IntelliSense and code completion).

  5. Agile. Ninject is designed around a component-based architecture, with customization and evolution in mind. Many facets of the system can be augmented or modified to fit the requirements of each project.

  6. Stealthy. Ninject will not invade your code. You can easily isolate the dependency on Ninject to a single assembly in your project.

  7. Powerful. Ninject includes many advanced features. For example, Ninject is the first dependency injector to support contextual binding, in which a different concrete implementation of a service may be injected depending on the context in which it is requested.

Everything else is in Extensions

Yes, sounds slim and focused, but where is the support for all the features that the competitors have?

Generally, they are maintained as specific focused extensions with owners who keep them in sync and pull in new ideas and fixes fast. These are summarized on the extensions section of the project website. Most are hosted alongside the core project right here.

License

Ninject is intended to be used in both open-source and commercial environments. To allow its use in as many situations as possible, Ninject is dual-licensed. You may choose to use Ninject under either the Apache License, Version 2.0, or the Microsoft Public License (Ms-PL). These licenses are essentially identical, but you are encouraged to evaluate both to determine which best fits your intended use.

Refer to LICENSE.txt for detailed information.

Changes history

Resources

ninject.web.mvc.fluentvalidation's People

Contributors

iappert avatar remogloor avatar schambers avatar scott-xu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ninject.web.mvc.fluentvalidation's Issues

What does this do?

What does this code do? I'm trying to figure out how to use DI in my Fluent Validation AbstractValidator constructors. Does this do that?

setting up ninject.web.mvc.fluentvalidation is not straight forward

Hi ,
First of all, i am very grateful for all the work put in the Ninject project and its extensions.

to the issues: using MVC4 on VC2012 Pro, wanting Ninject + FluentValidation

  1. installed the ninject MVC3 and fluent validation mvc4 + the ninject fluent validation extension, all using nuget. since using only stable versions, i ran into the signing issue
    as seen here , i would like very much for the package from nuget to work without the workaround.
  2. i used a single simple model object with nothing on it but auto props.
    added a simple validator class using AbstactValidator, with a single simple RuleFor rule.
    running with F5 , didnt activate the validator. (i saw the instructions but they are not clear as to where to put the first snippet marked "1" , and the NinjectModule (also marked "1") is never loaded, by anyone.)
    google around for quite a bit got me here, and now the validator gets loaded.
    i think the nuget should also put the code linked above, in the proper places, especially the NinjectModule and add it to the the kernel`s initialization. the problem is that installing the extension leaves you half way through, and its not so easy to complete the task.
  3. now that the validator is loaded, i get the dreaded "Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: required", as answered by Remo Gloor here.
    it still does not work for me (Remo`s answer does not work for me, the AttributeValidatorProvider class is not in any referenced assembly). Again i think it should work right after installing the Nuget and hitting F5.

there`r a lot of question at StackOverflow on all 3 points, so im not the only one having a hard time.

i would very much appreciate your response.

Error after install via nuget package

Installed packages

FluentValidation 3.4.6.0 A validation library for .NET that uses a fluent interface to construct strongly-typed validation rules. FluentValidation.MVC4 3.4.6.0 ASP.NET MVC 4 integration for FluentValidation Ninject.Web.Mvc.FluentValid... 3.0.0.4 Fluent validation extension for Ninject.Web.Mvc

Error

The type 'FluentValidation.ValidatorFactoryBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'FluentValidation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a82054b837897c66'.

In registre services

        private static void RegisterServices(IKernel kernel)
        {
            AutoMapperConfigurator.Configure(t => kernel.Get(t));

            kernel.Bind<IRepository>().To<CreditoImobiliarioContext>().InRequestScope().WithConstructorArgument("getCurrentUser", ninjet => new Func<int>(() => WebSecurity.CurrentUserId));
            kernel.Bind<IMappingEngine>().ToMethod(ctx => Mapper.Engine);
            kernel.Bind<ModelMetadataProvider>().To<BindSolutionModelMetadataProvider>().InSingletonScope();

            GlobalConfiguration.Configuration.DependencyResolver = new NinjectResolver(kernel);


            NinjectValidatorFactory ninjectValidatorFactory = new NinjectValidatorFactory(kernel);
            FluentValidationModelValidatorProvider.Configure(x => x.ValidatorFactory = ninjectValidatorFactory);
            //ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(ninjectValidatorFactory));
            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;


            AssemblyScanner.FindValidatorsInAssembly(Assembly.GetExecutingAssembly())
                .ForEach(match => kernel.Bind(match.InterfaceType).To(match.ValidatorType));

        }   

problems when upgrate from ver 3.0.0 to 3.2

HI,
thanks you for the wonderful project.

i try upgrade from version 3.0 to 3.2 that depends on "FluentValidation-Signed" with version between 3.4 and 4.0,
in our project we are using "FluentValidation-Signed version 5.0",
is it possible to release new version that support this ?

Regards,
Noam.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.