WorkflowDesignerLoader.Flush 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將暫止的變更寫入至載入設計工具的來源位置。
public:
override void Flush();
public override void Flush ();
override this.Flush : unit -> unit
Public Overrides Sub Flush ()
範例
下列範例示範如何使用 Flush 覆寫 WorkflowMarkupSerializer 方法,將工作流程序列化。 在此範例中,覆寫的 Flush 會委派 (Delegate) 至 PerformFlush 衍生類別中定義的 WorkflowDesignerLoader 方法。
public override void Flush()
{
this.PerformFlush(null);
}
protected override void PerformFlush(IDesignerSerializationManager manager)
{
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
if (host != null && host.RootComponent != null)
{
Activity service = host.RootComponent as Activity;
if (service != null)
{
using (XmlWriter writer = XmlWriter.Create(this.xomlFile))
{
WorkflowMarkupSerializer xomlSerializer = new WorkflowMarkupSerializer();
if (manager == null)
{
xomlSerializer.Serialize(writer, service);
}
else
{
xomlSerializer.Serialize(manager, writer, service);
}
}
}
}
}
Public Overrides Sub Flush()
Me.PerformFlush(Nothing)
End Sub
Protected Overrides Sub PerformFlush(ByVal manager As IDesignerSerializationManager)
Dim host As IDesignerHost = CType(GetService(GetType(IDesignerHost)), IDesignerHost)
If host IsNot Nothing And host.RootComponent IsNot Nothing Then
Dim service As Activity = CType(host.RootComponent, Activity)
If service IsNot Nothing Then
Using writer As XmlWriter = XmlWriter.Create(Me.XomlFile)
Dim xomlSerializer As New WorkflowMarkupSerializer()
If manager IsNot Nothing Then
xomlSerializer.Serialize(writer, service)
Else
xomlSerializer.Serialize(manager, writer, service)
End If
End Using
End If
End If
End Sub