WorkflowDesignerLoader.SaveDesignerLayout 方法

定義

將設計工具配置序列化。

protected void SaveDesignerLayout (System.Xml.XmlWriter layoutWriter, System.Workflow.ComponentModel.Design.ActivityDesigner rootDesigner, out System.Collections.IList layoutSaveErrors);

參數

layoutWriter
XmlWriter

用來序列化配置的 XmlWriter

rootDesigner
ActivityDesigner

從中取得配置資訊的根活動。

layoutSaveErrors
IList

序列化期間遇到的錯誤。

範例

下列範例示範如何使用 SaveDesignerLayout 方法儲存工作流程的設計配置資訊。 XmlWriter建立 物件之後, ActivityDesignerRootComponent 會擷取工作流程的 ,並傳遞至 SaveDesignerLayout 方法。 若要載入由這個方法產生的配置檔案,請參閱 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);
        }
    }
}

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1