c# - Unity.RegistrationByConvention.WithXXX members are accessed like properties when they are actually methods -


In most examples, and, I see methods with classes WithMappings , Unlimited with version 3.5.0, as if they were properties, but When I see them in the reflector, I see that they are the methods and they expect a array of (mostly) System.Type or System.Type .

What's the deal? Are these examples wrong or am I missing something?

If you look at the definition of the container. Registration Type Method, you will see that GetFromTypes, getName, getLifetimeManager, and getInjectionMembers are expecting all types of Func, which means they expect a method, for example getName is defined as:

  function & lt; Type, string & gt; GetName = null  

This allows you to pass in a method that accepts a type parameter and returns a string, such as standard string withName.TypeName (type Type) method However, it gives you the flexibility to define your own method with the same signature if you want to provide custom registration naming logic in the unity, or example.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -