Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        public void Write(XElement root)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }
            var listRoot = new XElement(m_name);

            foreach (TValue t in m_data)
            {
                var element = new XElement("Element");
                ConfigParameter <TValue> param = m_nodeFactory();
                param.Value = t;
                param.Write(element);
                listRoot.Add(element);
            }
            root.Add(listRoot);
        }
Ejemplo n.º 3
0
 public DataSourceController(ConfigParameter <List <string> > config)
 {
     m_config = config;
     LoadFromXml(m_config.Value);
 }