private static IO ioForOption(String option, SnippetInfo info) { option = option.TrimStart(); if (String.IsNullOrEmpty(option)) { throw new Exception("No IO destination specified"); } if (option.StartsWith("console", StringComparison.OrdinalIgnoreCase)) { return(frmMyDlg.getIOToConsole()); } else if (option.StartsWith("append", StringComparison.OrdinalIgnoreCase)) { return(new IOAppendCurrentDoc()); } else if (option.StartsWith("insert", StringComparison.OrdinalIgnoreCase)) { return(new IOInsertAtPosition()); } else if (option.StartsWith("new", StringComparison.OrdinalIgnoreCase)) { return(IONewDoc.NewDocFactory()); } else if (option.StartsWith("file", StringComparison.OrdinalIgnoreCase)) { string filename = option.Substring(4, option.Length - 4); if (!Path.IsPathRooted(filename)) { filename = Path.Combine(info.workingDirectory, filename); } //create an IO to that document return(IOFileDoc.FileDocFactory(filename)); } else { //TODO: new IOWriteDoc(); throw new NotImplementedException("silent file"); } }
public static IONewDoc NewDocFactory(string path) { IONewDoc ret = null; lock (IODoc.docs) { if (docs.ContainsKey("new")) { ret = (IONewDoc)docs["new"]; } if (ret == null || !ret.isOpen) { ret = new IONewDoc(-1, path); ret.isOpen = false; docs["new"] = ret; } ret.refs++; return(ret); } }
public static IONewDoc NewDocFactory() { return(IONewDoc.NewDocFactory(string.Empty)); }