TrackingProfileSerializer 类

定义

注意

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

提供通过使用跟踪配置文件 XML 架构定义 (XSD) 将跟踪配置文件序列化为 XML 文档或从 XML 文档反序列化跟踪配置文件的方法。

public ref class TrackingProfileSerializer
public class TrackingProfileSerializer
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class TrackingProfileSerializer
type TrackingProfileSerializer = class
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type TrackingProfileSerializer = class
Public Class TrackingProfileSerializer
继承
TrackingProfileSerializer
属性

示例

下面的代码示例演示如何使用 TrackingProfileSerializer 构造函数创建 TrackingProfileSerializer,以便序列化 TrackingProfile。 代码还使用 Serialize 方法。

此代码示例摘自 Program.cs 文件中的“使用 SQLTrackingService 查询”SDK 示例。 有关详细信息,请参阅 使用 SQLTrackingService 进行查询

private static void CreateAndInsertTrackingProfile()
{
    TrackingProfile profile = new TrackingProfile();
    ActivityTrackPoint activityTrack = new ActivityTrackPoint();
    ActivityTrackingLocation activityLocation = new ActivityTrackingLocation(typeof(Activity));
    activityLocation.MatchDerivedTypes = true;
    IEnumerable<ActivityExecutionStatus> statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable<ActivityExecutionStatus>;
    foreach (ActivityExecutionStatus status in statuses)
    {
        activityLocation.ExecutionStatusEvents.Add(status);
    }

    activityTrack.MatchingLocations.Add(activityLocation);
    profile.ActivityTrackPoints.Add(activityTrack);
    profile.Version = version;

    WorkflowTrackPoint workflowTrack = new WorkflowTrackPoint();
    WorkflowTrackingLocation workflowLocation = new WorkflowTrackingLocation();
    IEnumerable<TrackingWorkflowEvent> eventStatuses = Enum.GetValues(typeof(TrackingWorkflowEvent)) as IEnumerable<TrackingWorkflowEvent>;
    foreach (TrackingWorkflowEvent status in eventStatuses)
    {
        workflowLocation.Events.Add(status);
    }

    workflowTrack.MatchingLocation = workflowLocation;
    profile.WorkflowTrackPoints.Add(workflowTrack);

    TrackingProfileSerializer serializer = new TrackingProfileSerializer();
    StringWriter writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
    serializer.Serialize(writer, profile);
    string trackingprofile = writer.ToString();
    InsertTrackingProfile(trackingprofile);
}
Shared Sub CreateAndInsertTrackingProfile()
    Dim profile As TrackingProfile = New TrackingProfile()

    Dim activityTrack As ActivityTrackPoint = New ActivityTrackPoint()
    Dim activityLocation As ActivityTrackingLocation = New ActivityTrackingLocation(GetType(Activity))
    activityLocation.MatchDerivedTypes = True
    Dim statuses As IEnumerable(Of ActivityExecutionStatus) = CType(System.Enum.GetValues(GetType(ActivityExecutionStatus)), IEnumerable(Of ActivityExecutionStatus))
    For Each status As ActivityExecutionStatus In statuses
        activityLocation.ExecutionStatusEvents.Add(status)
    Next

    activityTrack.MatchingLocations.Add(activityLocation)
    profile.ActivityTrackPoints.Add(activityTrack)
    profile.Version = version

    Dim workflowTrack As WorkflowTrackPoint = New WorkflowTrackPoint()
    Dim workflowLocation As WorkflowTrackingLocation = New WorkflowTrackingLocation()
    Dim eventStatuses As IEnumerable(Of TrackingWorkflowEvent) = CType(System.Enum.GetValues(GetType(TrackingWorkflowEvent)), IEnumerable(Of TrackingWorkflowEvent))
    For Each status As TrackingWorkflowEvent In eventStatuses
        workflowLocation.Events.Add(status)
    Next

    workflowTrack.MatchingLocation = workflowLocation
    profile.WorkflowTrackPoints.Add(workflowTrack)

    Dim serializer As TrackingProfileSerializer = New TrackingProfileSerializer()
    Dim writer As StringWriter = New StringWriter(New StringBuilder(), CultureInfo.InvariantCulture)
    serializer.Serialize(writer, profile)
    Dim trackingProfile As String = writer.ToString()
    InsertTrackingProfile(trackingProfile)
End Sub

注解

注意

本材料讨论的类型和命名空间已废弃不用。 有关详细信息,请参阅 Windows Workflow Foundation 4.5 中弃用的类型

TrackingProfileSerializer 使用 TrackingProfileSerializer.Schema 中包含的跟踪配置文件 XSD 将 TrackingProfile 对象序列化为有效的 XML 文档,并将有效的 XML 文档反序列化为 TrackingProfile 对象。 TrackingProfileSerializer 在序列化和反序列化过程中执行验证,并在必要时引发适当的异常。

XML 文档提供了一种用于存储跟踪配置文件的方便格式。 它还提供了一种编写跟踪配置文件的非编程方式。 现成可用的 SqlTrackingService 使用 TrackingProfileSerializer 来序列化和反序列化存储在其数据库中的跟踪配置文件。

构造函数

TrackingProfileSerializer()
已过时.

初始化 TrackingProfileSerializer 类的新实例。

属性

Schema
已过时.

获取跟踪配置文件 XML 架构定义 (XSD)。

方法

Deserialize(TextReader)
已过时.

通过使用跟踪配置文件 XML 架构定义 (XSD) 反序列化包含在文本阅读器中的 XML 文档。

Equals(Object)
已过时.

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()
已过时.

作为默认哈希函数。

(继承自 Object)
GetType()
已过时.

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()
已过时.

创建当前 Object 的浅表副本。

(继承自 Object)
Serialize(TextWriter, TrackingProfile)
已过时.

通过使用跟踪配置文件 XML 架构定义 (XSD) 将跟踪配置文件序列化为 XML 文档。

ToString()
已过时.

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