예제 #1
0
        public static HarmonyDocument IRCommandDocument(string deviceId, string command)
        {
            var document = new HarmonyDocument();

            var element = new Element("oa");

            element.Attributes.Add("xmlns", "connect.logitech.com");
            element.Attributes.Add("mime", "vnd.logitech.harmony/vnd.logitech.harmony.engine?holdAction");

            var action = new HarmonyAction {
                type = "IRCommand", deviceId = deviceId, command = command
            };
            var json = new JavaScriptSerializer().Serialize(action);

            // At this point our valid json won't work - we need to break it so it looks like:
            // {"type"::"IRCommand","deviceId"::"deviceId","command"::"command"}
            // note double colons

            json = json.Replace(":", "::");

            element.Value = string.Format("action={0}:status=press", json);

            document.AddChild(element);

            return(document);
        }
        public static HarmonyDocument IrCommandDocument(string deviceId, string command)
        {
            var document = new HarmonyDocument();

            var action = new HarmonyAction {
                type = "IRCommand", deviceId = deviceId, command = command
            };
            var json = new JavaScriptSerializer().Serialize(action);

            // At this point our valid json won't work - we need to break it so it looks like:
            // {"type"::"IRCommand","deviceId"::"deviceId","command"::"command"}
            // note double colons

            json = json.Replace(":", "::");
            var element = CreateOaElement("holdAction");

            element.Value = $"action={json}:status=press";

            document.AddChild(element);

            return(document);
        }