예제 #1
0
 private void BriefAction(XmlReader reader, ServiceAction action)
 {
     reader.Read();
     foreach (Argument argument in action.Arguments.Values)
     {
         argument.Value = argument.RelatedStateVariable.DefaultValue;
     }
     while (Helper.ReadToNextElement(reader))
     {
         if (!action.Arguments.ContainsKey(reader.Name))
         {
             throw UpnpControlException.InvalidArgs();
         }
         Argument argument = action.Arguments[reader.Name];
         if (argument.RelatedStateVariable.DataType.IsEnum)
         {
             try {
                 argument.Value = Enum.Parse(argument.RelatedStateVariable.DataType, reader.ReadString());
             } catch {
                 throw UpnpControlException.ArgumentValueOutOfRange();
             }
         }
         else
         {
             try {
                 argument.Value = Convert.ChangeType(reader.ReadString(), argument.RelatedStateVariable.DataType);
             } catch {
                 throw UpnpControlException.InvalidArgs();
             }
             // TODO handle min, max, and step
         }
     }
     reader.Close();
 }