public void WriteXml(XmlWriter writer)
        {
            var pm = new PersistentMessage
            {
                ID = Id,
                VisibleTimeExtent = VisibleTimeExtent,
                PropertyItems     = this.Select(kvp => new PropertyItem {
                    Key = kvp.Key, Value = kvp.Value
                }).ToList(),
                PhaseControlPoints =
                    PhaseControlPointsDictionary.Select(kvp => new PropertyItem {
                    Key = kvp.Key, Value = kvp.Value
                })
                    .ToList()
            };

            // get properties in property list


            XmlSerializer serializer = new XmlSerializer(typeof(PersistentMessage));

            serializer.Serialize(writer, pm);
        }
        private void ProcessMission()
        {
            if (_mission == null || _mission.PhaseList.Count < 1)
            {
                return;
            }

            CurrentPhase = _mission.PhaseList[CurrentPhaseIndex];

            // ok, we have a mission with at least 1 phase
            int currentStartPhase = 0;
            int currentEndPhase = 0;

            foreach (var mm in _mission.MilitaryMessages)
            {
                currentStartPhase = 0;
                currentEndPhase = -1;

                foreach (var phase in _mission.PhaseList)
                {
                    if (mm.VisibleTimeExtent.Intersects(phase.VisibleTimeExtent))
                    {
                        currentEndPhase = _mission.PhaseList.IndexOf(phase);
                    }
                    else
                    {
                        //if (_mission.PhaseList.IndexOf(phase) <= currentEndPhase)
                        if (currentEndPhase < 0)
                        {
                            //currentStartPhase = _mission.PhaseList.IndexOf(phase);
                            currentStartPhase++;
                        }
                    }
                }

                var pm = new PersistentMessage() { ID = mm.Id, VisibleTimeExtent = mm.VisibleTimeExtent};

                var piList = new List<PropertyItem>();

                foreach (var item in mm)
                {
                    piList.Add(new PropertyItem() { Key = item.Key, Value = item.Value });
                }

                pm.PropertyItems = piList;

                CreateUpdateSymbolWithPM(pm, currentStartPhase, currentEndPhase);
            }
        }
        private void CreateUpdateSymbolWithPM(PersistentMessage pm, int currentStartPhase, int currentEndPhase)
        {
            // is this an update or a new symbol
            var foundSymbol = _phaseSymbols.FirstOrDefault(sl => sl.ItemSVM.Model.Values.ContainsKey(Message.IdPropertyName) && sl.ItemSVM.Model.Values[Message.IdPropertyName] == pm.ID);

            //if (foundSymbol != null && foundSymbol.Any())
            if(foundSymbol != null)
            {
                // symbol is in list, do an update
                var ps = foundSymbol;//.ElementAt(0);

                ps.EndPhase = currentEndPhase;
            }
            else
            {
                // symbol is missing, ADD a new one
                PropertyItem first = pm.PropertyItems.FirstOrDefault(pi => pi.Key == "sic");

                if (first != null)
                {
                    var psvm = new PhaseSymbolViewModel
                    {
                        StartPhase = currentStartPhase,
                        EndPhase = currentEndPhase,
                        ItemSVM = SymbolLoader.Search(first.Value),
                        VisibleTimeExtent = pm.VisibleTimeExtent
                    };

                    // create SVM
                    if (!psvm.ItemSVM.Model.Values.ContainsKey(Message.IdPropertyName))
                    {
                        psvm.ItemSVM.Model.Values.Add(Message.IdPropertyName, pm.ID);
                    }

                    _phaseSymbols.Add(psvm);
                }
            }
        }
        public void WriteXml(XmlWriter writer)
        {
            var pm = new PersistentMessage
            {
                ID = Id,
                VisibleTimeExtent = VisibleTimeExtent,
                PropertyItems = this.Select(kvp => new PropertyItem {Key = kvp.Key, Value = kvp.Value}).ToList(),
                PhaseControlPoints =
                    PhaseControlPointsDictionary.Select(kvp => new PropertyItem {Key = kvp.Key, Value = kvp.Value})
                        .ToList()
            };

            // get properties in property list

            XmlSerializer serializer = new XmlSerializer(typeof(PersistentMessage));
            serializer.Serialize(writer, pm);
        }