Exemplo n.º 1
0
        internal static VariableDescriptor FromXml(XElement xml)
        {
            var returnVal = new VariableDescriptor();

            returnVal.Name  = xml.Attribute("Name")?.Value;
            returnVal.Type  = xml.SafeExtractAttributeValue("Type", i => (VariableType)int.Parse(i));
            returnVal.Value = xml.Attribute("Value")?.Value;

            return(returnVal);
        }
Exemplo n.º 2
0
        private void OpenCommandHandler()
        {
            var openDialog = new OpenFileDialog
            {
                Filter      = "Expressive Playground (.expl)|*.expl",
                Multiselect = false,
            };

            if (openDialog.ShowDialog() == true)
            {
                var xmlConfig = XElement.Load(openDialog.FileName);

                this.textEditor.Text = xmlConfig.Element("Expression")?.Value;
                var variables = xmlConfig.Element("Variables").Elements().Select(e => VariableDescriptor.FromXml(e));

                foreach (var v in variables)
                {
                    this.Variables.Add(v);
                }
            }
        }