DvInvocation invocation; uint value; bool success = invocation.ReadUint("instanceID", out value); if (success) { Console.WriteLine("The instance ID is: " + value); } else { Console.WriteLine("Failed to read instance ID"); }
using OpenSource.UPnP; public class MyService : UPnPService { public MyService() : base("MyService", 1) { AddMethod("DoSomething"); } protected override void DoSomething(DvInvocation invocation) { uint value; bool success = invocation.ReadUint("param", out value); if (success) { Console.WriteLine("Got value: " + value); } else { Console.WriteLine("Failed to read value"); invocation.Response.ErrorCode = 402; invocation.Response.ErrorDescription = "Invalid parameter value"; } } }In this example, we define a custom UPnP service called "MyService" that has a method called "DoSomething". When this method is invoked by a control point, it expects an input argument called "param" that contains a 32-bit unsigned integer value. We use the ReadUint method to read this value and validate it. If the value is invalid, we set an error code and description in the response. This example assumes the use of the OpenSource.UPnP package library. Possible package/library: OpenSource.UPnP.