private string ExtractText(ComboBoxTemplate selectedOption) { string jsonString = ""; var readerType = (ReaderType)selectedOption.Value; var sourceTextReader = SourceReaderFactory.GetAppropriateReader(readerType); switch (selectedOption.Value) { case 3 when !string.IsNullOrEmpty(txtFileName.Text): jsonString = sourceTextReader.GetTextFromSource(txtFileName.Text); break; case 2 when dgTexts.SelectedItem != null: { var selectedDataGriItem = dgTexts.SelectedItem as SavedText; jsonString = _savedTextRepository.GetById(selectedDataGriItem.Id).TextValue; break; } case 1 when !string.IsNullOrEmpty(txtUserInput.Text): jsonString = txtUserInput.Text; break; } return(jsonString); }
/// <summary> /// Constructor without using the default factory /// </summary> /// <param name="factory">Factory to build the default scope</param> public Engine(IScopeFactory factory) { if (factory == null) { factory = new ScopeFactory(); } ReaderFactory = new SourceReaderFactory(); ScriptFactory = new DefaultLanguageScriptFactory(); DefaultScope = factory.MakeScope(); }