private static int DoGetColorComponents(IntPtr aPtr, IntPtr aInvocation) { GCHandle gch = GCHandle.FromIntPtr(aPtr); DvProviderOpenhomeOrgTestLights1 self = (DvProviderOpenhomeOrgTestLights1)gch.Target; DvInvocation invocation = new DvInvocation(aInvocation); uint color; uint brightness; uint red; uint green; uint blue; try { invocation.ReadStart(); color = invocation.ReadUint("Color"); invocation.ReadEnd(); self.GetColorComponents(invocation, color, out brightness, out red, out green, out blue); } catch (ActionError e) { invocation.ReportActionError(e, "GetColorComponents"); return(-1); } catch (PropertyUpdateError) { invocation.ReportError(501, String.Format("Invalid value for property {0}", "GetColorComponents")); return(-1); } catch (Exception e) { Console.WriteLine("WARNING: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "GetColorComponents", e.TargetSite.Name); Console.WriteLine(" Only ActionError or PropertyUpdateError should be thrown by actions"); return(-1); } try { invocation.WriteStart(); invocation.WriteUint("Brightness", brightness); invocation.WriteUint("Red", red); invocation.WriteUint("Green", green); invocation.WriteUint("Blue", blue); invocation.WriteEnd(); } catch (ActionError) { return(-1); } catch (System.Exception e) { Console.WriteLine("ERROR: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "GetColorComponents", e.TargetSite.Name); Console.WriteLine(" Only ActionError can be thrown by action response writer"); } return(0); }
private static int DoGetPosition(IntPtr aPtr, IntPtr aInvocation) { GCHandle gch = GCHandle.FromIntPtr(aPtr); DvProviderOpenhomeOrgTestLights1 self = (DvProviderOpenhomeOrgTestLights1)gch.Target; DvInvocation invocation = new DvInvocation(aInvocation); uint index; uint x; uint y; uint z; try { invocation.ReadStart(); index = invocation.ReadUint("Index"); invocation.ReadEnd(); self.GetPosition(invocation, index, out x, out y, out z); } catch (ActionError e) { invocation.ReportActionError(e, "GetPosition"); return(-1); } catch (PropertyUpdateError) { invocation.ReportError(501, String.Format("Invalid value for property {0}", "GetPosition")); return(-1); } catch (Exception e) { Console.WriteLine("WARNING: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "GetPosition", e.TargetSite.Name); Console.WriteLine(" Only ActionError or PropertyUpdateError should be thrown by actions"); return(-1); } try { invocation.WriteStart(); invocation.WriteUint("X", x); invocation.WriteUint("Y", y); invocation.WriteUint("Z", z); invocation.WriteEnd(); } catch (ActionError) { return(-1); } catch (System.Exception e) { Console.WriteLine("ERROR: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "GetPosition", e.TargetSite.Name); Console.WriteLine(" Only ActionError can be thrown by action response writer"); } return(0); }
private static int DoGetColor(IntPtr aPtr, IntPtr aInvocation) { GCHandle gch = GCHandle.FromIntPtr(aPtr); DvProviderOpenhomeOrgTestLights1 self = (DvProviderOpenhomeOrgTestLights1)gch.Target; DvInvocation invocation = new DvInvocation(aInvocation); uint index; uint color; try { invocation.ReadStart(); index = invocation.ReadUint("Index"); invocation.ReadEnd(); self.GetColor(invocation, index, out color); } catch (ActionError e) { invocation.ReportActionError(e, "GetColor"); return(-1); } catch (PropertyUpdateError) { invocation.ReportError(501, String.Format("Invalid value for property {0}", new object[] { "GetColor" })); return(-1); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("WARNING: unexpected exception {0} thrown by {1}", new object[] { e, "GetColor" }); System.Diagnostics.Debug.WriteLine(" Only ActionError or PropertyUpdateError should be thrown by actions"); return(-1); } try { invocation.WriteStart(); invocation.WriteUint("Color", color); invocation.WriteEnd(); } catch (ActionError) { return(-1); } catch (System.Exception e) { System.Diagnostics.Debug.WriteLine("WARNING: unexpected exception {0} thrown by {1}", new object[] { e, "GetColor" }); System.Diagnostics.Debug.WriteLine(" Only ActionError can be thrown by action response writer"); } return(0); }