Edit

Share via


WorkflowDesignerLoader.SaveDesignerLayout Method

Definition

Serializes the designer layout.

protected:
 void SaveDesignerLayout(System::Xml::XmlWriter ^ layoutWriter, System::Workflow::ComponentModel::Design::ActivityDesigner ^ rootDesigner, [Runtime::InteropServices::Out] System::Collections::IList ^ % layoutSaveErrors);
protected void SaveDesignerLayout (System.Xml.XmlWriter layoutWriter, System.Workflow.ComponentModel.Design.ActivityDesigner rootDesigner, out System.Collections.IList layoutSaveErrors);
member this.SaveDesignerLayout : System.Xml.XmlWriter * System.Workflow.ComponentModel.Design.ActivityDesigner * IList -> unit
Protected Sub SaveDesignerLayout (layoutWriter As XmlWriter, rootDesigner As ActivityDesigner, ByRef layoutSaveErrors As IList)

Parameters

layoutWriter
XmlWriter

XmlWriter that is used to serialize the layout into.

rootDesigner
ActivityDesigner

Root activity from which you get the layout information.

layoutSaveErrors
IList

Errors encountered during serialization.

Examples

The following example demonstrates how to save the design layout information of a workflow using the SaveDesignerLayout method. After the XmlWriter object is created, the ActivityDesigner for the RootComponent of the workflow is retrieved and passed to the SaveDesignerLayout method. To load the layout file that is generated by this method, see LoadDesignerLayout.

public void SaveLayout()
{
    using (XmlWriter writer = XmlWriter.Create("wfInstanceId.designer.xml"))
    {
        IList layoutSaveErrors = new ArrayList() as IList;
        IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
        ActivityDesigner rootDesigner = host.GetDesigner(host.RootComponent) as ActivityDesigner;
        this.SaveDesignerLayout(writer, rootDesigner, out layoutSaveErrors);

        if (layoutSaveErrors.Count > 0)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder("Errors:\r\n");
            foreach (WorkflowMarkupSerializationException error in layoutSaveErrors)
            {
                sb.Append(error.Message + "\r\n");
            }
            MessageBox.Show(sb.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}
Public Sub SaveLayout()
    Using writer As XmlWriter = XmlWriter.Create("wfInstanceId.designer.xml")
        Dim layoutSaveErrors As IList = CType(New ArrayList(), IList)

        Dim host As IDesignerHost = CType(GetService(GetType(IDesignerHost)), IDesignerHost)
        Dim rootDesigner As ActivityDesigner = CType(host.GetDesigner(host.RootComponent), ActivityDesigner)
        Me.SaveDesignerLayout(writer, rootDesigner, layoutSaveErrors)

        If layoutSaveErrors.Count > 0 Then
            Dim sb As New System.Text.StringBuilder("Errors:\r\n")
            For Each errorMessage As WorkflowMarkupSerializationException In layoutSaveErrors
                sb.Append(errorMessage.Message + "\r\n")
            Next
            MessageBox.Show(sb.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Using
End Sub

Applies to