/// <summary>
        /// Registers (creates) a new task in the folder using XML to define the task.
        /// </summary>
        /// <param name="Path">The task name. If this value is NULL, the task will be registered in the root task folder and the task name will be a GUID value that is created by the Task Scheduler service. A task name cannot begin or end with a space character. The '.' character cannot be used to specify the current task folder and the '..' characters cannot be used to specify the parent task folder in the path.</param>
        /// <param name="XmlText">An XML-formatted definition of the task.</param>
        /// <param name="createType">A union of <see cref="TaskCreation"/> flags.</param>
        /// <param name="UserId">The user credentials used to register the task.</param>
        /// <param name="password">The password for the userId used to register the task.</param>
        /// <param name="LogonType">A <see cref="TaskLogonType"/> value that defines what logon technique is used to run the registered task.</param>
        /// <param name="sddl">The security descriptor associated with the registered task. You can specify the access control list (ACL) in the security descriptor for a task in order to allow or deny certain users and groups access to a task.</param>
        /// <returns>A <see cref="Task"/> instance that represents the new task.</returns>
        public Task RegisterTask(string Path, string XmlText, TaskCreation createType = TaskCreation.CreateOrUpdate, string UserId = null, string password = null, TaskLogonType LogonType = TaskLogonType.S4U, string sddl = null)
        {
            if (v2Folder != null)
            {
                return(Task.CreateTask(this.TaskService, v2Folder.RegisterTask(Path, XmlText, (int)createType, UserId, password, LogonType, sddl)));
            }

            try
            {
                TaskDefinition td = this.TaskService.NewTask();
                XmlSerializationHelper.ReadObjectFromXmlText(XmlText, td);
                return(this.RegisterTaskDefinition(Path, td, createType, UserId == null ? td.Principal.ToString() : UserId,
                                                   password, LogonType == TaskLogonType.S4U ? td.Principal.LogonType : LogonType, sddl));
            }
            catch
            {
                throw;                 // new NotV1SupportedException();
            }
        }
        void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement("Actions", TaskDefinition.tns);
            while (reader.MoveToContent() == System.Xml.XmlNodeType.Element)
            {
                Action newAction = null;
                switch (reader.LocalName)
                {
                case "Exec":
                    newAction = this.AddNew(TaskActionType.Execute);
                    break;

                default:
                    reader.Skip();
                    break;
                }
                if (newAction != null)
                {
                    XmlSerializationHelper.ReadObject(reader, newAction);
                }
            }
            reader.ReadEndElement();
        }