Example #1
0
        public static TrackableRingTrackerSurrogate Convert(TrackablePocoTracker <IRing> tracker)
        {
            if (tracker == null)
            {
                return(null);
            }

            var surrogate = new TrackableRingTrackerSurrogate();

            foreach (var changeItem in tracker.ChangeMap)
            {
                switch (changeItem.Key.Name)
                {
                case "Name":
                    surrogate.Name = new EnvelopedObject <string> {
                        Value = (string)changeItem.Value.NewValue
                    };
                    break;

                case "Power":
                    surrogate.Power = new EnvelopedObject <int> {
                        Value = (int)changeItem.Value.NewValue
                    };
                    break;
                }
            }

            return(surrogate);
        }
Example #2
0
        public static TrackablePocoTracker <IRing> Convert(TrackableRingTrackerSurrogate surrogate)
        {
            if (surrogate == null)
            {
                return(null);
            }

            var tracker = new TrackablePocoTracker <IRing>();

            if (surrogate.Name != null)
            {
                tracker.ChangeMap.Add(TrackableRing.PropertyTable.Name, new TrackablePocoTracker <IRing> .Change {
                    NewValue = surrogate.Name.Value
                });
            }
            if (surrogate.Power != null)
            {
                tracker.ChangeMap.Add(TrackableRing.PropertyTable.Power, new TrackablePocoTracker <IRing> .Change {
                    NewValue = surrogate.Power.Value
                });
            }
            return(tracker);
        }