public string Export(ScriptExportType exportType) { if (exportType.DeclaringType != null) { throw new NotSupportedException("You can export only topmost types"); } if (IsBuiltInType(exportType)) { return(null); } string subPath = GetExportSubPath(exportType); string filePath = Path.Combine(m_exportPath, subPath); string uniqueFilePath = ToUniqueFileName(filePath); string directory = Path.GetDirectoryName(uniqueFilePath); if (!DirectoryUtils.Exists(directory)) { DirectoryUtils.CreateVirtualDirectory(directory); } using (Stream fileStream = FileUtils.CreateVirtualFile(uniqueFilePath)) { using (StreamWriter writer = new InvariantStreamWriter(fileStream, new UTF8Encoding(false))) { exportType.Export(writer); } } AddExportedType(exportType); return(uniqueFilePath); }
public string Export(ScriptExportType exportType) { if (exportType.DeclaringType != null) { throw new NotSupportedException("You can export only topmost types"); } if (IsBuiltInType(exportType)) { return(null); } string subPath = GetExportSubPath(exportType); string filePath = Path.Combine(m_exportPath, subPath); string directory = Path.GetDirectoryName(filePath); if (!DirectoryUtils.Exists(directory)) { DirectoryUtils.CreateDirectory(directory); } using (FileStream file = FileUtils.OpenWrite(filePath)) { using (StreamWriter writer = new StreamWriter(file)) { exportType.Export(writer); } } AddExportedType(exportType); return(filePath); }