internal static CpArgument CreateArgument(CpAction parentAction, CpService parentService, XPathNavigator argumentNav, IXmlNamespaceResolver nsmgr) { string name = ParserHelper.SelectText(argumentNav, "s:name/text()", nsmgr); string relatedStateVariableName = ParserHelper.SelectText(argumentNav, "s:relatedStateVariable/text()", nsmgr); CpStateVariable relatedStateVariable; if (!parentService.StateVariables.TryGetValue(relatedStateVariableName, out relatedStateVariable)) { throw new ArgumentException("Related state variable '{0}' is not present in service", relatedStateVariableName); } string direction = ParserHelper.SelectText(argumentNav, "s:direction/text()", nsmgr); XPathNodeIterator retValIt = argumentNav.Select("s:retval", nsmgr); CpArgument result = new CpArgument(parentAction, name, relatedStateVariable, ParseArgumentDirection(direction), retValIt.MoveNext()); return(result); }
internal static CpAction ConnectAction(DeviceConnection connection, CpService parentService, XPathNavigator actionNav, IXmlNamespaceResolver nsmgr) { using (connection.CPData.Lock.EnterWrite()) { string name = ParserHelper.SelectText(actionNav, "s:name/text()", nsmgr); CpAction result = new CpAction(connection, parentService, name); XPathNodeIterator argumentIt = actionNav.Select("s:argumentList/s:argument", nsmgr); while (argumentIt.MoveNext()) { CpArgument argument = CpArgument.CreateArgument(result, parentService, argumentIt.Current, nsmgr); if (argument.Direction == ArgumentDirection.In) { result.AddInAgrument(argument); } else { result.AddOutAgrument(argument); } } return(result); } }
/// <summary> /// Adds a new formal output argument to this action. /// </summary> /// <exception cref="UPnPAlreadyConnectedException">If the action is already connected to an action in a device.</exception> /// <param name="argument">Argument to add.</param> internal void AddOutAgrument(CpArgument argument) { _outArguments.Add(argument); }
/// <summary> /// Adds a new formal input argument to this action. /// </summary> /// <exception cref="UPnPAlreadyConnectedException">If the action is already connected to an action in a device.</exception> /// <param name="argument">Argument to add.</param> internal void AddInAgrument(CpArgument argument) { _inArguments.Add(argument); }
internal static CpArgument CreateArgument(CpAction parentAction, CpService parentService, XPathNavigator argumentNav, IXmlNamespaceResolver nsmgr) { string name = ParserHelper.SelectText(argumentNav, "s:name/text()", nsmgr); string relatedStateVariableName = ParserHelper.SelectText(argumentNav, "s:relatedStateVariable/text()", nsmgr); CpStateVariable relatedStateVariable; if (!parentService.StateVariables.TryGetValue(relatedStateVariableName, out relatedStateVariable)) throw new ArgumentException("Related state variable '{0}' is not present in service", relatedStateVariableName); string direction = ParserHelper.SelectText(argumentNav, "s:direction/text()", nsmgr); XPathNodeIterator retValIt = argumentNav.Select("s:retval", nsmgr); CpArgument result = new CpArgument(parentAction, name, relatedStateVariable, ParseArgumentDirection(direction), retValIt.MoveNext()); return result; }