c# - how to make an instance of an unknown class to use as a parameter for a method invocation using reflection? -


Well, to provide a way of grabbing all the ways from a webservice and checking them. So far we are displaying our methods and in some ways only work with entrees and stars. The part is taken care of (we can implement the method correctly and parse the results).

The problem is that some parameters required for the method call are classes that are somewhere in the website Are defined and we have no way of knowing what they are. The only thing we know is that these classes are made only by wire and ints (yay)

We say that the image is trying to make an example which is the "agent" Type

So far I have access to the service that was loaded at runtime which is in a different class. It works just fine

Proxy class:

 . . . Compiler parameter = new compiler parameter (assembly reference); Compiler Results Results = Provider 1 Compilation of Symphonomadom (Paramus, Unit 1); // Check for errors // To add web service method to our list of testing methods, please call. --------------------------- - --- The following are variable class levels --------------------------- Object Services = Results. Compacted asbanks. Create Ention (Sevanam); Type type = service.GetType (); & Lt; ConstructorInfo & gt; ListConstructors = (as the service type) .getType () GetConstructors () ToList (); & Lt; MethodInfo & gt; ListMethods = types.GetMethods (). ToList (); List (method). Where (mi = & gt; mi.GetCustomAttributes (false), where (= = gt; at GetType () == type (Soap Document MediateActivate). Calculation ()> 0) .Oolist (). Methods for ForEach (methodsInfo = & gt; {// test method is a list of wrapper class MethodsToTest.Add (New MethodTest (methodsInfo))});  

Now, im working in a different class. I am trying to achieve the purpose of using the method I use:

I am an example of this "agent" class

  private void Populated parameter listview () (if (funcLBox.SelectedItem! = Null) {resultTBlock.Text = String.Empty; // our text box paramLView.Items.Clear (); Parameter User Input for Pui = Null; // ParameterInfo Proxy A wrapper class. Method method list [index] .info.olist () .for (param = & gt; {Pui = no This parameter will be displayed on userin (ultimate); Parabiliums.ed (Pui); // it will check if it is a system type or a custom type (! Pui.ParameterType.IsSealed) {// This is where we want. In case of // temp, never consider this code as "agent" string temp = Proxy.MethodsToTest [index] .info.GetValue (0) .restring (). Split ('') [0]; MemberIo [] Mia Type = Proxy: gatemember (temporary); process}});}  

Now members have a question on it Brief trying to search through the 'type' declared proxy by members. The problem is that im very sure that I am still looking at the wrong place for those members. What can anyone do after seeing the wrong? I know that there is something with it that is actually on ITRTING

OK, it's a stretch Maybe, but JSN Net libraries () allows you to create an object from any class.

For example (from their document)

  product product = new product (); Product.Name = "Apple"; Product.Expiry = New DateTime (2008, 12, 28); Product. Value = 3. 99 m; Product.Sizes = New String [] {"Small", "Medium", "Big"}; String output = JsonConvert.SerializeObject (product); // "//" "name": "apple", // "end": "\ / date (1230375600000 + 1300) \ /", // "value": 3.99, // "size": [// "Small", // "medium", // "big" //] product deserializedProduct = JsonConvert.DeserializeObject & lt; Products & gt; (Output);  

This will handle your ints and strings easily.

The only problem being is JsonConvert.DeserializeObject & lt; T & gt; () , which you can easily do with your reflection skills.

EDIT: Here are the reflection skills required.

  Object ParseUserInput (string jsonInput) {type type = & lt; ; Var json = typeof (JsonConvert); Var generic = json.GetMethods (). Where (m => m.Name == "desiarialize object" & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; · amp; amp; · amp; amp; amp; amp; amp; amp ;. · amp; amp ;. · amp; Single (); Var method = generic Mechanical method (type); Return method Invoke (empty, jasien input); }  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -