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

Q: How do I create an instance of IType from System.Type? #279

Open
mmisztal1980 opened this issue Aug 1, 2024 · 2 comments
Open

Q: How do I create an instance of IType from System.Type? #279

mmisztal1980 opened this issue Aug 1, 2024 · 2 comments

Comments

@mmisztal1980
Copy link

Using a custom ICondition<Class> I'm writing a set of tests to validate a set of constructors in my library's layer.
I'm enumerating constructor's IType parameters, and I'd like to compare them vs expected System.Type(s) to make my test assertions. The IType has an .IsAssignableTo(IType) method, which I'd gladly use, however I'm not able to convert my System.Type(s) to an IType.

I'm it that to be somewhat difficult to do, and I haven't found anything in the docs yet.
Can anybody explain how can this be achieved?

@CesarD
Copy link

CesarD commented Aug 13, 2024

I'm asking myself the same question. Any tip to share, @alexanderlinne?

@CesarD
Copy link

CesarD commented Aug 13, 2024

Ok, I found by some other people's example that you can do Architecture.GetClassOfType(typeof(YourClass)) or Architecture.GetInterfaceOfType(typeof(IYourInterface)) to get the instance that satisfies an IType interface for the lib methods.

I'd like to know if there's any better alternative, but this works.

Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants