Try our conversational search powered by Generative AI!

StructureMap Support

Vote:
 

Looking at this post:

https://world.episerver.com/blogs/Johan-Bjornfot/Dates1/2017/11/episerver-servicelocation-structuremap-2/

I mentions its been tested against CMS, Find, Commerce etc.

Has any work been done on the Community Api? I seem to be running into issues and am having to register dependencies myself, for example:

            For<ICommentService>().Use<CommentService>();
            For<ICommentRepository>().Use<HttpCommentRepository>();

I'm currently stuck on EPiServer.Social.Common.Rest.IHttpClientFactory and what it implements as I can't used HttpClientFactory as its a static type.

#226307
Edited, Aug 10, 2020 18:00
Vote:
 

Hi Jacob,

There are packages for the API with the ".Site" suffix (e.g. EPiServer.Social.Comments.Site), which amount to little more than an initialization module that will take care of the dependency registration for you.

Alternatively, if you're in a non-Epi app (or if you're a tinkerer), you can use the factory methods available to construct the services:

() => new DefaultCommentServiceFactory().Create()

Using either of these approaches, you won't need to prepare the service's dependencies manually.

Some additional explanation can be found here.

#226359
Edited, Aug 11, 2020 13:26
Vote:
 

Hi Chris,

Thanks for getting back to me!

I already have the EPiServer.Social.Comments.Site package installed but still seem to have to prepare the dependencies manually!

For instance, if i don't manually register ICommentService I get:

"...No default Instance is registered and cannot be automatically determined for type 'EPiServer.Social.Comments.Core.ICommentService'..."

#226360
Aug 11, 2020 13:38
Vote:
 

Interesting -- we'll investigate what's up with that package. Thanks for letting us know.

The second approach should allow you to manually register the service, without needing to handle the entire dependency chain yourself, as a workaround in the meantime.

#226361
Aug 11, 2020 13:44
Vote:
 

Thanks, I am running version 1.5.4

#226362
Aug 11, 2020 13:46
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.