WorkflowDesignerLoader.SaveDesignerLayout 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將設計工具配置序列化。
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)
參數
- 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);
}
}
}
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