public void Load(XElement root) { if (root == null) { throw new ArgumentNullException(nameof(root)); } if (m_suppressibleValueChanged.Suppressed) { throw new InternalLogicException("Can't load config while there are unsaved changes to config"); } using (SuppressCallback()) //The following block will modify the data but during a load that shouldn't trigger ValueChanged { var a = root.Element(m_name); m_data.Clear(); if (a != null) { foreach (var node in a.Elements("Element")) { ConfigParameter <TValue> t = m_nodeFactory(); t.Load(node); m_data.Add(t.Value); } } m_suppressibleValueChanged.Dispose(); //Pretend we haven't changed anything, by destroying the old callback and making a new one } m_suppressibleValueChanged = new SuppressibleAction(() => ValueChanged.Execute()); }
protected override void Dispose(bool disposing) { m_valueChanged.Dispose(); m_valueChanged = null; }