question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Registration by Convention?

See original GitHub issue

I am really looking to give Grace a try on a NetCore 3.0 project.

I see you can find named instance (withKey:) lookups, which was a requirement for us.

The last thing we were looking at was RegistrationByConvention (ala Unity)?

AllClasses from a specific assembly, with matching name interfaces (MyClass -> IMyClass).

 var repositoriesAndServices =
     AllClasses
    .FromLoadedAssemblies()
    .Where(obj => obj.ToString().Contains("MyProject.Services.")
         || obj.ToString().Contains("MyProject.Repositories."));

 container.RegisterTypes(repositoriesAndServices,
     WithMappings.FromMatchingInterface,
     WithName.Default,
     WithLifetime.ContainerControlled);

I see another ticket #136 that mentions Strategies. If this is indeed how I would go about using resolution strategies, could you provide a demonstration? I didn’t find this in the Wiki/Api Docs.

Or if there is a completely different approach provided by Grace really just need the end result to be the same so we generally don’t want to manually wire up the code getting us hamstrung.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ipjohnsoncommented, Aug 19, 2019

@houseofcat I’m in the middle of doing 7.1.0 so it would be a good time to add functionality like this.

There is already the ability to export a type set by interface or attributed interface. So adding something that exports when the interface name matches seems like a very nice convention.

You mention the need for looking up by key. Is that a function of the fact the unity required it when registering or is this something that is located later with a key?

1reaction
houseofcatcommented, Sep 13, 2019

Thanks Ian!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Registration Convention
The Registration Convention was considered and negotiated by the Legal Subcommittee from 1962. It was adopted by the General Assembly in 1974 (General...
Read more >
Registration Convention
The Convention on Registration of Objects Launched into Outer Space was adopted by the United Nations General Assembly in 1974 and went into...
Read more >
Convention on Registration of Objects Launched into Outer ...
1. When a space object is launched into earth orbit or beyond, the launching. State shall register the space object by means of...
Read more >
unitycontainer/registration-by-convention
Registration By Convention. Code of Conduct. This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior ......
Read more >
Convention on Registration of Objects Launched into Outer ...
The Convention was adopted by resolution 3235 (XXIX) of the General Assembly dated 12 November 1974, pursuant to resolution 3182 (XXVIII) 2 dated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found