public ActionEditForm(UPnPService parentService)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            action = new UPnPAction();
            action.ParentService = parentService;
        }
        public ActionEditForm(UPnPService parentService)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            action = new UPnPAction();
            action.ParentService = parentService;
        }
        public MethodInvoke(UPnPAction action, UPnPService service)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.action = action;
            this.service = service;

            this.Text += " - " + action.Name;
            actionLabel.Text = action.Name;
            serviceLabel.Text = service.ServiceID;
            deviceLabel.Text = service.ParentDevice.FriendlyName;

            if (action.ArgumentList.Length>0)
            {
                argControlList = new UPnpArgumentControl[action.ArgumentList.Length];

                for (int z=0;z<action.ArgumentList.Length;++z)
                {
            //					if (action.ArgumentList[z].IsReturnValue == true) {returnArgPresent = true;}
                    argControlList[z] = new UPnpArgumentControl(action.ArgumentList[z]);
                    argControlList[z].Dock = System.Windows.Forms.DockStyle.Top;
                    /*
                    if (action.ArgumentList[z].RelatedStateVar.ValueType == "string")
                    {
                        argControlList[z].Height = 60;
                    }
                    */
                    argPanel.Controls.Add(argControlList[z]);
                    argPanel.Controls.SetChildIndex(argControlList[z],0);

                    Splitter splitter = new Splitter();
                    splitter.Height = 4;
                    splitter.MinExtra = 0;
                    splitter.MinSize = 32;
                    splitter.BackColor = Color.Gray;
                    splitter.Dock = System.Windows.Forms.DockStyle.Top;
                    argPanel.Controls.Add(splitter);
                    argPanel.Controls.SetChildIndex(splitter,0);
                }
            }

            service.OnInvokeError += new UPnPService.UPnPServiceInvokeErrorHandler(HandleInvokeError);
            service.OnInvokeResponse += new UPnPService.UPnPServiceInvokeHandler(HandleInvoke);
        }
        private void ParseActionXml(String XML)
        {
            UPnPAction action = new UPnPAction();
            UPnPArgument arg;

            StringReader MyString = new StringReader(XML);
            XmlTextReader XMLDoc = new XmlTextReader(MyString);

            XMLDoc.Read();
            XMLDoc.MoveToContent();
            XMLDoc.Read();
            XMLDoc.MoveToContent();
            while (XMLDoc.LocalName != "action")
            {
                switch (XMLDoc.LocalName)
                {
                    case "name":
                        OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.SuccessAudit, "I've found an action");
                        action.Name = XMLDoc.ReadString().Trim();
                        OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.SuccessAudit, "Its called " + action.Name);
                        break;
                    case "argumentList":
                        if (XMLDoc.IsEmptyElement)
                        {
                            break;
                        }
                        XMLDoc.Read();
                        XMLDoc.MoveToContent();
                        while (XMLDoc.LocalName != "argumentList" && XMLDoc.EOF == false)
                        {
                            if (XMLDoc.LocalName == "argument")
                            {
                                arg = new UPnPArgument();
                                XMLDoc.Read();
                                XMLDoc.MoveToContent();
                                while (XMLDoc.LocalName != "argument")
                                {
                                    switch (XMLDoc.LocalName)
                                    {
                                        case "name":
                                            arg.Name = XMLDoc.ReadString().Trim();
                                            break;
                                        case "retval":
                                            arg.IsReturnValue = true;
                                            break;
                                        case "direction":
                                            arg.Direction = XMLDoc.ReadString().Trim();
                                            break;
                                        case "relatedStateVariable":
                                            OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.SuccessAudit, "I've found a related state variable");
                                            arg.StateVarName = XMLDoc.ReadString().Trim();
                                            OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.SuccessAudit, "Its called " + arg.StateVarName);
                                            break;
                                    }
                                    XMLDoc.Read();
                                    XMLDoc.MoveToContent();
                                }
                                action.AddArgument(arg);
                                XMLDoc.Read();
                                XMLDoc.MoveToContent();
                            }
                            else
                            {
                                XMLDoc.Skip();
                            }
                        }
                        break;
                }
                // End of Switch
                XMLDoc.Read();
                XMLDoc.MoveToContent();
            }
            // End of While

            AddAction(action);
        }
