Autofac resolve based on class attribute / metadata -


I want to register and solve dynamically loaded types based on their class attribute. My code is as follows:

Custom class attribute:

  [MetadataAttrient] Public class FooIdentifier: attribute {public string identifier {get; Private set; } Public FooIdentifier (string identifier) ​​{this.Identifier = identifier; }}   

My intangible base class

  Public abstract class base {public abstract bool Execute (absolute object); Public Child Run (object param = null) {// ... returns true; } {Execution}   

My implementation type

I do not have a hard reference so I will manually load the assembly. My goal is to solve solid implementation on the basis of the identifier of the class feature. I have tried a lot with metadata, metadatafam, etc etc. My current effort is:

  var builder = new containerbuilder (); Var assemblies = assembly.load (@ "[patho attachment] .dell"); Builder.RegisterModule & LT; AttributedMetadataModule & gt; (); Manufacturer (Register) Assembly type (assembly). Where (t = & gt; T. S. B.Class of Off (Base)) // Like & lt; Base & gt; () Or .amplementation interface (.) From metadata & lt; Taskindentifier & gt; (); Var Container = Builder Build (); Var child = test.ResolveKeyed & lt; Base & gt; ("230"); // Here I have to be a child <1   

Can anyone help me with it?

  builder.RegisterAssemblyTypes (assembly). Where (t = & gt; T. asbalks off (typef (base)) & amp; amp; t. Gate customstate & lt; FooIdentifier & gt; ()! =) Pest & lt; Base & gt; (T = & gt; T. Gate customstate & lt; FooIdentifier & gt; (.) Identifier);    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -