I am working on an android project with Xamarin and along the way, just as an exercise I decided to write my own simple IoC container. Now, I come to deciding if I need to inject any dependencies for my injected instances. I look up Type.GetConstructors, it says it's available in PCL projects, but I can not seem to get GetConstructors.
I have System.Reflection in my usings and if I create an Android library, I have GetConstructor/s available to me. The MSDN documentation definitely says it's in the PCL. Maybe this is me not totally understanding what PCL means in the Xamarin ecosystem, but I thought that meant it would be supported.
So, my question is, am I missing something or is this actually correct?
UPDATE
For anybody wanting to see how I did this;
https://github.com/tbd-develop/simpletypeprovider
Shared Projects work well for application developers planning to use lots of platform-specific functionality in their cross-platform apps. While PCL projects continue to be supported in Visual Studio, . NET Standard is recommended for new projects.
Xamarin uses the same PCL profiles that Microsoft has released, but not all PCL profiles support System.Type.GetConstructors().
You'll probably need to do something like this (hard to say for sure, because every PCL profile has different System.Reflection limitations):
var info = type.GetTypeInfo ();
foreach (var ctor in info.DeclaredConstructors) {
// find the .ctor you want...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With