示例#5
0
 /// <summary>
 /// Adds a UPnPAction to this service
 /// </summary>
 /// <param name="action">Action to add</param>
 public void AddMethod(UPnPAction action)
 {
     if (action.Name == null || action.Name.Length == 0) throw new Exception("Invalid action name");
     action.ParentService = this;
     this.AddAction(action);
 }
        /// <summary>
        /// Remove a UPnPAction, using name of object
        /// </summary>
        /// <param name="action">Action to remove</param>
        public void RemoveMethod(UPnPAction action)
        {
            UPnPAction A = GetAction(action.Name);
            if (A == null) return;

            foreach (UPnPArgument arg in A.ArgumentList)
            {
                arg.RelatedStateVar.RemoveAssociation(A.Name, arg.Name);
                if (arg.RelatedStateVar.GetAssociations().Length == 0) RemoveStateVariable(arg.RelatedStateVar);
            }
            RemoteMethods.Remove(A.Name);
        }
        private void AddAction(UPnPAction action)
        {
            action.ParentService = this;
            RemoteMethods[action.Name] = action;

            // Check State Variables
            foreach (UPnPArgument arg in action.Arguments)
            {
                if (arg.__StateVariable != null)
                {
                    if (this.GetStateVariableObject(arg.__StateVariable.Name) == null)
                    {
                        this.AddStateVariable(arg.__StateVariable);
                    }
                    arg.__StateVariable = null;
                }
            }
        }
 /// <summary>
 /// Retrieves Actions exposed by this Service
 /// </summary>
 /// <returns>Array of Actions</returns>
 public UPnPAction[] GetActions()
 {
     UPnPAction[] RetVal = new UPnPAction[RemoteMethods.Count];
     IDictionaryEnumerator en = RemoteMethods.GetEnumerator();
     int id = 0;
     while (en.MoveNext())
     {
         RetVal[id] = (UPnPAction)en.Value;
         ++id;
     }
     return (RetVal);
 }
 /// <summary>
 /// Remove a UPnPAction, by name
 /// </summary>
 /// <param name="MethodName">Name of Action</param>
 public void RemoveMethod(string MethodName)
 {
     UPnPAction A = new UPnPAction();
     A.Name = MethodName;
     RemoveMethod(A);
 }
        private bool BasicControlTest_ACTION_BadAllowedValues(UPnPService s, UPnPAction A)
        {
            (new UPnPDebugObject(s)).SetProperty("ValidationMode",false);
            ArrayList ArgList = null;
            foreach(UPnPArgument arg in A.ArgumentList)
            {
                if(arg.IsReturnValue==false && arg.Direction=="in")
                {
                    if(arg.RelatedStateVar.AllowedStringValues!=null)
                    {
                        ArgList = BasicControlTest_BuildActionArgs(A);
                        for(int i=0;i<ArgList.Count;++i)
                        {
                            if(((UPnPArgument)ArgList[i]).Name==arg.Name)
                            {
                                string val = "!@#$";
                                bool OK = true;
                                do
                                {
                                    OK = true;
                                    for(int j=0;j<arg.RelatedStateVar.AllowedStringValues.Length;++j)
                                    {
                                        if(val==arg.RelatedStateVar.AllowedStringValues[j])
                                        {
                                            OK = false;
                                            break;
                                        }
                                    }
                                    if(OK==false) val += val;
                                }while (OK==false);
                                ((UPnPArgument)ArgList[i]).DataValue = val;

                                AddEvent(LogImportance.Remark,"Allowed Values","Invoke <<Bad " + arg.Name + ">> " + A.Name);
                                try
                                {
                                    s.InvokeSync(A.Name,(UPnPArgument[])ArgList.ToArray(typeof(UPnPArgument)));
                                    WARN_ALLOWED = true;
                                    AddEvent(LogImportance.High,"Allowed Values","   Device failed to validate argument");
                                }
                                catch(UPnPInvokeException ex)
                                {
                                    if(ex.UPNP!=null)
                                    {
                                        if(ex.UPNP.ErrorCode<501)
                                        {
                                            AddEvent(LogImportance.Remark,"Allowed Values","   Device SUCCESSFULLY validated argument");
                                        }
                                        else
                                        {
                                            WARN_ALLOWED = true;
                                            AddEvent(LogImportance.Remark,"Allowed Values","   Device returned code: " + ex.UPNP.ErrorCode.ToString() + " but failed to validate argument");
                                        }
                                    }
                                    else
                                    {
                                        FAIL_ALLOWED = true;
                                        AddEvent(LogImportance.Critical,"Allowed Values","   Device returned non SOAP-Encoded Error");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            (new UPnPDebugObject(s)).SetProperty("ValidationMode",true);
            return true;
        }
        /// <summary>
        /// Add a method to expose in this service
        /// </summary>
        /// <param name="MethodName">The name of the method to expose</param>
        public void AddMethod(String MethodName)
        {
            string retname = "_ReturnValue";
            UPnPStateVariable[] ESV;
            bool DontCreate = false;
            ESV = this.GetStateVariables();
            UPnPStateVariable sv;
            MethodInfo minfo = ServiceInstance.GetType().GetMethod(MethodName);
            if (minfo == null)
            {
                throw (new Exception(MethodName + " does not exist in " + ServiceInstance.GetType().ToString()));
            }

            // Create Generic State Variables
            DontCreate = false;
            if (minfo.ReturnType.FullName != "System.Void")
            {
                if (minfo.GetCustomAttributes(true).Length > 0)
                {
                    foreach (Attribute a in minfo.GetCustomAttributes(true))
                    {
                        if (a.GetType() == typeof(OpenSource.UPnP.ReturnArgumentAttribute))
                        {
                            retname = ((ReturnArgumentAttribute)a).Name;
                            break;
                        }
                    }
                }

                // There is a return value
                sv = new UPnPStateVariable("A_ARG_TYPE_" + MethodName + "_RetType", minfo.ReturnType, false);
                sv.AddAssociation(MethodName, retname);

                foreach (UPnPStateVariable _ESV in ESV)
                {
                    foreach (UPnPStateVariable.AssociationNode AESV in _ESV.GetAssociations())
                    {
                        if ((AESV.ActionName == MethodName) && (AESV.ArgName == retname))
                        {
                            // Don't create state variable
                            DontCreate = true;
                        }
                    }
                }

                if (DontCreate == false) this.AddStateVariable(sv);
            }

            ParameterInfo[] pinfo = minfo.GetParameters();
            for (int x = 0; x < pinfo.Length; ++x)
            {
                sv = new UPnPStateVariable("A_ARG_TYPE_" + MethodName + "_" + pinfo[x].Name, pinfo[x].ParameterType, false);
                sv.AddAssociation(MethodName, pinfo[x].Name);
                DontCreate = false;
                foreach (UPnPStateVariable _ESV in ESV)
                {
                    foreach (UPnPStateVariable.AssociationNode AESV in _ESV.GetAssociations())
                    {
                        if ((AESV.ActionName == MethodName) && (AESV.ArgName == pinfo[x].Name))
                        {
                            // Don't create state variable
                            DontCreate = true;
                        }
                    }
                }
                if (DontCreate == false) this.AddStateVariable(sv);
            }
            UPnPAction NewAction = new UPnPAction();
            NewAction.Name = MethodName;
            NewAction.ParentService = this;
            NewAction.MethodPointer = minfo;
            UPnPArgument ARG;

            if (minfo.ReturnType.FullName != "System.Void")
            {
                ARG = new UPnPArgument(retname, "");
                ARG.DataType = UPnPStateVariable.ConvertToUPnPType(minfo.ReturnType);
                ARG.Direction = "out";
                ARG.IsReturnValue = true;
                ARG.ParentAction = NewAction;
                ARG.StateVarName = this.GetStateVariableObject(MethodName, retname).Name;
                NewAction.AddArgument(ARG);
            }
            foreach (ParameterInfo p in pinfo)
            {
                ARG = new UPnPArgument(p.Name, "");
                ARG.DataType = UPnPStateVariable.ConvertToUPnPType(p.ParameterType);

                ARG.Direction = p.Attributes == ParameterAttributes.Out ? "out" : "in";

                ARG.IsReturnValue = false;
                ARG.ParentAction = NewAction;
                ARG.StateVarName = this.GetStateVariableObject(MethodName, p.Name).Name;
                NewAction.AddArgument(ARG);
            }
            this.AddAction(NewAction);
        }
示例#12
0
        private void ParseActionXml(String XML, int startLine)
        {
            UPnPAction action = new UPnPAction();
            UPnPArgument arg;

            StringReader MyString = new StringReader(XML);
            XmlTextReader XMLDoc = new XmlTextReader(MyString);

            try
            {
                XMLDoc.Read();
                XMLDoc.MoveToContent();
                XMLDoc.Read();
                XMLDoc.MoveToContent();
                while (XMLDoc.LocalName != "action")
                {
                    switch (XMLDoc.LocalName)
                    {
                        case "name":
                            action.Name = XMLDoc.ReadString().Trim();
                            break;
                        case "argumentList":
                            if (XMLDoc.IsEmptyElement)
                            {
                                break;
                            }
                            XMLDoc.Read();
                            XMLDoc.MoveToContent();
                            while (XMLDoc.LocalName != "argumentList" && XMLDoc.EOF == false)
                            {
                                if (XMLDoc.LocalName == "argument")
                                {
                                    arg = new UPnPArgument();
                                    XMLDoc.Read();
                                    XMLDoc.MoveToContent();
                                    while (XMLDoc.LocalName != "argument")
                                    {
                                        switch (XMLDoc.LocalName)
                                        {
                                            case "name":
                                                arg.Name = XMLDoc.ReadString().Trim();
                                                break;
                                            case "retval":
                                                arg.IsReturnValue = true;
                                                break;
                                            case "direction":
                                                arg.Direction = XMLDoc.ReadString().Trim();
                                                break;
                                            case "relatedStateVariable":
                                                arg.StateVarName = XMLDoc.ReadString().Trim();
                                                break;
                                        }
                                        XMLDoc.Read();
                                        XMLDoc.MoveToContent();
                                    }
                                    action.AddArgument(arg);
                                    XMLDoc.Read();
                                    XMLDoc.MoveToContent();
                                }
                                else
                                {
                                    XMLDoc.Skip();
                                }
                            }
                            break;
                    }
                    // End of Switch
                    XMLDoc.Read();
                    XMLDoc.MoveToContent();
                }
                // End of While

                AddAction(action);
            }
            catch (Exception ex)
            {
                throw new XMLParsingException("Invalid Action XML", startLine + XMLDoc.LineNumber, XMLDoc.LinePosition, ex);
            }
        }
        private void SetAction(UPnPAction act)
        {
            actionNameTextBox.Text = act.Name;

            UPnPArgument[] args = act.ArgumentList;
            foreach (UPnPArgument arg in args)
            {
                UPnpArgumentEditControl argEdit = new UPnpArgumentEditControl(this,act,arg);
                argEdit.Dock = DockStyle.Top;
                argPanel.Controls.Add(argEdit);
                argPanel.Controls.SetChildIndex(argEdit,0);
            }
        }
 private void TestAction(UPnPAction A)
 {
     ArrayList ArgList = new ArrayList();
     Hashtable RelTable = new Hashtable();
     UPnPArgument G;
     foreach(UPnPArgument arg in A.Arguments)
     {
         if(arg.IsReturnValue==false)
         {
             G = new UPnPArgument(arg.Name,UPnPService.CreateObjectInstance(arg.RelatedStateVar.GetNetType(),null));
             RelTable[G] = arg.RelatedStateVar;
             ArgList.Add(G);
         }
     }
 }
        private bool BasicControlTest_ACTION_BadRange(UPnPService s, UPnPAction A)
        {
            (new UPnPDebugObject(s)).SetProperty("ValidationMode",false);

            ArrayList ArgList = null;
            foreach(UPnPArgument arg in A.ArgumentList)
            {
                if(arg.IsReturnValue==false && arg.Direction=="in")
                {
                    if(arg.RelatedStateVar.Maximum!=null ||
                        arg.RelatedStateVar.Minimum!=null)
                    {
                        ArgList = BasicControlTest_BuildActionArgs(A);
                        for(int i=0;i<ArgList.Count;++i)
                        {
                            if(((UPnPArgument)ArgList[i]).Name==arg.Name)
                            {
                                if(arg.RelatedStateVar.Minimum!=null)
                                {
                                    FieldInfo mi = arg.RelatedStateVar.GetNetType().GetField("MinValue");
                                    if(mi.GetValue(null).ToString()!=arg.RelatedStateVar.Minimum.ToString())
                                    {
                                        ((UPnPArgument)ArgList[i]).DataValue = mi.GetValue(null);

                                        AddEvent(LogImportance.Remark,"Range","Invoke <<" + arg.Name + " value too small>> " + A.Name);
                                        try
                                        {
                                            s.InvokeSync(A.Name,(UPnPArgument[])ArgList.ToArray(typeof(UPnPArgument)));
                                            WARN_RANGE = true;
                                            AddEvent(LogImportance.High,"Range","   Device failed to validate argument");
                                        }
                                        catch(UPnPInvokeException ex)
                                        {
                                            if(ex.UPNP!=null)
                                            {
                                                if(ex.UPNP.ErrorCode<501)
                                                {
                                                    AddEvent(LogImportance.Remark,"Range","   Device SUCCESSFULLY validated argument");

                                                }
                                                else
                                                {
                                                    WARN_RANGE = true;
                                                    AddEvent(LogImportance.High,"Range","   Device returned code: " + ex.UPNP.ErrorCode.ToString() + " but failed to validate argument");
                                                }
                                            }
                                            else
                                            {
                                                FAIL_RANGE = true;
                                                AddEvent(LogImportance.Critical,"Range","   Device returned non SOAP-Encoded Error");
                                            }
                                        }
                                    }
                                }
                                if(arg.RelatedStateVar.Maximum!=null)
                                {
                                    FieldInfo mi = arg.RelatedStateVar.GetNetType().GetField("MaxValue");
                                    if(mi.GetValue(null).ToString()!=arg.RelatedStateVar.Maximum.ToString())
                                    {
                                        ((UPnPArgument)ArgList[i]).DataValue = mi.GetValue(null);

                                        AddEvent(LogImportance.Remark,"Range","Invoke <<" + arg.Name + " value too big>> " + A.Name);
                                        try
                                        {
                                            s.InvokeSync(A.Name,(UPnPArgument[])ArgList.ToArray(typeof(UPnPArgument)));
                                            WARN_RANGE = true;
                                            AddEvent(LogImportance.High,"Range","   Device failed to validate argument");
                                        }
                                        catch(UPnPInvokeException ex)
                                        {
                                            if(ex.UPNP!=null)
                                            {
                                                if(ex.UPNP.ErrorCode<501)
                                                {
                                                    AddEvent(LogImportance.Remark,"Range","   Device SUCCESSFULLY validated argument");

                                                }
                                                else
                                                {
                                                    WARN_RANGE = true;
                                                    AddEvent(LogImportance.High,"Range","   Device returned code: " + ex.UPNP.ErrorCode.ToString() + " but failed to validate argument");
                                                }
                                            }
                                            else
                                            {
                                                FAIL_RANGE = true;
                                                AddEvent(LogImportance.Critical,"Range","   Device returned non SOAP-Encoded Error");
                                            }
                                        }
                                    }
                                }

                            }
                        }
                    }
                }
            }

            (new UPnPDebugObject(s)).SetProperty("ValidationMode",true);
            return true;
        }
        public UPnpArgumentEditControl(ActionEditForm parentform, UPnPAction action, UPnPArgument argument)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.parentform = parentform;
            this.parentaction = action;
            this.arg = argument;

            // Set name
            argNameTextBox.Text = arg.Name;
            //toolTip.SetToolTip(actionNameLabel,"(" + arg.RelatedStateVar.ValueType + ") " + arg.Name);

            // Set input/output
            inputMenuItem.Checked = false;
            outputMenuItem.Checked = false;
            returnMenuItem.Checked = false;

            if (arg.IsReturnValue == true)
            {
                returnMenuItem.Checked = true;
                argDirPictureBox.Image = actionImageList.Images[2];
                toolTip.SetToolTip(argDirPictureBox,"Return argument");
            }
            else
            {
                if (arg.Direction == "in")
                {
                    inputMenuItem.Checked = true;
                    argDirPictureBox.Image = actionImageList.Images[0];
                    toolTip.SetToolTip(argDirPictureBox,"Input argument");
                }
                else
                if (arg.Direction == "out")
                {
                    outputMenuItem.Checked = true;
                    argDirPictureBox.Image = actionImageList.Images[1];
                    toolTip.SetToolTip(argDirPictureBox,"Ouput argument");
                }
                else
                {
                    returnMenuItem.Checked = true;
                    argDirPictureBox.Image = actionImageList.Images[2];
                    toolTip.SetToolTip(argDirPictureBox,"Return argument");
                }
            }

            // Fill state variables
            UPnPStateVariable[] vars = action.ParentService.GetStateVariables();
            bool selitemset = false;
            foreach (UPnPStateVariable var in vars)
            {
                stateVariablesComboBox.Items.Add(var);
                if (arg.RelatedStateVar != null && var.Name == arg.RelatedStateVar.Name)
                {
                    stateVariablesComboBox.SelectedItem = var;
                    selitemset = true;
                }
            }
            if (selitemset == false)
            {
                stateVariablesComboBox.SelectedIndex = 0;
            }
        }
        private void InvokeSink(UPnPAction sender, UPnPArgument[] _Args, out object RetVal, out UPnPArgument[] _OutArgs)
        {
            string DeviceUDN = (string)ReverseUDNTable[sender.ParentService.ParentDevice.UniqueDeviceName];
            string ServiceID = sender.ParentService.ServiceID;

            byte[] InArgs = Gatekeeper.BuildArguments(_Args);
            //byte[] OutArgs;

            ++ActionCounter;
            if (this.OnAction != null) OnAction(this, ActionCounter);

            int Handle = Creator.GetNewHandle();
            Creator.InvokeLaterTable[Handle] = ILCB;
            PendingActionTable[Handle] = sender;
            CP.InvokeAsync(DV, DeviceUDN, ServiceID, sender.Name, InArgs, Handle);

            UPnPArgument[] Args;
            sender.ParentService.DelayInvokeRespose(0, out Args);
            throw (new DelayedResponseException());

            /*
            CP.Sync_Invoke(DeviceUDN,ServiceID,sender.Name,
                InArgs, out OutArgs);

            UPnPArgument[] Outputs = Gatekeeper.ParseArguments(OutArgs);
            ArrayList alist = new ArrayList();
            RetVal = null;

            foreach(UPnPArgument A in Outputs)
            {
                if(A.IsReturnValue)
                {
                    RetVal = A.DataValue;
                }
                else
                {
                    alist.Add(A);
                }
            }

            _OutArgs = (UPnPArgument[])alist.ToArray(typeof(UPnPArgument));
            */
        }
 private ArrayList BasicControlTest_BuildActionArgs(UPnPAction A)
 {
     ArrayList ArgList = new ArrayList();
     foreach(UPnPArgument arg in A.ArgumentList)
     {
         if(arg.IsReturnValue==false)
         {
             UPnPArgument NArg;
     //					if(arg.RelatedStateVar.GetNetType().FullName=="System.String")
     //					{
     //						NArg = new UPnPArgument(arg.Name,"Sample String");
     //					}
     //					else
     //					{
                 NArg = new UPnPArgument(arg.Name,UPnPService.CreateObjectInstance(arg.RelatedStateVar.GetNetType(),null));
     //					}
             if(arg.RelatedStateVar.AllowedStringValues!=null) NArg.DataValue = arg.RelatedStateVar.AllowedStringValues[0];
             if(arg.RelatedStateVar.Minimum!=null) NArg.DataValue = arg.RelatedStateVar.Minimum;
             if(arg.RelatedStateVar.Maximum!=null) NArg.DataValue = arg.RelatedStateVar.Maximum;
             ArgList.Add(NArg);
         }
     }
     return(ArgList);
 }
 /// <summary>
 /// Adds a UPnPAction to this service
 /// </summary>
 /// <param name="action">Action to add</param>
 public void AddMethod(UPnPAction action)
 {
     OpenSource.Utilities.EventLogger.Log(this, System.Diagnostics.EventLogEntryType.SuccessAudit, "Adding Action : " + action.Name);
     if (action.Name == null || action.Name.Length == 0) throw new Exception("Invalid action name");
     action.ParentService = this;
     this.AddAction(action);
 }
        private bool BasicControlTest_ACTION(UPnPService s, UPnPAction A)
        {
            ArrayList ArgList = BasicControlTest_BuildActionArgs(A);
            try
            {
                s.InvokeSync(A.Name,(UPnPArgument[])ArgList.ToArray(typeof(UPnPArgument)));
                AddEvent(LogImportance.Remark,"Valid Values","Invoke: " + A.Name + " << OK >>");
            }
            catch(UPnPInvokeException ex)
            {
                if(ex.UPNP.ErrorCode==401 ||
                    ex.UPNP.ErrorCode==402)
                {
                    // Oh really?
                    WARN_VALID = true;
                    AddEvent(LogImportance.High,"Valid Values",
                        "   Invoke: " + A.Name);
                    AddEvent(LogImportance.High,"Valid Values",
                        "      Cannot return Error Code " + ex.UPNP.ErrorCode.ToString());

                    foreach(UPnPArgument _arg in ex.Arguments)
                    {
                        AddEvent(LogImportance.High,"Valid Values",
                            "         " + _arg.Name + ": " + UPnPService.SerializeObjectInstance(_arg.DataValue));
                    }
                }
                else
                {
                    // Fine, I suppose
                    AddEvent(LogImportance.Remark,"Valid Values",
                        "Invoke: " + A.Name + " << " + ex.UPNP.ErrorCode + " " + ex.UPNP.ErrorDescription + "  OK >>");
                }
            }
            return true;
        }