public void SetUp() { _parser = new FakeParser(); _logger = new FakeLogger(); _fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>()); _directory = new MockDirectoryInfo(_fileSystem, @"C:\databasename"); _service = new FileSystemScriptRepository(_directory, "servername", databaseName, _fileSystem, _parser, _logger, true); }
private void EventHandler_New(object sender, System.EventArgs e) { try { TreeNode node = gscriptTreeView.SelectedNode; if (node != null) { ScriptTreeNodeProperty prop = (ScriptTreeNodeProperty)node.Tag; if (prop != null) { ScriptType type; if (prop.Type == ScriptTreeNodeType.G || prop.Type == ScriptTreeNodeType.GRoot) { type = ScriptType.G; } else { type = ScriptType.Simple; } string name = StringInputBox.GetInputString(Resources.TEXT_INPUTNAME, Resources.TEXT_INPUTNAME_TITLE, SunnyChen.Common.RegularExpressions.RegularExpressionSet.IDENTIFIER); if (name.Trim().Equals(string.Empty)) { return; } string fileName = FileSystemScriptRepository.GetScriptFileName(name, type); if (File.Exists(fileName)) { MessageBox.Show(Resources.TEXT_SCRIPT_ALREADY_EXISTS, Resources.TEXT_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } frmCodeEditor codeEditor = new frmCodeEditor(parent__, compiler__, configReader__); codeEditor.CreateNewCode(name, fileName, type); codeEditor.Show(); toolbarsManager.Tools["mnuDelete"].SharedProps.Enabled = false; toolbarsManager.Tools["mnuRun"].SharedProps.Enabled = false; toolbarsManager.Tools["mnuCompile"].SharedProps.Enabled = false; } } } catch { } }
/// <summary> /// Loads the script code into code editor. /// </summary> /// <param name="_name">Name of the script.</param> /// <param name="_scriptType">Type of the script.</param> /// <param name="_openReadOnly">Determines if the script should be opened read-only.</param> public void LoadExistingCode(string _name, ScriptType _scriptType, bool _openReadOnly) { using (new LengthyOperation(parent__)) { try { name__ = _name; type__ = _scriptType; Text = string.Format(SunnyChen.Gulu.Win.Properties.Resources.TEXT_CODEEDITOR_TITLE, name__, type__); string content = scriptRepository__.GetContent(_name, _scriptType); syntaxDocument1.Text = content; editor.ReadOnly = _openReadOnly; this.BuildCodeStruct(content); editor.Focus(); fileName__ = FileSystemScriptRepository.GetScriptFileName(_name, _scriptType); } catch { } } }