Dynamically create service actions

May 9, 2015 at 9:46 PM
@The Toid,

I am still developing my Sony API, and am wanting to add more features.
Sort of like your ManagedUPnPTest example, I would like to be able to Dynamically create Methods based on the actions found with each service.

For example:
My Bravia has a service called AVTransport:1
It has an action called SetNextAVTransportURI, that requires 3 params.

I already have a class object called SonyDevice. It currently holds all the devices information.
This class has a partial class that holds all the Services called Servs. (SonyDevice.Servs)
Currently, I am accessing the services using a ForNext to loop through the services then executing the corresponding Invoke statement.

Is there a way during the creation of my SonyDevice that I could Dynamically create the AVTransport method and be able to access it through my object class?

This would cut down on my coding for all the serivces and actions.

Like this:
SonyDevice.Servs.AVTransport.SetNextAVTransportURI(Int Instance ID, string NextURI, string NextURIMetaData)

I also would like to know how to create a listener for state variable changes!

Thanks in advance for your help!
May 15, 2015 at 4:27 PM
Edited May 15, 2015 at 6:39 PM
OK, Disregard my above question, I am moving away from that, as I used your CodeGen and created the code for the Service object (AVTransport:1), and placed it directly in to my project.

Now, I am trying to save my Device object to a file.
However, I can not find a way to serialize anything from the ManagedUPnP.

For example, my SonyDevice object now has a Service object called AVTransport.
But this object is derived from a ManagedUPnP.Service object. (Does not have a parameterless constructor)

In your best practice, How could I save all the information for my device to a file, so I could then load the device in to my application and not have to do all the discovery stuff or send out a broadcast then load each service.

Thanks,

EDIT: Let me re-phase my question. Lets say I save the devices Description.xml to a file. Is there a way to create the device and services from this file instead of discovery?