private bool Validate(Stream stream, string fileName) { var info = SupportedFileManager.GetSupportedFileInfo(ClassType); if (info == null) { return(false); } bool valid = true; try { try { info.Instantiator(stream, true, fileName); } catch (Exception) { valid = false; } } finally { stream.Position = 0; } return(valid); }
public static IResourceWrapper GetResourceWrapper(string text, Stream stream, int supportedFileIndex, string filePath = null) { if (supportedFileIndex == -1) { return(new BinaryFileWrapper(text, new BinaryFile(stream))); } var supportedFileInfo = SupportedFileManager.GetSupportedFileInfo(supportedFileIndex); var resource = supportedFileInfo.Instantiator(stream, false, filePath); return(GetResourceWrapper(text, resource)); }
public static IResourceWrapper GetResourceWrapper(string text, Stream stream, int supportedFileIndex, string filePath = null) { if (stream is FileStream fileStream) { if (filePath == null) { filePath = fileStream.Name; } stream = fileStream.ToMemoryStream(leaveOpen: false); } if (supportedFileIndex == -1) { return(new BinaryFileWrapper(text, new BinaryFile(stream))); } var supportedFileInfo = SupportedFileManager.GetSupportedFileInfo(supportedFileIndex); var resource = supportedFileInfo.Instantiator(stream, false, filePath); return(GetResourceWrapper(text, resource)); }
public static IResourceWrapper GetResourceWrapper(string text, Stream stream, string filePath = null) { return(GetResourceWrapper(text, stream, SupportedFileManager.GetSupportedFileIndex(text, stream), filePath ?? text)); }