Exemple #1
0
        public void ParseEngineOptionLines(string [] optionLines)
        {
            foreach (string optionLine in optionLines)
            {
                try
                {
                    string[] split = optionLine.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    string key   = split[0];
                    string type  = split[1];
                    string value = split[2];

                    EngineOption eo;

                    switch (type)
                    {
                    case "bool":
                        BooleanEngineOption beo = new BooleanEngineOption();
                        beo.Value = bool.Parse(value);
                        eo        = beo;
                        break;

                    case "int":
                        IntegerEngineOption ieo = new IntegerEngineOption();
                        ieo.Value = int.Parse(value);
                        if (split.Length >= 5)
                        {
                            ieo.MinValue = int.Parse(split[3]);
                            ieo.MaxValue = int.Parse(split[4]);
                        }
                        eo = ieo;
                        break;

                    case "double":
                        DoubleEngineOption deo = new DoubleEngineOption();
                        deo.Value = double.Parse(value);
                        if (split.Length >= 5)
                        {
                            deo.MinValue = double.Parse(split[3]);
                            deo.MaxValue = double.Parse(split[4]);
                        }
                        eo = deo;
                        break;

                    case "enum":
                        EnumEngineOption eeo = new EnumEngineOption();
                        eeo.Value  = value;
                        eeo.Values = new string[split.Length - 3];
                        Array.Copy(split, 3, eeo.Values, 0, eeo.Values.Length);
                        eo = eeo;
                        break;

                    default:
                        throw new Exception(string.Format("Unknown type \"{0}\"", type));
                    }

                    eo.Key = key;

                    _options[key] = eo;
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Unable to parse option line {0}", optionLine), ex);
                }
            }
        }
 public ObservableDoubleEngineOption(DoubleEngineOption option) : base(option)
 {
     _value   = option.Value;
     MinValue = option.MinValue;
     MaxValue = option.MaxValue;
 }