How to pass an object to an inner class

I am looking at the source code of an internal .Net class and want to change the function using reflection. (Rewriting each line of the original function into a new function using reflection and adding my modification to it)

object responseObject = request.ConnectionAsyncResult.InternalWaitForCompletion();
ConnectStream writeStream = responseObject as ConnectStream;
if (writeStream == null) ...

How to write a second line of code?

The code checks if the object is a concrete class, but I have no idea how to do this if the class is an inner class. How to pass an object to an inner class?

ConnectStream is an inner class

+4
source share
1 answer

Well no. You just need to use reflection for each step - the compiler is sure that it will not help you :)

" " - - , , . , , , , , .

, #. , , :

if (responseObject != null && responseObject.GetType().Name == "ConnectStream")

: , System.Net ConnectStream , Type . .

+3

Source: https://habr.com/ru/post/1624232/


All Articles