1

I have the following piece of code

    public TOutput DoStuff<TOutput>(object input)
    {
        var type = typeof(IDoStuffHandler<,>).MakeGenericType(typeof(TOutput), input.GetType());

        dynamic provider = _lifetimeScope.Resolve(type);

        return provider.DoStuff((dynamic)input);
    }

This currently works as long as the input is not null. As soon as we have a null I get a null reference exception on input.GetType(). Is there a way for me to figure out the type of input?

Strike08
  • 267
  • 1
  • 2
  • 17
  • No way. https://stackoverflow.com/questions/254461/net-how-do-you-get-the-type-of-a-null-object – Roman Ryzhiy Sep 15 '20 at 11:24
  • No this does not solve the question as it is not the same. The output parameter is different than what we use as input. This method converts types to different types – Strike08 Sep 15 '20 at 11:33
  • how are they different? you just added a resolvable type next to the null type. They BOTH need to be resolved independently. – Bizhan Sep 15 '20 at 11:58

0 Answers0