Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Resolve Generic Class<T>(it's constructor parameter also generic…e.g:Param<T> param) With Unity Container?? help! thanks #27

Open
jetjo opened this issue Dec 3, 2019 · 3 comments
Labels
Question ❔ Issue is a question

Comments

@jetjo
Copy link

jetjo commented Dec 3, 2019

interface Interface<T>{}

class Class<T>:Interface<T>
{
      public Class(IInterfaceParam<T> param){}
}

interface IInterfaceParam<T>{}

class InterfaceParam<T>:IInterfaceParam<T>{}

class Tclass{}

 class Program
 {
          void Main(){
                  var v1= container.Resolve<Interface<Tclass>>();
          }
 }

how to config in unity.config xml file?? help! thanks!

bellow is my config:

  <register type="IInterfaceParam`1" mapTo="InterfaceParam`1" name="paramDefault">
  </register>

  <register type="Interface`1" mapTo="Class`1">
    <constructor>
      <param type="IInterfaceParam`1" name="param">
        <dependency name="paramDefault"></dependency>
      </param>
    </constructor>
  </register>

but i got the exception:InvalidOperationException: Configuration is incorrect, the type Class`1 does not have a constructor that takes parameters named param...why???

@jetjo
Copy link
Author

jetjo commented Dec 3, 2019

can help me??
thanks very much!

@ENikS ENikS transferred this issue from unitycontainer/container Dec 19, 2019
@ENikS
Copy link
Contributor

ENikS commented Dec 19, 2019 via email

@ENikS ENikS added this to the Bugs and Questions milestone Apr 3, 2020
@ENikS ENikS added the Question ❔ Issue is a question label Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question ❔ Issue is a question
Projects
None yet
Development

No branches or pull requests

2 participants