/[cits3200i]/branches/metadata-branch-rvvs89/UWAPlugins/MetadataPlugin/Source/MetadataList.cs


UCC Code Repository

Contents of /branches/metadata-branch-rvvs89/UWAPlugins/MetadataPlugin/Source/MetadataList.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 87 - (show annotations) (download)
Mon Oct 11 21:19:18 2010 UTC (11 years, 1 month ago) by rvvs89
File size: 1320 byte(s)
Serializing a MetadataList to route extension data is now working.
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.IO;
5 using System.Runtime.Serialization;
6 using ZoneFiveSoftware.Common.Data.Fitness;
7
8 namespace MetadataPlugin.Source
9 {
10 [Serializable]
11 class MetadataList : IDeserializationCallback
12 {
13 private IList<IMetadata> items = new List<IMetadata>();
14 [NonSerialized]
15 private IActivity activity;
16
17 public IActivity Activity
18 {
19 set { activity = value; }
20 }
21
22 public void Commit()
23 {
24 // TODO: create some triggers for this function
25 if (activity == null)
26 return;
27 activity.SetExtensionData(Plugin.Instance.Id, MetadataListSerializer.Serialize(this));
28 }
29
30 public void OnDeserialization(object sender)
31 {
32 activity = null;
33 }
34
35 public static MetadataList LoadFromActivity(IActivity activity)
36 {
37 if (activity == null)
38 return null;
39 MetadataList ret = MetadataListSerializer.Deserialize(activity.GetExtensionData(Plugin.Instance.Id));
40 if (ret == null)
41 ret = new MetadataList();
42 ret.Activity = activity;
43 return ret;
44 }
45 }
46 }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26