internal IDocument New(IDocumentType documentType) { if (documentType == null) { throw new ArgumentNullException("documentType"); } if (!documentTypes.Contains(documentType)) { throw new ArgumentException("documentType is not an item of the DocumentTypes collection."); } var document = documentType.New(); fileService.AddDocument(document); ActiveDocument = document; return(document); }
private void NewCore(DocumentType documentType, string code = null) { int startCaretPosition = 0; if (string.IsNullOrEmpty(code)) { code = documentType == DocumentType.CSharp ? TemplateCode.InitialCSharpCode : TemplateCode.InitialVisualBasicCode; startCaretPosition = documentType == DocumentType.CSharp ? TemplateCode.StartCaretPositionCSharp : TemplateCode.StartCaretPositionVisualBasic; } string fileName = "Script" + (documentCounter + 1) + (documentType == DocumentType.CSharp ? ".cs" : ".vb"); var document = new DocumentFile(documentType, fileName, code, startCaretPosition); document.ResetModified(); fileService.AddDocument(document); ActiveDocumentFile = document; documentCounter++; }