Пример #1
0
        /// <summary>
        /// Processes an <paramref name="xmlAction"/> element in the XML model, deserializing the persisted values into the provided <paramref name="action"/>.
        /// </summary>
        private static void ProcessXmlAction(XmlElement xmlAction, IAction action)
        {
            string path = xmlAction.GetAttribute("path");

            action.Path = new ActionPath(path, action.ResourceResolver);
            //The group hint from the xml never overrides the action's group hint!!!  Otherwise, we can't change
            //the group hint of an action for the purpose of placing a new one near it.
            //string grouphint = xmlAction.GetAttribute("group-hint");
            //action.GroupHint = new GroupHint(grouphint);

            bool   available      = true;
            string availableValue = xmlAction.GetAttribute("available");

            if (!string.IsNullOrEmpty(availableValue))
            {
                if (!bool.TryParse(availableValue, out available))
                {
                    available = true;
                }
            }
            action.Available = available;

            if (action is IClickAction)
            {
                IClickAction clickAction = (IClickAction)action;

                XKeys  keyStroke      = XKeys.None;
                string keystrokeValue = xmlAction.GetAttribute("keystroke");
                if (!string.IsNullOrEmpty(keystrokeValue))
                {
                    if (!XKeysConverter.TryParseInvariant(keystrokeValue, out keyStroke))
                    {
                        Platform.Log(LogLevel.Debug, "Invalid value for attribute keystroke for action {0}", action.ActionID);
                    }
                }
                clickAction.KeyStroke = keyStroke;
            }
        }