Example #1
0
        public static MetaExtractor Create(string extension, Stream file)
        {
            if (String.IsNullOrWhiteSpace(extension))
            {
                throw new ArgumentNullException(nameof(extension));
            }

            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            MetaExtractor document = null;

            switch (extension.ToLowerInvariant().Trim())
            {
            case ".sxw":
            case ".odt":
            case ".ods":
            case ".odg":
            case ".odp":
                document = new OpenOfficeDocument(file, extension);
                break;

            case ".docx":
            case ".xlsx":
            case ".pptx":
            case ".ppsx":
                document = new OfficeOpenXMLDocument(file, extension);
                break;

            case ".doc":
            case ".xls":
            case ".ppt":
            case ".pps":
                document = new Office972003(file);
                break;

            case ".pdf":
                document = new PDFDocument(file);
                break;

            case ".wpd":
                document = new WPDDocument(file);
                break;

            case ".raw":
            case ".cr2":
            case ".crw":
            case ".jpg":
            case ".jpeg":
                document = new EXIFDocument(file, extension);
                break;

            case ".svg":
            case ".svgz":
                document = new SVGDocument(file);
                break;

            case ".indd":
                document = new InDDDocument(file);
                break;

            case ".rdp":
                document = new RDPDocument(file);
                break;

            case ".ica":
                document = new ICADocument(file);
                break;

            default:
                throw new ArgumentException("Extension not allowed", nameof(extension));
            }
            return(document);
        }
Example #2
0
        public static MetaExtractor Create(string extension, Stream file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            string normalizedExtension = NormalizeExtension(extension);

            if (IsSupportedExtension(normalizedExtension))
            {
                MetaExtractor document = null;
                switch (normalizedExtension)
                {
                case ".sxw":
                case ".odt":
                case ".ods":
                case ".odg":
                case ".odp":
                    document = new OpenOfficeDocument(file, extension);
                    break;

                case ".docx":
                case ".xlsx":
                case ".pptx":
                case ".ppsx":
                    document = new OfficeOpenXMLDocument(file, extension);
                    break;

                case ".doc":
                case ".xls":
                case ".ppt":
                case ".pps":
                    document = new Office972003(file);
                    break;

                case ".pdf":
                    document = new PDFDocument(file);
                    break;

                case ".wpd":
                    document = new WPDDocument(file);
                    break;

                case ".raw":
                case ".cr2":
                case ".crw":
                case ".jpg":
                case ".jpeg":
                    document = new EXIFDocument(file, extension);
                    break;

                case ".svg":
                case ".svgz":
                    document = new SVGDocument(file);
                    break;

                case ".indd":
                    document = new InDDDocument(file);
                    break;

                case ".rdp":
                    document = new RDPDocument(file);
                    break;

                case ".ica":
                    document = new ICADocument(file);
                    break;

                default:
                    throw new ArgumentException("Extension not supported", nameof(extension));
                }

                return(document);
            }
            else
            {
                throw new ArgumentException("Extension not supported", nameof(extension));
            }
        }