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

定義

主機會叫用這個方法,並將 InstanceData 集合 (由 LoadWorkflowCommandLoadWorkflowByInstanceKeyCommand 填入) 中載入的所有值當做字典參數傳遞。

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;
        }
    }
}

適用於