0

I am using sitecore 9.3 and was trying to add configuration for dependency injection of the implemented repository as below:

<register
    serviceType="projectname.IRepository[[projectname.models.model1, projectname]],projectname" 
    implementationType="projectname.Repositories.Repository[[projectname.Models.model1, projectname]],projectname" />

But this doesn't work except after adding "`1" to the interface and the repository names as below:

<register
    serviceType="projectname.IRepository`1[[projectname.models.model1, projectname]],projectname"
    implementationType="projectname.Repositories.Repository`1[[projectname.Models.model1, projectname]],projectname" />

I want to know what this character "`1" represent, any one can advise?

3

"`1" is not Sitecore specific. It's how generic type names in .net can be encoded.

The number after "`" character (arity) stands for the number of generic parameters

E.g. "List`1[string]" means that it's a generic List type with 1 parameter of type string.

and "Dictionary`2[string, int]" stands for a generic Dictionary with 2 parameters where first one is a string and second one is an int.

You can read more in ECMA-335: "II.9 Generics" chapter

|improve this answer|||||
  • Thanks a lot for your clarification – NAli Jan 12 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.