TrackingProfileSerializer 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
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) |