Beispiel #1
0
        public static List <Rule> ParseRules(List <string> rulesStrings, List <Symbol> possibleSymbols)
        {
            var rules = new List <Rule>();

            foreach (var ruleString in rulesStrings)
            {
                var ruleStringSplit = ruleString.Split(new[] { "->" }, StringSplitOptions.RemoveEmptyEntries);

                var leftSideSymbol   = new NonTerminalSymbol(ruleStringSplit[0]);
                var rightSideSymbols = SymbolParser.ParseSymbols(ruleStringSplit[1], possibleSymbols);

                var rule = new Rule(leftSideSymbol, rightSideSymbols);
                rules.Add(rule);
            }

            return(rules);
        }
        public void ApplyEditorsToDataSourceAndClose()
        {
            if (this.txtDataSourceName.Text == "")
            {
                MessageBox.Show("Please provide Name for this new DataSet");
                this.txtDataSourceName.Focus();
                return;
            }
//			DataSource foundSameName = this.assemblerInstance.RepositoryJsonDataSource.DataSourceFind(this.txtDataSourceName.Text);
//			if (foundSameName != null) {
//				string msg = "DataSource[" + this.txtDataSourceName.Text + "] existed before; Overwrite?";
//				DialogResult dialogResult = MessageBox.Show(msg, "DataSource [" + this.txtDataSourceName.Text + "] already exists", MessageBoxButtons.YesNoCancel);
//				switch (dialogResult) {
//					case System.Windows.Forms.DialogResult.Cancel:
//					case DialogResult.No:
//						this.txtDataSourceName.SelectAll();
//						this.txtDataSourceName.Focus();
//						return;
//					case DialogResult.Yes:
//						this.assemblerInstance.RepositoryJsonDataSource.SerializeSingle(ds);
//						base.DialogResult = System.Windows.Forms.DialogResult.OK;
//						return;
//				}
//			}

            ds.Name    = this.txtDataSourceName.Text;
            ds.Symbols = SymbolParser.ParseSymbols(this.txtSymbols.Text);
            if (ds.StreamingProvider != null)
            {
                ds.StreamingProvider.EditorInstance.PushEditedSettingsToStreamingProvider();
            }
            if (ds.BrokerProvider != null)
            {
                ds.BrokerProvider.EditorInstance.PushEditedSettingsToBrokerProvider();
            }
            // for DataSource, nothing changed, but providers were assigned by user clicks, so DS will Initialize() each
            ds.Initialize(this.assemblerInstance.RepositoryJsonDataSource.AbsPath, this.assemblerInstance.OrderProcessor, this.assemblerInstance.StatusReporter);
            this.assemblerInstance.RepositoryJsonDataSource.SerializeSingle(ds);
            base.Hide();
        }