語言

PersistenceParticipant.PublishValues(IDictionary<XName,Object>) 方法

定義

主機會呼叫此方法,並將集合中 InstanceData 所有載入的值(由 LoadWorkflowCommand 或 LoadWorkflowByInstanceKeyCommand填充)作為字典參數傳遞。

protected:
 virtual void PublishValues(System::Collections::Generic::IDictionary<System::Xml::Linq::XName ^, System::Object ^> ^ readWriteValues);
protected virtual void PublishValues(System.Collections.Generic.IDictionary<System.Xml.Linq.XName,object> readWriteValues);
abstract member PublishValues : System.Collections.Generic.IDictionary<System.Xml.Linq.XName, obj> -> unit
override this.PublishValues : System.Collections.Generic.IDictionary<System.Xml.Linq.XName, obj> -> unit
Protected Overridable Sub PublishValues (readWriteValues As IDictionary(Of XName, Object))

參數

readWriteValues
IDictionary<XName,Object>

從持久儲存庫載入的讀寫值。 此字典對應於最近一次持久化事件中持續存在的讀寫值字典。

範例

以下程式碼範例示範在由 衍生 PersistenceParticipant的類別中使用 PublishValues。 此範例來自 持久性參與者 樣本。

public class StepCountExtension : PersistenceParticipant
{
    static XNamespace stepCountNamespace = XNamespace.Get("urn:schemas-microsoft-com:Microsoft.Samples.WF/WorkflowInstances/properties");
    static XName currentCountName = stepCountNamespace.GetName("CurrentCount");

    int currentCount;

    public int CurrentCount
    {
        get
        {
            return this.currentCount;
        }
    }

    internal void IncrementStepCount()
    {
        this.currentCount += 1;
    }

    protected override void CollectValues(out IDictionary<XName, object> readWriteValues, out IDictionary<XName, object> writeOnlyValues)
    {
        readWriteValues = new Dictionary<XName, object>(1) { { currentCountName, this.currentCount } };
        writeOnlyValues = null;
    }

    protected override void PublishValues(IDictionary<XName, object> readWriteValues)
    {
        object loadedData;
        if (readWriteValues.TryGetValue(currentCountName, out loadedData))
        {
            this.currentCount = (int)loadedData;
        }
    }
}

適用於