You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var ISolrQueryExecuter = typeof (ISolrQueryExecuter<>).MakeGenericType(core.DocumentType);
var SolrQueryExecuter = typeof (SolrQueryExecuter<>).MakeGenericType(core.DocumentType);
string coreConnectionId = GetCoreConnectionId(core.Id);
var registrationId = isNamed ? core.Id : null;
container.RegisterType(
ISolrQueryExecuter, SolrQueryExecuter, registrationId,
new InjectionConstructor(
new ResolvedParameter(typeof (ISolrAbstractResponseParser<>).MakeGenericType(core.DocumentType)),
new ResolvedParameter(typeof (ISolrConnection), coreConnectionId),
new ResolvedParameter(typeof (ISolrQuerySerializer)),
new ResolvedParameter(typeof (ISolrFacetQuerySerializer)),
new ResolvedParameter(typeof (ISolrMoreLikeThisHandlerQueryResultsParser<>).MakeGenericType(core.DocumentType))));
The point seems to be to create a named (keyed?) registrations.
You get this instances like this:
var core1 = container.Resolve<ISolrOperations<Entity>>("core1");
So, follow-up question. I need to set an injection property at the same time. Unity was using InjectionProperty. I looked at ImportMembers but couldn't figure out how to set a specific value.
container.RegisterType<ISolrConnection, SolrConnection>("solr" + typeof(SolrConnection),
new InjectionMember[] { new InjectionConstructor("http://localhost:8983/solr"),
new InjectionProperty("HttpWebRequestFactory", new BasicAuthHttpWebRequestFactory("user", "pass")) });
Now, why they didn't just add an overloaded constructor, I have no idea...
So, follow-up question. I need to set an injection property at the same time. Unity was using InjectionProperty. I looked at ImportMembers but couldn't figure out how to set a specific value.
container.RegisterType<ISolrConnection, SolrConnection>("solr" + typeof(SolrConnection),
new InjectionMember[] { new InjectionConstructor("http://localhost:8983/solr"),
new InjectionProperty("HttpWebRequestFactory", new BasicAuthHttpWebRequestFactory("user", "pass")) });
Now, why they didn't just add an overloaded constructor, I have no idea...
How's it going with the official release? We have a release coming up in a week or so and I'd like to change my Grace package from Beta before that happens.
Activity
ipjohnson commentedon Sep 17, 2018
Hi @scovel,
I’ll find some examples tonight showing how to do this. Essentially it’s just adding a couple WithCtorParam configurations to the Export call.
adding WithCtorParam with not generic type for issue #194
ipjohnson commentedon Sep 18, 2018
I realized there was no method to register what you wanted to do so I added a new method and will do a nuget pre-release for it.
Case 1:
Case 2:
scovel commentedon Sep 19, 2018
That is working!!!
I owe you so many beers....
So, follow-up question. I need to set an injection property at the same time. Unity was using InjectionProperty. I looked at ImportMembers but couldn't figure out how to set a specific value.
.ImportMembers(MembersThat.AreNamed("HttpWebRequestFactory"))Looking at the property in the library there is no specific injection attributes on it, it's just a public property.
Here's the Unity code:
Now, why they didn't just add an overloaded constructor, I have no idea...
scovel commentedon Sep 19, 2018
That is working!!!
I owe you so many beers....
So, follow-up question. I need to set an injection property at the same time. Unity was using InjectionProperty. I looked at ImportMembers but couldn't figure out how to set a specific value.
.ImportMembers(MembersThat.AreNamed("HttpWebRequestFactory"))Looking at the property in the library there is no specific injection attributes on it, it's just a public property.
Here's the Unity code:
Now, why they didn't just add an overloaded constructor, I have no idea...
ipjohnson commentedon Sep 19, 2018
@scovel, I think is probably another case of the container can do it but the registration method is missing for non generic.
I can add it but I may not be able to get to it till this weekend because of family obligations.
scovel commentedon Sep 20, 2018
Sounds good. I finished up the rest of the port and didn't find anything else I need. Let me know when you want me to test.
Have a good weekend.
adding property injection for issue #194
ipjohnson commentedon Sep 22, 2018
Ok I've pushed out a beta to nuget with the new ImportProperty method.
scovel commentedon Sep 24, 2018
The beta is working great! Thanks for your efforts again.
ipjohnson commentedon Sep 24, 2018
Very cool, in 2-3 weeks I’ll plan to do an official release.
scovel commentedon Oct 11, 2018
How's it going with the official release? We have a release coming up in a week or so and I'd like to change my Grace package from Beta before that happens.
Thanks,
Sean
ipjohnson commentedon Oct 11, 2018
I’ll do an official release this weekend.
ipjohnson commentedon Oct 13, 2018
marking as closed in release 6.4.2