Glass.Mapper.Sc set inferType to true by default globally

In Glass.Mapper.Sc v 4.0.1.5 ISitecoreService and ISitecoreContext have all their method signatures with inferType false by default. I'm looking for a way to override this value and use true by default without changing method calls throughout the site.

I created another interface to override those in order to change the default inferType to true, but I was wondering if there was a better solution.

+3


source to share


1 answer


There is no automatic override for this, but it may be easier to create your own task in the configuration converter pipeline.

If you look at the following line of code: https://github.com/mikeedwards83/Glass.Mapper/blob/master/Source/Glass.Mapper.Sc/Pipelines/ConfigurationResolver/TemplateInferredTypeTask.cs#L48



You can see that it is just checking the InferType flag, you can create another pipeline at the beginning of the request that just sets it to true. Then each request will be valid through InferType.

You will need to register a new pipeline process in the GlassMapperScCustom against the DependencyResolver.ConfigurationResolverFactory using the Add method.

+2


source







All Articles