public SPWorkflowAssociationInstance ImportFromXml(SPWebInstance rootWeb, string xml)
        {
            if (rootWeb == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A web must be supplied as the first argument.");
            }

            var result = SPWorkflowAssociation.ImportFromXml(rootWeb.Web, xml);

            return(result == null
                ? null
                : new SPWorkflowAssociationInstance(this.Engine.Object.InstancePrototype, result));
        }
        /// <summary>
        /// Adds the workflow associations.
        /// </summary>
        /// <param name="targetCT">The target content type.</param>
        /// <param name="sourceCT">The source content type.</param>
        private void AddWorkflowAssociations(SPContentType targetCT, SPContentType sourceCT)
        {
            // Remove the default workflows - we're going to add from the source.
            while (targetCT.WorkflowAssociations.Count > 0)
            {
                targetCT.WorkflowAssociations.Remove(targetCT.WorkflowAssociations[0]);
            }

            // Add workflows.
            foreach (SPWorkflowAssociation wf in sourceCT.WorkflowAssociations)
            {
                Logger.Write("Progress: Adding workflow '{0}' to content type...", wf.Name);
                targetCT.WorkflowAssociations.Add(SPWorkflowAssociation.ImportFromXml(targetCT.ParentWeb.Site.RootWeb, wf.ExportToXml()));
            }
            targetCT.Update();
        }