public string Process(Bot bot) { if(_iterator == null) _iterator = Run(bot); bool hasElements = false; try { hasElements = _iterator.MoveNext(); } catch(InvalidOperationException e) { hasElements = false; _reason = "InvalidOperationException?"; } if(hasElements) return _iterator.Current; else { _finished = true; return String.Format("{0} exit: {1}", this.GetType().Name, _reason); } }
private static void LoadCombos(Bot bot, string XMLFilename) { var xmldoc = new XmlDocument(); xmldoc.Load(XMLFilename); foreach (XmlNode comboXml in xmldoc.DocumentElement.SelectNodes("//Combo")) { var combo = new Combo(); ComboType tmp = 0; string stInput = ""; if (comboXml.ParentNode.LocalName == "Starter") { foreach (XmlAttribute attr in comboXml.ParentNode.Attributes) { PropertyInfo propertyInfo = combo.GetType().GetProperty(attr.Name); if (propertyInfo.PropertyType.IsEnum) propertyInfo.SetValue(combo, Enum.Parse(typeof(ComboType), attr.Value)); else propertyInfo.SetValue(combo, Convert.ChangeType(attr.Value, propertyInfo.PropertyType), null); } tmp = combo.Type; stInput = combo.Input; } foreach(XmlAttribute attr in comboXml.Attributes) { PropertyInfo propertyInfo = combo.GetType().GetProperty(attr.Name); if(propertyInfo.PropertyType.IsEnum) propertyInfo.SetValue(combo, Enum.Parse(typeof(ComboType), attr.Value)); else propertyInfo.SetValue(combo, Convert.ChangeType(attr.Value, propertyInfo.PropertyType), null); } combo.Type = combo.Type | tmp; if(stInput != "") combo.Input = stInput + "."+combo.Input; bot.getComboList().Add(combo); } }
private void BotSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) { StatusLabel.Content = "Loading " + (string)BotSelector.SelectedValue +"..."; //try { bot = BotLoader.LoadBotFromFile((string)BotSelector.SelectedValue); bot.Init(P1CheckBox.IsChecked.Value ? 0 : 1); BotSelector.Items.Refresh(); RefreshBotData(); } //catch(Exception err) { //StatusLabel.Content = err.ToString(); //throw err; } }
public virtual IEnumerator<string> Run(Bot bot) { while(true) yield return this.GetType().Name; }