コード例 #1
0
        public void AddRegistration(Registration registration)
        {
            lock(_lock)
            {
                XDocument doc = GetOrCreateDocument();

                var registrationsNode = doc.Element("Registrations");
                registrationsNode.Add(new XElement("Registration",
                    new XAttribute("NotificationChannel", registration.NotificationChannel),
                    new XAttribute("UniqueId", registration.UniqueId)));

                SaveDocument(doc);
            }
        }
コード例 #2
0
        public void UpdateRegistration(Registration registration)
        {
            lock (_lock)
            {
                var doc = GetOrCreateDocument();
                var registrationsNode = doc.Element("Registrations");
                var node = (from reg in registrationsNode.Elements("Registration")
                            where reg.Attribute("UniqueId").Value == registration.UniqueId
                            select reg).FirstOrDefault();

                if (node != null)
                {
                    node.Attribute("NotificationChannel").Value = registration.NotificationChannel;
                }
                else
                {
                    registrationsNode.Add(new XElement("Registration",
                        new XAttribute("NotificationChannel", registration.NotificationChannel),
                        new XAttribute("UniqueId", registration.UniqueId)));
                }
                SaveDocument(doc);
            }
        }