├── .config └── dotnet-tools.json ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── dependabot-reviewer.yml │ ├── docsfx.yml │ ├── dotnet-publish.yml │ └── dotnet-test.yml ├── .gitignore ├── .husky ├── commit-msg ├── csxScripts │ └── commit-lint.csx ├── pre-commit └── task-runner.json ├── .versionize ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── FileCurator.Example ├── FileCurator.Example.csproj ├── MyFile.txt ├── Program.cs ├── TestCSV.csv └── TestPDF.pdf ├── FileCurator.Tests ├── BaseClasses │ ├── TestBaseClass.cs │ └── TestingDirectoryFixture.cs ├── Default │ ├── AbsoluteFileSystem.cs │ ├── LocalDirectory.cs │ ├── LocalFile.cs │ ├── MemoryDirectoryTests.cs │ ├── MemoryFileSystem.cs │ ├── MemoryFileTests.cs │ ├── NetworkFileSystem.cs │ ├── RelativeLocalFileSystem.cs │ ├── ResourceDirectoryTests.cs │ ├── ResourceFileTests.cs │ ├── WebDirectoryTests.cs │ └── WebFileTests.cs ├── DirectoryInfo.cs ├── FileCurator.Tests.csproj ├── FileCuratorTests.cs ├── FileInfo.cs ├── Formats │ ├── Delimited │ │ ├── DelimitedReaderTests.cs │ │ └── DelimitedWriter.cs │ ├── Excel │ │ ├── ExcelReaderTests.cs │ │ └── ExcelWriterTests.cs │ ├── HTML │ │ └── HTMLFormatTests.cs │ ├── ICalendar │ │ ├── ICalReader.cs │ │ └── ICalWriter.cs │ ├── ManagerTests.cs │ ├── Mime │ │ └── MimeFormatTests.cs │ ├── PDF │ │ └── PDFReaderTests.cs │ ├── PowerPoint │ │ └── PowerPointFormatTests.cs │ ├── RSS │ │ ├── RSSReaderTests.cs │ │ └── RSSWriterTests.cs │ ├── Txt │ │ └── TxtFormatTests.cs │ ├── VCalendar │ │ ├── VCalReader.cs │ │ └── VCalWriter.cs │ ├── VCard │ │ ├── VCardReader.cs │ │ └── VCardWriterTests.cs │ └── Word │ │ └── WordFormatTests.cs ├── HelperMethods │ └── InternalHttpClientFactoryTests.cs ├── Properties │ └── AssemblyInfo.cs ├── Resources │ └── TextFile1.txt ├── TestData │ ├── TestCSV.csv │ ├── TestDOCX.docx │ ├── TestDefault.boop │ ├── TestEml.eml │ ├── TestHTML.htm │ ├── TestICal.ics │ ├── TestMHTML.mht │ ├── TestMSG.msg │ ├── TestPDF.pdf │ ├── TestPPSX.ppsx │ ├── TestPPTX.pptx │ ├── TestRSS.rss │ ├── TestRSS2.rss │ ├── TestRTF.rtf │ ├── TestTXT.txt │ ├── TestVCF.vcf │ ├── TestVCal.vcs │ ├── TestXLSX.xlsx │ └── TestXML.xml └── xunit.runner.json ├── FileCurator.sln ├── FileCurator ├── BaseClasses │ ├── DirectoryBase.cs │ ├── FileBase.cs │ ├── FileSystemBase.cs │ └── LocalFileSystemBase.cs ├── Credentials.cs ├── Default │ ├── Ftp │ │ ├── FtpDirectory.cs │ │ ├── FtpFile.cs │ │ └── FtpFileSystem.cs │ ├── Http │ │ ├── HttpFileSystem.cs │ │ ├── WebDirectory.cs │ │ └── WebFile.cs │ ├── Local │ │ ├── AbsoluteFileSystem.cs │ │ ├── LocalDirectory.cs │ │ ├── LocalFile.cs │ │ ├── NetworkFileSystem.cs │ │ └── RelativeLocalFileSystem.cs │ ├── Memory │ │ ├── MemoryDirectory.cs │ │ ├── MemoryFile.cs │ │ └── MemoryFileSystem.cs │ └── Resource │ │ ├── ResourceDirectory.cs │ │ ├── ResourceFile.cs │ │ └── ResourceFileSystem.cs ├── DirectoryInfo.cs ├── Enums │ ├── CopyOptions.cs │ └── MimeTypes.cs ├── ExtensionMethods.cs ├── FileCurator.csproj ├── FileInfo.cs ├── FileSystem.cs ├── Formats │ ├── BaseClasses │ │ ├── FormatBaseClass.cs │ │ └── ReaderBaseClass.cs │ ├── Data │ │ ├── Address.cs │ │ ├── BaseClasses │ │ │ ├── FileBaseClass.cs │ │ │ └── TableBaseClass.cs │ │ ├── Enums │ │ │ └── Relationship.cs │ │ ├── FixedLength │ │ │ ├── BaseClasses │ │ │ │ ├── FieldBaseClass.cs │ │ │ │ ├── FixedLengthBaseClass.cs │ │ │ │ └── RecordBase.cs │ │ │ ├── Interfaces │ │ │ │ ├── IField.cs │ │ │ │ └── IRecord.cs │ │ │ └── StringField.cs │ │ ├── GenericCalendar.cs │ │ ├── GenericCard.cs │ │ ├── GenericCell.cs │ │ ├── GenericEmail.cs │ │ ├── GenericFile.cs │ │ ├── GenericRow.cs │ │ ├── GenericTable.cs │ │ ├── Interfaces │ │ │ ├── Feed │ │ │ │ ├── IChannel.cs │ │ │ │ ├── IEnclosure.cs │ │ │ │ ├── IFeed.cs │ │ │ │ ├── IFeedGuid.cs │ │ │ │ ├── IFeedItem.cs │ │ │ │ └── IThumbnail.cs │ │ │ ├── IAddress.cs │ │ │ ├── ICalendar.cs │ │ │ ├── ICard.cs │ │ │ ├── IGenericFile.cs │ │ │ ├── IMailAddress.cs │ │ │ ├── IMessage.cs │ │ │ ├── IPhoneNumber.cs │ │ │ └── Table │ │ │ │ ├── ICell.cs │ │ │ │ ├── IRow.cs │ │ │ │ └── ITable.cs │ │ ├── MailAddress.cs │ │ └── PhoneNumber.cs │ ├── Delimited │ │ ├── DelimitedFormat.cs │ │ ├── DelimitedReader.cs │ │ └── DelimitedWriter.cs │ ├── Excel │ │ ├── ExcelFormat.cs │ │ ├── ExcelReader.cs │ │ └── ExcelWriter.cs │ ├── HTML │ │ ├── HTMLFormat.cs │ │ ├── HTMLReader.cs │ │ └── HTMLWriter.cs │ ├── ICal │ │ ├── ICalendarFormat.cs │ │ ├── ICalendarReader.cs │ │ └── ICalendarWriter.cs │ ├── Interfaces │ │ ├── IFileReader.cs │ │ ├── IFileWriter.cs │ │ └── IFormat.cs │ ├── MSG │ │ ├── Data │ │ │ └── OutlookStorage.cs │ │ ├── MSGFormat.cs │ │ ├── MSGReader.cs │ │ └── MSGWriter.cs │ ├── Manager.cs │ ├── Mime │ │ ├── MimeFormat.cs │ │ ├── MimeReader.cs │ │ └── MimeWriter.cs │ ├── PDF │ │ ├── PDFFormat.cs │ │ ├── PDFReader.cs │ │ └── PDFWriter.cs │ ├── PowerPoint │ │ ├── PowerPointFormat.cs │ │ ├── PowerPointReader.cs │ │ └── PowerPointWriter.cs │ ├── RSS │ │ ├── Data │ │ │ ├── Channel.cs │ │ │ ├── Enclosure.cs │ │ │ ├── Feed.cs │ │ │ ├── FeedGuid.cs │ │ │ ├── FeedItem.cs │ │ │ ├── Thumbnail.cs │ │ │ └── Utils.cs │ │ ├── RSSFormat.cs │ │ ├── RSSReader.cs │ │ └── RSSWriter.cs │ ├── RTF │ │ ├── RTFFormat.cs │ │ ├── RTFReader.cs │ │ └── RTFWriter.cs │ ├── Txt │ │ ├── TxtFormat.cs │ │ ├── TxtReader.cs │ │ └── TxtWriter.cs │ ├── VCalendar │ │ ├── VCalendarFormat.cs │ │ ├── VCalendarReader.cs │ │ └── VCalendarWriter.cs │ ├── VCard │ │ ├── VCardFormat.cs │ │ ├── VCardReader.cs │ │ └── VCardWriter.cs │ ├── Word │ │ ├── WordFormat.cs │ │ ├── WordReader.cs │ │ └── WordWriter.cs │ └── XML │ │ ├── XMLFormat.cs │ │ ├── XMLReader.cs │ │ └── XMLWriter.cs ├── HelperMethods │ ├── HelperFunctions.cs │ ├── InternalHttpClientFactory.cs │ ├── Services.cs │ └── Word │ │ └── WordDocumentAssembler.cs ├── Interfaces │ ├── IDirectory.cs │ ├── IFile.cs │ └── IFileSystem.cs ├── Module │ └── FileCuratorModule.cs ├── Properties │ └── AssemblyInfo.cs └── Registration │ └── CanisterExtension.cs ├── Icon.png ├── LICENSE ├── README.md ├── SECURITY.md ├── docfx_project ├── .gitignore ├── api │ ├── .gitignore │ └── index.md ├── articles │ ├── intro.md │ └── toc.yml ├── docfx.json ├── images │ └── icon.png ├── index.md ├── templates │ └── mytemplate │ │ └── public │ │ └── main.css └── toc.yml └── setup.bat /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "husky": { 6 | "version": "0.7.2", 7 | "commands": [ 8 | "husky" 9 | ], 10 | "rollForward": false 11 | }, 12 | "versionize": { 13 | "version": "2.3.1", 14 | "commands": [ 15 | "versionize" 16 | ], 17 | "rollForward": false 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: JaCraig 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Example code** 14 | Please provide example code that produces the bug either in a gist or pull request adding a test case and link here. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Version Information** 23 | - OS: [e.g. iOS] 24 | - .Net Version: [e.g. .Net 6] 25 | - Release Version of Library [e.g. 2.0.1] 26 | 27 | **Additional context** 28 | Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "nuget" # See documentation for possible values 9 | directory: "/FileCurator/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | commit-message: 13 | prefix: "fix" 14 | groups: 15 | dependencies: 16 | patterns: 17 | - "*" 18 | 19 | - package-ecosystem: "nuget" # See documentation for possible values 20 | directory: "/FileCurator.Tests/" # Location of package manifests 21 | schedule: 22 | interval: "daily" 23 | commit-message: 24 | prefix: "chore" 25 | groups: 26 | dependencies: 27 | patterns: 28 | - "*" 29 | 30 | - package-ecosystem: "nuget" # See documentation for possible values 31 | directory: "/FileCurator.Example/" # Location of package manifests 32 | schedule: 33 | interval: "daily" 34 | commit-message: 35 | prefix: "chore" 36 | groups: 37 | dependencies: 38 | patterns: 39 | - "*" 40 | 41 | - package-ecosystem: "github-actions" 42 | directory: "/" 43 | schedule: 44 | interval: "daily" 45 | commit-message: 46 | prefix: "chore" 47 | groups: 48 | dependencies: 49 | patterns: 50 | - "*" 51 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "master" ] 17 | pull_request: 18 | branches: [ "master" ] 19 | schedule: 20 | - cron: '37 18 * * 3' 21 | 22 | permissions: 23 | actions: read 24 | contents: read 25 | security-events: write 26 | 27 | jobs: 28 | analyze: 29 | uses: JaCraig/Centralized-Workflows/.github/workflows/codeql.yml@main -------------------------------------------------------------------------------- /.github/workflows/dependabot-reviewer.yml: -------------------------------------------------------------------------------- 1 | name: Dependabot Reviewer 2 | 3 | on: pull_request_target 4 | 5 | permissions: 6 | pull-requests: write 7 | contents: write 8 | 9 | jobs: 10 | review-dependabot-pr: 11 | if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} 12 | uses: JaCraig/Centralized-Workflows/.github/workflows/dependabot-reviewer.yml@main 13 | secrets: 14 | token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/docsfx.yml: -------------------------------------------------------------------------------- 1 | name: Document Site Publish 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | 7 | permissions: 8 | contents: write 9 | 10 | jobs: 11 | publish-docs: 12 | uses: JaCraig/Centralized-Workflows/.github/workflows/docsfx.yml@main -------------------------------------------------------------------------------- /.github/workflows/dotnet-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a .NET project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net 3 | 4 | name: .NET Publish 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | 10 | jobs: 11 | build: 12 | uses: 'JaCraig/Centralized-Workflows/.github/workflows/dotnet-publish.yml@main' 13 | with: 14 | user: 'JaCraig' 15 | user-email: 'JaCraig@users.noreply.github.com' 16 | coveralls-upload: "./FileCurator.Tests/TestResults-9.0.x/coverage.net8.0.info" 17 | test-filter: "FileCurator.Tests" 18 | secrets: 19 | PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} 20 | NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} -------------------------------------------------------------------------------- /.github/workflows/dotnet-test.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a .NET project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net 3 | 4 | name: .NET Test Pull Requests 5 | 6 | on: 7 | pull_request: 8 | branches: [ "master" ] 9 | 10 | jobs: 11 | build: 12 | uses: 'JaCraig/Centralized-Workflows/.github/workflows/dotnet-test.yml@main' -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | ## husky task runner examples ------------------- 5 | ## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky' 6 | 7 | ## run all tasks 8 | #husky run 9 | 10 | ### run all tasks with group: 'group-name' 11 | #husky run --group group-name 12 | 13 | ## run task with name: 'task-name' 14 | #husky run --name task-name 15 | 16 | ## pass hook arguments to task 17 | #husky run --args "$1" "$2" 18 | 19 | ## or put your custom commands ------------------- 20 | #echo 'Husky.Net is awesome!' 21 | 22 | dotnet husky run --name "commit-message-linter" --args "$1" 23 | -------------------------------------------------------------------------------- /.husky/csxScripts/commit-lint.csx: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | private var pattern = @"^(?=.{1,90}$)(?:build|feat|ci|chore|docs|fix|perf|refactor|revert|style|test)(?:\(.+\))*(?::).{4,}(?:#\d+)*(? 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | PreserveNewest 19 | 20 | 21 | PreserveNewest 22 | 23 | 24 | PreserveNewest 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /FileCurator.Example/MyFile.txt: -------------------------------------------------------------------------------- 1 | This is my example file. -------------------------------------------------------------------------------- /FileCurator.Example/Program.cs: -------------------------------------------------------------------------------- 1 | using BigBook; 2 | using FileCurator.Formats.Data.Interfaces; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace FileCurator.Example 6 | { 7 | /// 8 | /// Example program to show how to use the FileCurator library 9 | /// 10 | internal class Program 11 | { 12 | /// 13 | /// Defines the entry point of the application. 14 | /// 15 | /// The arguments. 16 | private static void Main(string[] args) 17 | { 18 | // Create a service provider. 19 | var ServiceProvider = new ServiceCollection().AddCanisterModules()?.BuildServiceProvider(); 20 | 21 | // Let's load a generic file and view it's details. 22 | var MyFile = new FileInfo("./MyFile.txt"); 23 | Console.WriteLine("File Info:"); 24 | Console.WriteLine($"File: {MyFile.FullName}"); 25 | Console.WriteLine($"File Exists: {MyFile.Exists}"); 26 | Console.WriteLine($"File Extension: {MyFile.Extension}"); 27 | Console.WriteLine($"File Name: {MyFile.Name}"); 28 | Console.WriteLine($"File length: {MyFile.Length}"); 29 | Console.WriteLine(); 30 | 31 | // We can also parse the file and view it's contents. 32 | var PDFContent = new FileInfo("./TestPDF.pdf").Parse(); 33 | Console.WriteLine("PDF Content:"); 34 | Console.WriteLine(PDFContent.Content); 35 | Console.WriteLine(); 36 | 37 | // Including more structured files like CSVs. This will parse the CSV into a table. 38 | var CSVContent = new FileInfo("./TestCSV.csv").Parse(); 39 | Console.WriteLine("CSV Content:"); 40 | Console.WriteLine(CSVContent.Content); 41 | Console.WriteLine($"Columns: {CSVContent.Columns.ToString(x => x)}"); 42 | Console.WriteLine($"Rows: {CSVContent.Rows.ToString(x => x.Cells.ToString(x => x.Content, ", "), "\n")}"); 43 | Console.WriteLine(); 44 | 45 | // We can also write structured content to a file. 46 | var NewCSVFile = new FileInfo("./NewCSV.csv"); 47 | NewCSVFile.Write(CSVContent); 48 | 49 | // And then read it as a string. 50 | Console.WriteLine(NewCSVFile.Read()); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /FileCurator.Example/TestCSV.csv: -------------------------------------------------------------------------------- 1 | Header 1,Header 2,Header 3,Header 4,Header 5,Header 6 2 | This,is,a,test,CSV,file 3 | Tons,of,data,in here,is,super 4 | important -------------------------------------------------------------------------------- /FileCurator.Example/TestPDF.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/FileCurator.Example/TestPDF.pdf -------------------------------------------------------------------------------- /FileCurator.Tests/BaseClasses/TestingDirectoryFixture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | namespace FileCurator.Tests.BaseClasses 5 | { 6 | [Collection("DirectoryCollection")] 7 | public class TestingDirectoryFixture : IDisposable 8 | { 9 | public TestingDirectoryFixture() 10 | { 11 | new DirectoryInfo(@".\Testing").Create(); 12 | new DirectoryInfo(@".\App_Data").Create(); 13 | new DirectoryInfo(@".\Logs").Create(); 14 | new DirectoryInfo("./Results").Create(); 15 | } 16 | 17 | public void Dispose() 18 | { 19 | new DirectoryInfo(@".\Testing").Delete(); 20 | new DirectoryInfo(@".\App_Data").Delete(); 21 | new DirectoryInfo(@".\Logs").Delete(); 22 | new DirectoryInfo("./Results").Delete(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Default/AbsoluteFileSystem.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default; 2 | using FileCurator.Tests.BaseClasses; 3 | using Xunit; 4 | 5 | namespace FileCurator.Tests.Default 6 | { 7 | public class AbsoluteFileSystemTests : TestBaseClass 8 | { 9 | public AbsoluteFileSystemTests() 10 | { 11 | TestObject = new AbsoluteLocalFileSystem(); 12 | } 13 | 14 | [Fact] 15 | public void CanHandle() 16 | { 17 | var Temp = new AbsoluteLocalFileSystem(); 18 | Assert.True(Temp.CanHandle(@"C:\TestPath\Yay")); 19 | Assert.True(Temp.CanHandle(@"F:\TestPath\Yay")); 20 | Assert.True(Temp.CanHandle(@"Q:\TestPath\Yay")); 21 | } 22 | 23 | [Fact] 24 | public void Creation() 25 | { 26 | var Temp = new AbsoluteLocalFileSystem(); 27 | Assert.NotNull(Temp); 28 | Assert.Equal("Absolute Local", Temp.Name); 29 | } 30 | 31 | [Fact] 32 | public void Directory() 33 | { 34 | var Temp = new AbsoluteLocalFileSystem(); 35 | var Dir = Temp.Directory(@"C:\"); 36 | Assert.NotNull(Dir); 37 | Assert.IsType(Dir); 38 | //Assert.True(Dir.Exists); 39 | } 40 | 41 | [Fact] 42 | public void File() 43 | { 44 | var Temp = new AbsoluteLocalFileSystem(); 45 | var TestFile = Temp.File(@"C:\Test.txt"); 46 | Assert.NotNull(TestFile); 47 | Assert.IsType(TestFile); 48 | Assert.False(TestFile.Exists); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Default/LocalFile.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.Text; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Default 7 | { 8 | public class LocalFileTests : TestBaseClass 9 | { 10 | public LocalFileTests() 11 | { 12 | TestObject = new LocalFile(); 13 | } 14 | 15 | [Fact] 16 | public void Creation() 17 | { 18 | var File = new LocalFile("./Test.txt"); 19 | Assert.NotNull(File); 20 | Assert.False(File.Exists); 21 | } 22 | 23 | [Fact] 24 | public void ReadWrite() 25 | { 26 | var File = new LocalFile("./Test.txt"); 27 | File.Write("Testing this out"); 28 | Assert.True(File.Exists); 29 | Assert.Equal("Testing this out", File.Read()); 30 | Assert.Equal("Testing this out", File); 31 | Assert.Equal(Encoding.ASCII.GetBytes("Testing this out"), File.ReadBinary()); 32 | Assert.Equal(Encoding.ASCII.GetBytes("Testing this out"), File); 33 | File.Delete(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Default/MemoryDirectoryTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default.Memory; 2 | using FileCurator.Interfaces; 3 | using FileCurator.Tests.BaseClasses; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Default 7 | { 8 | public class MemoryDirectoryTests : TestBaseClass 9 | { 10 | public MemoryDirectoryTests() 11 | { 12 | TestObject = new MemoryDirectory(); 13 | } 14 | 15 | [Fact] 16 | public void Copy() 17 | { 18 | var Temp = new MemoryDirectory("mem://Test"); 19 | var Temp2 = new MemoryDirectory("mem://Test2"); 20 | Temp.Create(); 21 | Temp2.Create(); 22 | var Temp3 = Temp2.CopyTo(Temp); 23 | Assert.True(Temp.Exists); 24 | Assert.True(Temp2.Exists); 25 | Assert.True(Temp3.Exists); 26 | Assert.Equal(Temp, Temp3); 27 | Assert.NotSame(Temp, Temp2); 28 | Assert.NotSame(Temp2, Temp3); 29 | Temp.Delete(); 30 | Temp2.Delete(); 31 | Assert.False(Temp.Exists); 32 | } 33 | 34 | [Fact] 35 | public void CreateAndDelete() 36 | { 37 | var Temp = new MemoryDirectory("mem://Test"); 38 | Temp.Create(); 39 | Assert.True(Temp.Exists); 40 | Temp.Delete(); 41 | Assert.False(Temp.Exists); 42 | } 43 | 44 | [Fact] 45 | public void Creation() 46 | { 47 | var Temp = new MemoryDirectory("mem://Test"); 48 | Assert.NotNull(Temp); 49 | Assert.False(Temp.Exists); 50 | } 51 | 52 | [Fact] 53 | public void Enumeration() 54 | { 55 | foreach (IFile File in new MemoryDirectory("mem://Test")) { } 56 | } 57 | 58 | [Fact] 59 | public void Equality() 60 | { 61 | var Temp = new MemoryDirectory("mem://A"); 62 | var Temp2 = new MemoryDirectory("mem://A"); 63 | Assert.True(Temp == Temp2); 64 | Assert.True(Temp.Equals(Temp2)); 65 | Assert.Equal(0, Temp.CompareTo(Temp2)); 66 | Assert.False(Temp < Temp2); 67 | Assert.False(Temp > Temp2); 68 | Assert.True(Temp <= Temp2); 69 | Assert.True(Temp >= Temp2); 70 | Assert.False(Temp != Temp2); 71 | } 72 | 73 | [Fact] 74 | public void Move() 75 | { 76 | IDirectory Temp = new MemoryDirectory("mem://Test/A"); 77 | IDirectory Temp2 = new MemoryDirectory("mem://Test2/"); 78 | Temp.Create(); 79 | Temp2.Create(); 80 | Temp2 = Temp2.MoveTo(Temp); 81 | Assert.True(Temp.Exists); 82 | Assert.True(Temp2.Exists); 83 | Assert.Equal(Temp.FullName, Temp2.Parent.FullName); 84 | Temp.Delete(); 85 | Assert.False(Temp.Exists); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Default/MemoryFileSystem.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default.Memory; 2 | using FileCurator.Tests.BaseClasses; 3 | using Xunit; 4 | 5 | namespace FileCurator.Tests.Default 6 | { 7 | public class MemoryFileSystemTests : TestBaseClass 8 | { 9 | public MemoryFileSystemTests() 10 | { 11 | TestObject = new MemoryFileSystem(); 12 | } 13 | 14 | [Fact] 15 | public void CanHandle() 16 | { 17 | var Temp = new MemoryFileSystem(); 18 | Assert.True(Temp.CanHandle(@"mem://localhost\C$\TestPath\Yay")); 19 | } 20 | 21 | [Fact] 22 | public void Creation() 23 | { 24 | var Temp = new MemoryFileSystem(); 25 | Assert.NotNull(Temp); 26 | Assert.Equal("Memory", Temp.Name); 27 | } 28 | 29 | [Fact] 30 | public void Directory() 31 | { 32 | var Temp = new MemoryFileSystem(); 33 | var Dir = Temp.Directory(@"mem://localhost\C$\"); 34 | Assert.NotNull(Dir); 35 | Assert.IsType(Dir); 36 | Assert.False(Dir.Exists); 37 | } 38 | 39 | [Fact] 40 | public void File() 41 | { 42 | var Temp = new MemoryFileSystem(); 43 | var TestFile = Temp.File(@"mem://localhost\C$\Test.txt"); 44 | Assert.NotNull(TestFile); 45 | Assert.IsType(TestFile); 46 | Assert.True(TestFile.Exists); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Default/MemoryFileTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default.Memory; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.Text; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Default 7 | { 8 | public class MemoryFileTests : TestBaseClass 9 | { 10 | public MemoryFileTests() 11 | { 12 | TestObject = new MemoryFile(); 13 | } 14 | 15 | [Fact] 16 | public void Clone() 17 | { 18 | var Temp = new MemoryFile("mem://code.jquery.com/jquery-1.10.2.min.js", null); 19 | Temp.Write("Testing this out"); 20 | var Temp2 = new MemoryFile("mem://code.jquery.com/jquery-1.10.2.min.js", null); 21 | Temp2.Write("Testing this out"); 22 | Assert.True(Temp == Temp2); 23 | Assert.True(Temp.Equals(Temp2)); 24 | Assert.Equal(0, Temp.CompareTo(Temp2)); 25 | Assert.False(Temp < Temp2); 26 | Assert.False(Temp > Temp2); 27 | Assert.True(Temp <= Temp2); 28 | Assert.True(Temp >= Temp2); 29 | Assert.False(Temp != Temp2); 30 | } 31 | 32 | [Fact] 33 | public void Creation() 34 | { 35 | var File = new MemoryFile("mem://code.jquery.com/jquery-1.10.2.min.js", null); 36 | Assert.NotNull(File); 37 | Assert.True(File.Exists); 38 | } 39 | 40 | [Fact] 41 | public void ReadWrite() 42 | { 43 | var File = new MemoryFile("mem://Test.txt", null); 44 | File.Write("Testing this out"); 45 | Assert.True(File.Exists); 46 | Assert.Equal("Testing this out", File.Read()); 47 | Assert.Equal("Testing this out", File); 48 | Assert.Equal(Encoding.ASCII.GetBytes("Testing this out"), File.ReadBinary()); 49 | Assert.Equal(Encoding.ASCII.GetBytes("Testing this out"), File); 50 | File.Delete(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Default/NetworkFileSystem.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default; 2 | using FileCurator.Tests.BaseClasses; 3 | using Xunit; 4 | 5 | namespace FileCurator.Tests.Default 6 | { 7 | public class NetworkFileSystemTests : TestBaseClass 8 | { 9 | public NetworkFileSystemTests() 10 | { 11 | TestObject = new NetworkFileSystem(); 12 | } 13 | 14 | [Fact] 15 | public void CanHandle() 16 | { 17 | var Temp = new NetworkFileSystem(); 18 | Assert.True(Temp.CanHandle(@"\\localhost\C$\TestPath\Yay")); 19 | } 20 | 21 | [Fact] 22 | public void Creation() 23 | { 24 | var Temp = new NetworkFileSystem(); 25 | Assert.NotNull(Temp); 26 | Assert.Equal("Network", Temp.Name); 27 | } 28 | 29 | [Fact] 30 | public void Directory() 31 | { 32 | var Temp = new NetworkFileSystem(); 33 | var Dir = Temp.Directory(@"\\localhost\C$\"); 34 | Assert.NotNull(Dir); 35 | Assert.IsType(Dir); 36 | } 37 | 38 | [Fact] 39 | public void File() 40 | { 41 | var Temp = new NetworkFileSystem(); 42 | var TestFile = Temp.File(@"\\localhost\C$\Test.txt"); 43 | Assert.NotNull(TestFile); 44 | Assert.IsType(TestFile); 45 | Assert.False(TestFile.Exists); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Default/RelativeLocalFileSystem.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default; 2 | using FileCurator.Tests.BaseClasses; 3 | using Xunit; 4 | 5 | namespace FileCurator.Tests.Default 6 | { 7 | public class RelativeLocalFileSystemTests : TestBaseClass 8 | { 9 | public RelativeLocalFileSystemTests() 10 | { 11 | TestObject = new RelativeLocalFileSystem(); 12 | } 13 | 14 | [Fact] 15 | public void CanHandle() 16 | { 17 | var Temp = new RelativeLocalFileSystem(); 18 | Assert.True(Temp.CanHandle(@".\TestPath\Yay")); 19 | Assert.True(Temp.CanHandle(@"..\TestPath\Yay")); 20 | Assert.True(Temp.CanHandle(@"~\TestPath\Yay")); 21 | } 22 | 23 | [Fact] 24 | public void Creation() 25 | { 26 | var Temp = new RelativeLocalFileSystem(); 27 | Assert.NotNull(Temp); 28 | Assert.Equal("Relative Local", Temp.Name); 29 | } 30 | 31 | [Fact] 32 | public void Directory() 33 | { 34 | var Temp = new RelativeLocalFileSystem(); 35 | var Dir = Temp.Directory("."); 36 | Assert.NotNull(Dir); 37 | Assert.IsType(Dir); 38 | Assert.True(Dir.Exists); 39 | Dir = Temp.Directory(".."); 40 | Assert.NotNull(Dir); 41 | Assert.IsType(Dir); 42 | Assert.True(Dir.Exists); 43 | Dir = Temp.Directory("~/"); 44 | Assert.NotNull(Dir); 45 | Assert.IsType(Dir); 46 | } 47 | 48 | [Fact] 49 | public void File() 50 | { 51 | var Temp = new RelativeLocalFileSystem(); 52 | var TestFile = Temp.File(@"~\Test.txt"); 53 | Assert.NotNull(TestFile); 54 | Assert.IsType(TestFile); 55 | Assert.False(TestFile.Exists); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Default/ResourceFileTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default; 2 | using FileCurator.Tests.BaseClasses; 3 | using Xunit; 4 | 5 | namespace FileCurator.Tests.Default 6 | { 7 | public class ResourceFileTests : TestBaseClass 8 | { 9 | public ResourceFileTests() 10 | { 11 | TestObject = new ResourceFile(); 12 | } 13 | 14 | [Fact] 15 | public void Creation() 16 | { 17 | var File = new ResourceFile("resource://FileCurator.Tests/FileCurator.Tests.Resources.TextFile1.txt"); 18 | Assert.NotNull(File); 19 | Assert.True(File.Exists); 20 | Assert.NotNull(File.Directory); 21 | Assert.Equal(".txt", File.Extension); 22 | Assert.Equal("resource://FileCurator.Tests/FileCurator.Tests.Resources.TextFile1.txt", File.FullName); 23 | Assert.Equal(32, File.Length); 24 | Assert.Equal("FileCurator.Tests.Resources.TextFile1.txt", File.Name); 25 | } 26 | 27 | [Fact] 28 | public void CreationDoesntExist() 29 | { 30 | var File = new ResourceFile("resource://_ViewImports.cshtml"); 31 | Assert.NotNull(File); 32 | Assert.False(File.Exists); 33 | Assert.Null(File.Directory); 34 | Assert.Equal(".cshtml", File.Extension); 35 | Assert.Equal("resource://_ViewImports.cshtml", File.FullName); 36 | Assert.Equal(0, File.Length); 37 | Assert.Equal("_ViewImports.cshtml", File.Name); 38 | } 39 | 40 | [Fact] 41 | public void CreationWithSlashes() 42 | { 43 | var File = new ResourceFile("resource://FileCurator.Tests/FileCurator/Tests/Resources/TextFile1.txt"); 44 | Assert.NotNull(File); 45 | Assert.True(File.Exists); 46 | Assert.NotNull(File.Directory); 47 | Assert.Equal(".txt", File.Extension); 48 | Assert.Equal("resource://FileCurator.Tests/FileCurator.Tests.Resources.TextFile1.txt", File.FullName); 49 | Assert.Equal(32, File.Length); 50 | Assert.Equal("FileCurator.Tests.Resources.TextFile1.txt", File.Name); 51 | } 52 | 53 | [Fact] 54 | public void ReadWrite() 55 | { 56 | var File = new ResourceFile("resource://FileCurator.Tests/FileCurator.Tests.Resources.TextFile1.txt"); 57 | Assert.Equal("This is a resource file test.", File.Read()); 58 | Assert.Equal("This is a resource file test.", (string)File); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /FileCurator.Tests/FileCuratorTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Default; 2 | using FileCurator.Interfaces; 3 | using FileCurator.Tests.BaseClasses; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests 7 | { 8 | public class FileCuratorTests : TestBaseClass 9 | { 10 | public FileCuratorTests() 11 | { 12 | TestObject = null; 13 | } 14 | 15 | [Fact] 16 | public void Creation() 17 | { 18 | var Temp = new FileSystem(new IFileSystem[] { new AbsoluteLocalFileSystem(), new NetworkFileSystem(), new RelativeLocalFileSystem() }); 19 | Assert.NotNull(Temp); 20 | } 21 | 22 | [Fact] 23 | public void Directory() 24 | { 25 | var Temp = new FileSystem(new IFileSystem[] { new AbsoluteLocalFileSystem(), new NetworkFileSystem(), new RelativeLocalFileSystem() }); 26 | var Dir = Temp.Directory(@"C:\"); 27 | if (!Dir.Exists) 28 | return; 29 | Assert.NotNull(Dir); 30 | Assert.IsType(Dir); 31 | Assert.True(Dir.Exists); 32 | Dir = Temp.Directory(@"\\localhost\C$\"); 33 | Assert.NotNull(Dir); 34 | Assert.IsType(Dir); 35 | Assert.True(Dir.Exists); 36 | Dir = Temp.Directory("./"); 37 | Assert.NotNull(Dir); 38 | Assert.IsType(Dir); 39 | Assert.True(Dir.Exists); 40 | Dir = Temp.Directory("../"); 41 | Assert.NotNull(Dir); 42 | Assert.IsType(Dir); 43 | Assert.True(Dir.Exists); 44 | Dir = Temp.Directory("~/"); 45 | Assert.NotNull(Dir); 46 | Assert.IsType(Dir); 47 | Assert.True(Dir.Exists); 48 | } 49 | 50 | [Fact] 51 | public void File() 52 | { 53 | var Temp = new FileSystem(new IFileSystem[] { new AbsoluteLocalFileSystem(), new NetworkFileSystem(), new RelativeLocalFileSystem() }); 54 | var TestFile = Temp.File(@"C:\Test.txt"); 55 | Assert.NotNull(TestFile); 56 | Assert.IsType(TestFile); 57 | Assert.False(TestFile.Exists); 58 | TestFile = Temp.File(@"~\Test.txt"); 59 | Assert.NotNull(TestFile); 60 | Assert.IsType(TestFile); 61 | Assert.False(TestFile.Exists); 62 | TestFile = Temp.File(@"\\localhost\C$\Test.txt"); 63 | Assert.NotNull(TestFile); 64 | Assert.IsType(TestFile); 65 | Assert.False(TestFile.Exists); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/Delimited/DelimitedReaderTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.Delimited; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using Xunit; 6 | 7 | namespace FileCurator.Tests.Formats.Delimited 8 | { 9 | public class DelimitedReaderTests : TestBaseClass 10 | { 11 | public DelimitedReaderTests() 12 | { 13 | TestObject = new DelimitedReader(); 14 | } 15 | 16 | [Fact] 17 | public void Read() 18 | { 19 | var TestObject = new DelimitedReader(); 20 | var Result = TestObject.Read(File.OpenRead("./TestData/TestCSV.csv")); 21 | Assert.Equal(3, Result.Rows.Count); 22 | Assert.Equal(6, Result.Columns.Count); 23 | Assert.Equal("Header 1", Result.Columns[0]); 24 | Assert.Equal("Header 2", Result.Columns[1]); 25 | Assert.Equal("Header 3", Result.Columns[2]); 26 | Assert.Equal("Header 4", Result.Columns[3]); 27 | Assert.Equal("Header 5", Result.Columns[4]); 28 | Assert.Equal("Header 6", Result.Columns[5]); 29 | var TempData = new List> 30 | { 31 | new List(), 32 | new List(), 33 | new List() 34 | }; 35 | TempData[0].AddRange(new[] { "This", "is", "a", "test", "CSV", "file" }); 36 | TempData[1].AddRange(new[] { "Tons", "of", "data", "in here", "is", "super" }); 37 | TempData[2].Add("important"); 38 | for (int x = 0; x < TempData.Count; ++x) 39 | { 40 | for (int y = 0; y < TempData[x].Count; ++y) 41 | { 42 | Assert.Equal(TempData[x][y], Result.Rows[x].Cells[y].Content); 43 | } 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/Delimited/DelimitedWriter.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.Delimited; 2 | using FileCurator.Formats.Excel; 3 | using FileCurator.Formats.Txt; 4 | using FileCurator.Tests.BaseClasses; 5 | using System.IO; 6 | using Xunit; 7 | 8 | namespace FileCurator.Tests.Formats.Delimited 9 | { 10 | public class DelimitedWriterTests : TestBaseClass 11 | { 12 | public DelimitedWriterTests() 13 | { 14 | TestObject = new DelimitedWriter(); 15 | } 16 | 17 | [Fact] 18 | public void WriteATable() 19 | { 20 | Directory.CreateDirectory("./Results"); 21 | var TestObject = new DelimitedWriter(); 22 | var TestReader = new ExcelReader(); 23 | var ResultReader = new DelimitedReader(); 24 | using (var ResultFile = File.Open("./Results/WriteATable.csv", FileMode.OpenOrCreate)) 25 | { 26 | using var TestFile = File.OpenRead("./TestData/TestXLSX.xlsx"); 27 | Assert.True(TestObject.Write(ResultFile, TestReader.Read(TestFile))); 28 | } 29 | using (var ResultFile = File.Open("./Results/WriteATable.csv", FileMode.OpenOrCreate)) 30 | { 31 | var Result = ResultReader.Read(ResultFile); 32 | Assert.Equal(2, Result.Rows.Count); 33 | Assert.Equal(2, Result.Columns.Count); 34 | Assert.Equal("Test", Result.Columns[0]); 35 | Assert.Equal("Data", Result.Columns[1]); 36 | Assert.Equal("Goes", Result.Rows[0].Cells[0].Content); 37 | Assert.Equal("here", Result.Rows[0].Cells[1].Content); 38 | Assert.Equal("1", Result.Rows[1].Cells[1].Content); 39 | } 40 | } 41 | 42 | [Fact] 43 | public void WriteNotATable() 44 | { 45 | Directory.CreateDirectory("./Results"); 46 | var TestObject = new DelimitedWriter(); 47 | var TestReader = new TxtFormat(); 48 | var ResultReader = new DelimitedReader(); 49 | using (var ResultFile = File.Open("./Results/WriteNotATable.csv", FileMode.OpenOrCreate)) 50 | { 51 | using var TestFile = File.OpenRead("./TestData/TestTXT.txt"); 52 | Assert.True(TestObject.Write(ResultFile, TestReader.Read(TestFile))); 53 | } 54 | using (var ResultFile = File.Open("./Results/WriteNotATable.csv", FileMode.OpenOrCreate)) 55 | { 56 | var Result = ResultReader.Read(ResultFile); 57 | Assert.Single(Result.Columns); 58 | Assert.Equal("This is a test docx", Result.Columns[0]); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/Excel/ExcelReaderTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.Excel; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.IO; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Formats.Excel 7 | { 8 | public class ExcelReaderTests : TestBaseClass 9 | { 10 | public ExcelReaderTests() 11 | { 12 | TestObject = new ExcelReader(); 13 | } 14 | 15 | [Fact] 16 | public void Convert() 17 | { 18 | var TestObject = new ExcelReader(); 19 | var Result = TestObject.Read(File.OpenRead("./TestData/TestXLSX.xlsx")); 20 | var Results = Result.Convert(); 21 | Assert.Equal(2, Results.Count); 22 | Assert.Equal("Goes", Results[0].Test); 23 | Assert.Equal("here", Results[0].Data); 24 | Assert.Equal(string.Empty, Results[1].Test); 25 | Assert.Equal("1", Results[1].Data); 26 | } 27 | 28 | [Fact] 29 | public void Read() 30 | { 31 | var TestObject = new ExcelReader(); 32 | var Result = TestObject.Read(File.OpenRead("./TestData/TestXLSX.xlsx")); 33 | Assert.Equal(2, Result.Rows.Count); 34 | Assert.Equal(2, Result.Columns.Count); 35 | Assert.Equal("Test", Result.Columns[0]); 36 | Assert.Equal("Data", Result.Columns[1]); 37 | Assert.Equal("Goes", Result.Rows[0].Cells[0].Content); 38 | Assert.Equal("here", Result.Rows[0].Cells[1].Content); 39 | Assert.Equal("1", Result.Rows[1].Cells[1].Content); 40 | Assert.Equal(1, Result.Rows[1].Cells[1].GetValue()); 41 | } 42 | 43 | public class ExcelTestData 44 | { 45 | public string Data { get; set; } 46 | public string Test { get; set; } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/ICalendar/ICalReader.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.ICal; 2 | using FileCurator.Tests.BaseClasses; 3 | using System; 4 | using System.IO; 5 | using Xunit; 6 | 7 | namespace FileCurator.Tests.Formats.ICalendar 8 | { 9 | public class ICalReader : TestBaseClass 10 | { 11 | public ICalReader() 12 | { 13 | TestObject = new ICalendarReader(); 14 | } 15 | 16 | [Fact] 17 | public void Read() 18 | { 19 | var TimeZone = TimeZoneInfo.Local; 20 | var TestObject = new ICalendarReader(); 21 | var Result = TestObject.Read(File.OpenRead("./TestData/TestICal.ics")); 22 | Assert.Single(Result.AttendeeList); 23 | Assert.Equal("EMPLOYEE-A@EXAMPLE.COM", Result.AttendeeList[0].EmailAddress); 24 | Assert.False(Result.Cancel); 25 | Assert.Equal("Project XYZ Review Meeting", Result.Content); 26 | Assert.Equal("Project XYZ Review Meeting", Result.Description); 27 | Assert.Equal(new DateTime(1998, 3, 12, 9, 30, 0) + TimeZone.BaseUtcOffset, Result.EndTime); 28 | Assert.Equal("1CP Conference Room 4350", Result.Location); 29 | Assert.Equal("", Result.Meta); 30 | Assert.Equal("MRBIG@EXAMPLE.COM", Result.Organizer.EmailAddress); 31 | Assert.Equal(new DateTime(1998, 3, 12, 8, 30, 0) + TimeZone.BaseUtcOffset, Result.StartTime); 32 | Assert.Equal("BUSY", Result.Status); 33 | Assert.Equal("XYZ Project Review", Result.Subject); 34 | Assert.Equal("XYZ Project Review", Result.Title); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/ICalendar/ICalWriter.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.Data; 2 | using FileCurator.Formats.ICal; 3 | using FileCurator.Tests.BaseClasses; 4 | using System; 5 | using System.IO; 6 | using Xunit; 7 | 8 | namespace FileCurator.Tests.Formats.ICalendar 9 | { 10 | public class ICalWriterTests : TestBaseClass 11 | { 12 | public ICalWriterTests() 13 | { 14 | TestObject = new ICalendarWriter(); 15 | } 16 | 17 | [Fact] 18 | public void WriteACalendar() 19 | { 20 | Directory.CreateDirectory("./Results"); 21 | var TestObject = new ICalendarWriter(); 22 | var ResultReader = new ICalendarReader(); 23 | using (var ResultFile = File.Open("./Results/WriteACalendar.ics", FileMode.OpenOrCreate)) 24 | { 25 | Assert.True(TestObject.Write(ResultFile, new GenericCalendar 26 | { 27 | Description = "This is my description of the event", 28 | EndTime = new DateTime(2017, 1, 1, 15, 0, 0), 29 | StartTime = new DateTime(2017, 1, 1, 12, 20, 0), 30 | Subject = "This is my subject", 31 | Location = "That Place" 32 | })); 33 | } 34 | using (var ResultFile = File.Open("./Results/WriteACalendar.ics", FileMode.OpenOrCreate)) 35 | { 36 | var Result = ResultReader.Read(ResultFile); 37 | Assert.Equal("This is my description of the event", Result.Description); 38 | Assert.Equal(new DateTime(2017, 1, 1, 15, 0, 0), Result.EndTime); 39 | Assert.Equal(new DateTime(2017, 1, 1, 12, 20, 0), Result.StartTime); 40 | Assert.Equal("This is my subject", Result.Subject); 41 | Assert.Equal("That Place", Result.Location); 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/Mime/MimeFormatTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.Mime; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.IO; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Formats.Mime 7 | { 8 | public class MimeFormatTests : TestBaseClass 9 | { 10 | public MimeFormatTests() 11 | { 12 | TestObject = new MimeFormat(); 13 | } 14 | 15 | [Fact] 16 | public void Read() 17 | { 18 | var TestObject = new MimeFormat(); 19 | using var TestFile = File.OpenRead("./TestData/TestEml.eml"); 20 | var Result = TestObject.Read(TestFile); 21 | Assert.NotNull(Result.ToString()); 22 | } 23 | 24 | [Fact] 25 | public void Write() 26 | { 27 | Directory.CreateDirectory("./Results"); 28 | var TestObject = new MimeFormat(); 29 | using var ResultFile = File.Open("./Results/TestEML.eml", FileMode.OpenOrCreate); 30 | using var TestFile = File.OpenRead("./TestData/TestEml.eml"); 31 | Assert.False(TestObject.Write(ResultFile, TestObject.Read(TestFile))); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/PDF/PDFReaderTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.PDF; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.IO; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Formats.PDF 7 | { 8 | public class PDFReaderTests : TestBaseClass 9 | { 10 | public PDFReaderTests() 11 | { 12 | TestObject = new PDFReader(); 13 | } 14 | 15 | [Fact] 16 | public void Read() 17 | { 18 | var TestObject = new PDFReader(); 19 | FileCurator.Formats.Data.Interfaces.IGenericFile Result = TestObject.Read(File.OpenRead("./TestData/TestPDF.pdf")); 20 | Assert.Equal("This is a test docx", Result.Content.Trim()); 21 | Assert.Equal("Title of doc", Result.Title); 22 | Assert.Equal("tag 1", Result.Meta); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/PowerPoint/PowerPointFormatTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.PowerPoint; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.IO; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Formats.PowerPoint 7 | { 8 | public class PowerPointFormatTests : TestBaseClass 9 | { 10 | public PowerPointFormatTests() 11 | { 12 | TestObject = new PowerPointFormat(); 13 | } 14 | 15 | [Fact] 16 | public void ReadPPSX() 17 | { 18 | var TestObject = new PowerPointFormat(); 19 | using var TestFile = File.OpenRead("./TestData/TestPPSX.ppsx"); 20 | var Result = TestObject.Read(TestFile); 21 | Assert.Equal(" rewqqawer vcxzasdf\n Asdfpof\t\t fadsasasdfasdf\n This is a test Testing", Result.ToString()); 22 | Assert.Equal("Asdfpof\t\t", Result.Title); 23 | } 24 | 25 | [Fact] 26 | public void ReadPPTX() 27 | { 28 | var TestObject = new PowerPointFormat(); 29 | using var TestFile = File.OpenRead("./TestData/TestPPTX.pptx"); 30 | var Result = TestObject.Read(TestFile); 31 | Assert.Equal(" YAYYYAYAYAYA asdfoidpasfoasdfhjoidpasfhhf\n Title1 Something something darkside", Result.ToString()); 32 | Assert.Equal("Title1", Result.Title); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/RSS/RSSReaderTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.RSS; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.IO; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Formats.RSS 7 | { 8 | public class RSSReaderTests : TestBaseClass 9 | { 10 | public RSSReaderTests() 11 | { 12 | TestObject = new RSSReader(); 13 | } 14 | 15 | [Fact] 16 | public void Read() 17 | { 18 | var TestObject = new RSSReader(); 19 | FileCurator.Formats.Data.Interfaces.IFeed Result = TestObject.Read(File.OpenRead("./TestData/TestRSS.rss")); 20 | _ = Assert.Single(Result); 21 | Assert.Equal(10, Result.Channels[0].Count); 22 | Assert.Equal(11957, Result.Content.ReplaceLineEndings("\n").Length); 23 | } 24 | 25 | [Fact] 26 | public void Read2() 27 | { 28 | var TestObject = new RSSReader(); 29 | FileCurator.Formats.Data.Interfaces.IFeed Result = TestObject.Read(File.OpenRead("./TestData/TestRSS2.rss")); 30 | _ = Assert.Single(Result); 31 | Assert.Equal(50, Result.Channels[0].Count); 32 | Assert.Equal(15485, Result.Content.ReplaceLineEndings("\n").Length); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/RSS/RSSWriterTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.RSS; 2 | using FileCurator.Formats.Txt; 3 | using FileCurator.Tests.BaseClasses; 4 | using System.IO; 5 | using Xunit; 6 | 7 | namespace FileCurator.Tests.Formats.RSS 8 | { 9 | public class RSSWriterTests : TestBaseClass 10 | { 11 | public RSSWriterTests() 12 | { 13 | TestObject = new RSSWriter(); 14 | } 15 | 16 | [Fact] 17 | public void WriteAFeed() 18 | { 19 | _ = Directory.CreateDirectory("./Results"); 20 | var TestObject = new RSSWriter(); 21 | var TestReader = new RSSReader(); 22 | var ResultReader = new RSSReader(); 23 | using (FileStream ResultFile = File.Open("./Results/WriteAFeed.rss", FileMode.OpenOrCreate)) 24 | { 25 | using FileStream TestFile = File.OpenRead("./TestData/TestRSS.rss"); 26 | Assert.True(TestObject.Write(ResultFile, TestReader.Read(TestFile))); 27 | } 28 | using (FileStream ResultFile = File.Open("./Results/WriteAFeed.rss", FileMode.OpenOrCreate)) 29 | { 30 | FileCurator.Formats.Data.Interfaces.IFeed Result = ResultReader.Read(ResultFile); 31 | _ = Assert.Single(Result); 32 | Assert.Equal(10, Result.Channels[0].Count); 33 | Assert.Equal(11957, Result.Content.ReplaceLineEndings("\n").Length); 34 | } 35 | } 36 | 37 | [Fact] 38 | public void WriteNotAFeed() 39 | { 40 | _ = Directory.CreateDirectory("./Results"); 41 | var TestObject = new RSSWriter(); 42 | var TestReader = new TxtReader(); 43 | using FileStream ResultFile = File.Open("./Results/WriteAFeed.rss", FileMode.OpenOrCreate); 44 | using FileStream TestFile = File.OpenRead("./TestData/TestTXT.txt"); 45 | Assert.False(TestObject.Write(ResultFile, TestReader.Read(TestFile))); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/Txt/TxtFormatTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.Txt; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.IO; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Formats.Txt 7 | { 8 | public class TxtFormatTests : TestBaseClass 9 | { 10 | public TxtFormatTests() 11 | { 12 | TestObject = new TxtFormat(); 13 | } 14 | 15 | [Fact] 16 | public void ReadWrite() 17 | { 18 | Directory.CreateDirectory("./Results"); 19 | var TestObject = new TxtFormat(); 20 | using (var ResultFile = File.Open("./Results/TxtWrite.txt", FileMode.OpenOrCreate)) 21 | { 22 | using var TestFile = File.OpenRead("./TestData/TestTXT.txt"); 23 | Assert.True(TestObject.Write(ResultFile, TestObject.Read(TestFile))); 24 | } 25 | using (var ResultFile = File.Open("./Results/TxtWrite.txt", FileMode.OpenOrCreate)) 26 | { 27 | var Result = TestObject.Read(ResultFile); 28 | Assert.Equal("This is a test docx", Result.ToString()); 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/VCalendar/VCalReader.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.VCalendar; 2 | using FileCurator.Tests.BaseClasses; 3 | using System; 4 | using System.IO; 5 | using Xunit; 6 | 7 | namespace FileCurator.Tests.Formats.VCalendar 8 | { 9 | public class VCalReader : TestBaseClass 10 | { 11 | public VCalReader() 12 | { 13 | TestObject = new VCalendarReader(); 14 | } 15 | 16 | [Fact] 17 | public void Read() 18 | { 19 | var TimeZone = TimeZoneInfo.Local; 20 | var TestObject = new VCalendarReader(); 21 | var Result = TestObject.Read(File.OpenRead("./TestData/TestVCal.vcs")); 22 | Assert.Empty(Result.AttendeeList); 23 | Assert.False(Result.Cancel); 24 | Assert.Equal("Networld+Interop Conference and Exhibit\nAtlanta World Congress Center\n Atlanta, Georgia", Result.Content); 25 | Assert.Equal("Networld+Interop Conference and Exhibit\nAtlanta World Congress Center\n Atlanta, Georgia", Result.Description); 26 | Assert.Equal(new DateTime(1996, 9, 20, 22, 0, 0) + TimeZone.BaseUtcOffset, Result.EndTime); 27 | Assert.Null(Result.Location); 28 | Assert.Equal("", Result.Meta); 29 | Assert.Null(Result.Organizer); 30 | Assert.Equal(new DateTime(1996, 9, 18, 14, 30, 0) + TimeZone.BaseUtcOffset, Result.StartTime); 31 | Assert.Equal("BUSY", Result.Status); 32 | Assert.Equal("Networld+Interop Conference", Result.Subject); 33 | Assert.Equal("Networld+Interop Conference", Result.Title); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/VCalendar/VCalWriter.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.Data; 2 | using FileCurator.Formats.VCalendar; 3 | using FileCurator.Tests.BaseClasses; 4 | using System; 5 | using System.IO; 6 | using Xunit; 7 | 8 | namespace FileCurator.Tests.Formats.VCalendar 9 | { 10 | public class VCalWriterTests : TestBaseClass 11 | { 12 | public VCalWriterTests() 13 | { 14 | TestObject = new VCalendarWriter(); 15 | } 16 | 17 | [Fact] 18 | public void WriteACalendar() 19 | { 20 | Directory.CreateDirectory("./Results"); 21 | var TestObject = new VCalendarWriter(); 22 | var ResultReader = new VCalendarReader(); 23 | using (var ResultFile = File.Open("./Results/WriteACalendar.vcs", FileMode.OpenOrCreate)) 24 | { 25 | Assert.True(TestObject.Write(ResultFile, new GenericCalendar 26 | { 27 | Description = "This is my description of the event", 28 | EndTime = new DateTime(2017, 1, 1, 15, 0, 0), 29 | StartTime = new DateTime(2017, 1, 1, 12, 20, 0), 30 | Subject = "This is my subject", 31 | Location = "That Place" 32 | })); 33 | } 34 | using (var ResultFile = File.Open("./Results/WriteACalendar.vcs", FileMode.OpenOrCreate)) 35 | { 36 | var Result = ResultReader.Read(ResultFile); 37 | Assert.Equal("This is my description of the event", Result.Description); 38 | Assert.Equal(new DateTime(2017, 1, 1, 15, 0, 0), Result.EndTime); 39 | Assert.Equal(new DateTime(2017, 1, 1, 12, 20, 0), Result.StartTime); 40 | Assert.Equal("This is my subject", Result.Subject); 41 | Assert.Equal("That Place", Result.Location); 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Formats/VCard/VCardReader.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.VCard; 2 | using FileCurator.Tests.BaseClasses; 3 | using System.IO; 4 | using Xunit; 5 | 6 | namespace FileCurator.Tests.Formats.VCard 7 | { 8 | public class VCardReaderTests : TestBaseClass 9 | { 10 | public VCardReaderTests() 11 | { 12 | TestObject = new VCardReader(); 13 | } 14 | 15 | [Fact] 16 | public void Read() 17 | { 18 | var TestObject = new VCardReader(); 19 | var Result = TestObject.Read(File.OpenRead("./TestData/TestVCF.vcf")); 20 | Assert.Contains(Result.DirectDial, x => x.Type == "HOME,VOICE" && x.Number == "555-555-1111"); 21 | Assert.Contains(Result.DirectDial, x => x.Type == "WORK,VOICE" && x.Number == "555-555-1112"); 22 | Assert.Contains(Result.DirectDial, x => x.Type == "CELL,VOICE" && x.Number == "555-555-1113"); 23 | Assert.Contains(Result.Email, x => x.Type == "HOME" && x.EmailAddress == "home@example.com"); 24 | Assert.Contains(Result.Email, x => x.Type == "WORK" && x.EmailAddress == "work@example.com"); 25 | Assert.Contains(Result.Addresses, x => x.Type == "WORK" && x.Street == "WorkStreet"); 26 | Assert.Equal("FirstName", Result.FirstName); 27 | Assert.Equal("Prefix FirstName MiddleName LastName Suffix", Result.FullName); 28 | Assert.Equal("LastName", Result.LastName); 29 | Assert.Equal("MiddleName", Result.MiddleName); 30 | Assert.Equal("Organization2;Department2", Result.Organization); 31 | Assert.Equal("Prefix", Result.Prefix); 32 | Assert.Empty(Result.Relationships); 33 | Assert.Equal("Suffix", Result.Suffix); 34 | Assert.Equal("Title2", Result.Title); 35 | Assert.Equal("http://www.custom.com", Result.Url); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /FileCurator.Tests/HelperMethods/InternalHttpClientFactoryTests.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.HelperMethods; 2 | using FileCurator.Tests.BaseClasses; 3 | using Mecha.xUnit; 4 | using System.ComponentModel.DataAnnotations; 5 | using Xunit; 6 | 7 | namespace FileCurator.Tests.HelperMethods 8 | { 9 | public class InternalHttpClientFactoryTests : TestBaseClass 10 | { 11 | public InternalHttpClientFactoryTests() 12 | { 13 | TestObject = new InternalHttpClientFactory(); 14 | } 15 | 16 | [Property] 17 | public void ClientAlwaysTheSame(Credentials credentials) 18 | { 19 | var Result1 = TestObject.GetClient(credentials); 20 | var Result2 = TestObject.GetClient(credentials); 21 | Assert.Same(Result1, Result2); 22 | } 23 | 24 | [Property] 25 | public void ClientAlwaysTheSameWhenCopied([Required] Credentials credentials) 26 | { 27 | var Result1 = TestObject.GetClient(credentials); 28 | var Result2 = TestObject.GetClient(new Credentials { UseDefaultCredentials = credentials.UseDefaultCredentials, Domain = credentials.Domain, Password = credentials.Password, UserName = credentials.UserName }); 29 | Assert.Same(Result1, Result2); 30 | } 31 | 32 | [Property] 33 | public void CredentialsReturnValid(Credentials credentials) 34 | { 35 | var Result = TestObject.GetClient(credentials); 36 | Assert.NotNull(Result); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /FileCurator.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following set of attributes. 5 | // Change these attribute values to modify the information associated with an assembly. 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("")] 8 | [assembly: AssemblyProduct("FileCurator.Tests")] 9 | [assembly: AssemblyTrademark("")] 10 | 11 | // Setting ComVisible to false makes the types in this assembly not visible to COM components. If you 12 | // need to access a type in this assembly from COM, set the ComVisible attribute to true on that type. 13 | [assembly: ComVisible(false)] 14 | 15 | // The following GUID is for the ID of the typelib if this project is exposed to COM 16 | [assembly: Guid("92a08683-de2a-4d41-9713-eb766589329e")] -------------------------------------------------------------------------------- /FileCurator.Tests/Resources/TextFile1.txt: -------------------------------------------------------------------------------- 1 | This is a resource file test. -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestCSV.csv: -------------------------------------------------------------------------------- 1 | Header 1,Header 2,Header 3,Header 4,Header 5,Header 6 2 | This,is,a,test,CSV,file 3 | Tons,of,data,in here,is,super 4 | important -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestDOCX.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/FileCurator.Tests/TestData/TestDOCX.docx -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestDefault.boop: -------------------------------------------------------------------------------- 1 | No idea what this file should be so just do the default. -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestICal.ics: -------------------------------------------------------------------------------- 1 | BEGIN:VCALENDAR 2 | PRODID:-//RDU Software//NONSGML HandCal//EN 3 | VERSION:2.0 4 | BEGIN:VTIMEZONE 5 | TZID:America/New_York 6 | BEGIN:STANDARD 7 | DTSTART:19981025T020000 8 | TZOFFSETFROM:-0400 9 | TZOFFSETTO:-0500 10 | TZNAME:EST 11 | END:STANDARD 12 | BEGIN:DAYLIGHT 13 | DTSTART:19990404T020000 14 | TZOFFSETFROM:-0500 15 | TZOFFSETTO:-0400 16 | TZNAME:EDT 17 | END:DAYLIGHT 18 | END:VTIMEZONE 19 | BEGIN:VEVENT 20 | DTSTAMP:19980309T231000Z 21 | UID:guid-1.example.com 22 | ORGANIZER:mailto:mrbig@example.com 23 | ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:mailto:employee-A@example.com 24 | DESCRIPTION:Project XYZ Review Meeting 25 | CATEGORIES:MEETING 26 | CLASS:PUBLIC 27 | CREATED:19980309T130000Z 28 | SUMMARY:XYZ Project Review 29 | DTSTART;TZID=America/New_York:19980312T083000 30 | DTEND;TZID=America/New_York:19980312T093000 31 | LOCATION:1CP Conference Room 4350 32 | END:VEVENT 33 | END:VCALENDAR -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestMSG.msg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/FileCurator.Tests/TestData/TestMSG.msg -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestPDF.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/FileCurator.Tests/TestData/TestPDF.pdf -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestPPSX.ppsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/FileCurator.Tests/TestData/TestPPSX.ppsx -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestPPTX.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/FileCurator.Tests/TestData/TestPPTX.pptx -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestTXT.txt: -------------------------------------------------------------------------------- 1 | This is a test docx -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestVCal.vcs: -------------------------------------------------------------------------------- 1 | BEGIN:VCALENDAR 2 | PRODID:-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN 3 | VERSION:2.0 4 | BEGIN:VEVENT 5 | DTSTAMP:19960704T120000Z 6 | UID:uid1@example.com 7 | ORGANIZER:mailto:jsmith@example.com 8 | DTSTART:19960918T143000Z 9 | DTEND:19960920T220000Z 10 | STATUS:CONFIRMED 11 | CATEGORIES:CONFERENCE 12 | SUMMARY:Networld+Interop Conference 13 | DESCRIPTION:Networld+Interop Conference and Exhibit\nAtlanta World Congress Center\n Atlanta\, Georgia 14 | END:VEVENT 15 | END:VCALENDAR -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestXLSX.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/FileCurator.Tests/TestData/TestXLSX.xlsx -------------------------------------------------------------------------------- /FileCurator.Tests/TestData/TestXML.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | getstaffonline 4 | success 5 | 1 6 | 7 | 8 | Admin 9 | 2010-03-03 18:29:12 10 | 127.0.0.1 11 | 2010-03-03 18:30:43 12 | 13 | 14 | -------------------------------------------------------------------------------- /FileCurator.Tests/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", 3 | "parallelizeTestCollections": true 4 | } -------------------------------------------------------------------------------- /FileCurator/BaseClasses/LocalFileSystemBase.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Default; 18 | using FileCurator.HelperMethods; 19 | using FileCurator.Interfaces; 20 | 21 | namespace FileCurator.BaseClasses 22 | { 23 | /// 24 | /// Local file system base class 25 | /// 26 | /// 27 | public abstract class LocalFileSystemBase : FileSystemBase 28 | { 29 | /// 30 | /// Constructor 31 | /// 32 | protected LocalFileSystemBase() 33 | { 34 | } 35 | 36 | /// 37 | /// Gets the directory representation for the directory 38 | /// 39 | /// Path to the directory 40 | /// The credentials. 41 | /// The directory object 42 | public override IDirectory Directory(string path, Credentials? credentials = null) 43 | { 44 | return new LocalDirectory(AbsolutePath(path).RemoveIllegalDirectoryNameCharacters()); 45 | } 46 | 47 | /// 48 | /// Gets the class representation for the file 49 | /// 50 | /// Path to the file 51 | /// The credentials. 52 | /// The file object 53 | public override IFile File(string path, Credentials? credentials = null) 54 | { 55 | return new LocalFile(AbsolutePath(path)); 56 | } 57 | 58 | /// 59 | /// Performs application-defined tasks associated with freeing, releasing, or resetting 60 | /// unmanaged resources. 61 | /// 62 | /// 63 | /// true to release both managed and unmanaged resources; false to release 64 | /// only unmanaged resources. 65 | /// 66 | protected override void Dispose(bool managed) 67 | { 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /FileCurator/Default/Ftp/FtpFileSystem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.BaseClasses; 18 | using FileCurator.Interfaces; 19 | 20 | namespace FileCurator.Default.Ftp 21 | { 22 | /// 23 | /// Ftp file system 24 | /// 25 | /// 26 | public class FtpFileSystem : FileSystemBase 27 | { 28 | /// 29 | /// Name of the file system 30 | /// 31 | public override string Name { get; } = "FTP"; 32 | 33 | /// 34 | /// Gets the order (lower numbers occur first). 35 | /// 36 | /// The order. 37 | public override int Order { get; } = int.MaxValue; 38 | 39 | /// 40 | /// Relative starter 41 | /// 42 | protected override string HandleRegexString { get; } = "^ftps?://"; 43 | 44 | /// 45 | /// Gets the directory representation for the directory 46 | /// 47 | /// Path to the directory 48 | /// The credentials. 49 | /// The directory object 50 | public override IDirectory Directory(string path, Credentials? credentials = null) 51 | { 52 | return new FtpDirectory(AbsolutePath(path), credentials); 53 | } 54 | 55 | /// 56 | /// Gets the class representation for the file 57 | /// 58 | /// Path to the file 59 | /// The credentials. 60 | /// The file object 61 | public override IFile File(string path, Credentials? credentials = null) 62 | { 63 | return new FtpFile(AbsolutePath(path), credentials); 64 | } 65 | 66 | /// 67 | /// Gets the absolute path of the variable passed in 68 | /// 69 | /// Path to convert to absolute 70 | /// The absolute path of the path passed in 71 | protected override string AbsolutePath(string path) => path; 72 | 73 | /// 74 | /// Used to dispose of any resources 75 | /// 76 | protected override void Dispose(bool managed) 77 | { 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /FileCurator/Default/Local/AbsoluteFileSystem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.BaseClasses; 18 | 19 | namespace FileCurator.Default 20 | { 21 | /// 22 | /// Absolute local file system 23 | /// 24 | public class AbsoluteLocalFileSystem : LocalFileSystemBase 25 | { 26 | /// 27 | /// Name of the file system 28 | /// 29 | public override string Name { get; } = "Absolute Local"; 30 | 31 | /// 32 | /// Gets the order (lower numbers occur first). 33 | /// 34 | /// The order. 35 | public override int Order { get; } = int.MaxValue; 36 | 37 | /// 38 | /// Relative starter 39 | /// 40 | protected override string HandleRegexString { get; } = @"^\w:"; 41 | 42 | /// 43 | /// Gets the absolute path of the variable passed in 44 | /// 45 | /// Path to convert to absolute 46 | /// The absolute path of the path passed in 47 | protected override string AbsolutePath(string path) => path; 48 | } 49 | } -------------------------------------------------------------------------------- /FileCurator/Default/Local/NetworkFileSystem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.BaseClasses; 18 | 19 | namespace FileCurator.Default 20 | { 21 | /// 22 | /// Network file system 23 | /// 24 | public class NetworkFileSystem : LocalFileSystemBase 25 | { 26 | /// 27 | /// Name of the file system 28 | /// 29 | public override string Name { get; } = "Network"; 30 | 31 | /// 32 | /// Gets the order (lower numbers occur first). 33 | /// 34 | /// The order. 35 | public override int Order { get; } = int.MaxValue; 36 | 37 | /// 38 | /// Relative starter 39 | /// 40 | protected override string HandleRegexString { get; } = @"^\\"; 41 | 42 | /// 43 | /// Gets the absolute path of the variable passed in 44 | /// 45 | /// Path to convert to absolute 46 | /// The absolute path of the path passed in 47 | protected override string AbsolutePath(string path) => path; 48 | } 49 | } -------------------------------------------------------------------------------- /FileCurator/Default/Local/RelativeLocalFileSystem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.BaseClasses; 18 | using System; 19 | using System.IO; 20 | 21 | namespace FileCurator.Default 22 | { 23 | /// 24 | /// Relative local file system 25 | /// 26 | public class RelativeLocalFileSystem : LocalFileSystemBase 27 | { 28 | /// 29 | /// Name of the file system 30 | /// 31 | public override string Name { get; } = "Relative Local"; 32 | 33 | /// 34 | /// Gets the order (lower numbers occur first). 35 | /// 36 | /// The order. 37 | public override int Order { get; } = int.MaxValue; 38 | 39 | /// 40 | /// Relative starter 41 | /// 42 | protected override string HandleRegexString { get; } = @"^[~|\.]"; 43 | 44 | /// 45 | /// Gets the absolute path of the variable passed in 46 | /// 47 | /// Path to convert to absolute 48 | /// The absolute path of the path passed in 49 | protected override string AbsolutePath(string path) 50 | { 51 | if (string.IsNullOrEmpty(path)) 52 | return path; 53 | path = path.Replace('/', Path.DirectorySeparatorChar); 54 | var BaseDirectory = new System.IO.DirectoryInfo(".").FullName; 55 | var ParentDirectory = new LocalDirectory(BaseDirectory).Parent.FullName; 56 | if (path.StartsWith(".." + Path.DirectorySeparatorChar, StringComparison.Ordinal)) 57 | { 58 | return ParentDirectory + path.Remove(0, 2); 59 | } 60 | else if (path.StartsWith("." + Path.DirectorySeparatorChar, StringComparison.Ordinal)) 61 | { 62 | return BaseDirectory + path.Remove(0, 1); 63 | } 64 | else if (path.StartsWith("~" + Path.DirectorySeparatorChar, StringComparison.Ordinal)) 65 | { 66 | return BaseDirectory + path.Remove(0, 1); 67 | } 68 | return path; 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /FileCurator/Default/Memory/MemoryFileSystem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.BaseClasses; 18 | 19 | namespace FileCurator.Default.Memory 20 | { 21 | /// 22 | /// Temporary file system held in memory (this is not for memory mapped files) 23 | /// 24 | /// 25 | public class MemoryFileSystem : FileSystemBase 26 | { 27 | /// 28 | /// Name of the file system 29 | /// 30 | public override string Name { get; } = "Memory"; 31 | 32 | /// 33 | /// Gets the order (lower numbers occur first). 34 | /// 35 | /// The order. 36 | public override int Order { get; } = int.MaxValue; 37 | 38 | /// 39 | /// Regex string used to determine if the file system can handle the path 40 | /// 41 | protected override string HandleRegexString { get; } = "^mem://"; 42 | 43 | /// 44 | /// Gets the directory representation for the directory 45 | /// 46 | /// Path to the directory 47 | /// The credentials. 48 | /// The directory object 49 | public override Interfaces.IDirectory Directory(string path, Credentials? credentials = null) => new MemoryDirectory(path, credentials); 50 | 51 | /// 52 | /// Gets the class representation for the file 53 | /// 54 | /// Path to the file 55 | /// The credentials. 56 | /// The file object 57 | public override Interfaces.IFile File(string path, Credentials? credentials = null) => new MemoryFile(path, credentials); 58 | 59 | /// 60 | /// Gets the absolute path of the variable passed in 61 | /// 62 | /// Path to convert to absolute 63 | /// The absolute path of the path passed in 64 | protected override string AbsolutePath(string path) => path; 65 | 66 | /// 67 | /// Function to override in order to dispose objects 68 | /// 69 | protected override void Dispose(bool managed) 70 | { 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /FileCurator/Default/Resource/ResourceFileSystem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.BaseClasses; 18 | 19 | namespace FileCurator.Default 20 | { 21 | /// 22 | /// Resource file system 23 | /// 24 | public class ResourceFileSystem : FileSystemBase 25 | { 26 | /// 27 | /// Name of the file system 28 | /// 29 | public override string Name { get; } = "Resource File System"; 30 | 31 | /// 32 | /// Gets the order (lower numbers occur first). 33 | /// 34 | /// The order. 35 | public override int Order { get; } = int.MaxValue; 36 | 37 | /// 38 | /// Regex string used to determine if the file system can handle the path 39 | /// 40 | protected override string HandleRegexString { get; } = "^resource://"; 41 | 42 | /// 43 | /// Gets the directory representation for the directory 44 | /// 45 | /// Path to the directory 46 | /// The credentials. 47 | /// The directory object 48 | public override Interfaces.IDirectory Directory(string path, Credentials credentials = null) => new ResourceDirectory(path, credentials); 49 | 50 | /// 51 | /// Gets the class representation for the file 52 | /// 53 | /// Path to the file 54 | /// The credentials. 55 | /// The file object 56 | public override Interfaces.IFile File(string path, Credentials credentials = null) => new ResourceFile(path, credentials); 57 | 58 | /// 59 | /// Gets the absolute path of the variable passed in 60 | /// 61 | /// Path to convert to absolute 62 | /// The absolute path of the path passed in 63 | protected override string AbsolutePath(string path) => path; 64 | 65 | /// 66 | /// Function to override in order to dispose objects 67 | /// 68 | protected override void Dispose(bool managed) 69 | { 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /FileCurator/Enums/CopyOptions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Enums 18 | { 19 | /// 20 | /// Options used in directory copying 21 | /// 22 | public enum CopyOptions 23 | { 24 | /// 25 | /// Copy if newer than the DateTime specified 26 | /// 27 | CopyIfNewer, 28 | 29 | /// 30 | /// Copy always 31 | /// 32 | CopyAlways, 33 | 34 | /// 35 | /// Do not overwrite a file 36 | /// 37 | DoNotOverwrite 38 | } 39 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Address.cs: -------------------------------------------------------------------------------- 1 | using FileCurator.Formats.Data.Interfaces; 2 | 3 | namespace FileCurator.Formats.Data 4 | { 5 | /// 6 | /// Address class 7 | /// 8 | /// 9 | public class Address : IAddress 10 | { 11 | /// 12 | /// Gets or sets the city. 13 | /// 14 | /// The city. 15 | public string? City { get; set; } 16 | 17 | /// 18 | /// Gets or sets the country. 19 | /// 20 | /// The country. 21 | public string? Country { get; set; } 22 | 23 | /// 24 | /// Gets or sets the name. 25 | /// 26 | /// The name. 27 | public string? Name { get; set; } 28 | 29 | /// 30 | /// Gets or sets the state or provence. 31 | /// 32 | /// The state or provence. 33 | public string? StateOrProvence { get; set; } 34 | 35 | /// 36 | /// Gets or sets the street. 37 | /// 38 | /// The street. 39 | public string? Street { get; set; } 40 | 41 | /// 42 | /// Gets or sets the type. 43 | /// 44 | /// The type. 45 | public string? Type { get; set; } 46 | 47 | /// 48 | /// Gets or sets the area code. 49 | /// 50 | /// The area code. 51 | public string? ZipCode { get; set; } 52 | } 53 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Enums/Relationship.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Enums 18 | { 19 | /// 20 | /// Enum defining relationships (used for XFN markup) 21 | /// 22 | public enum Relationship 23 | { 24 | /// 25 | /// Friend 26 | /// 27 | Friend, 28 | 29 | /// 30 | /// Acquaintance 31 | /// 32 | Acquaintance, 33 | 34 | /// 35 | /// Contact 36 | /// 37 | Contact, 38 | 39 | /// 40 | /// Met 41 | /// 42 | Met, 43 | 44 | /// 45 | /// Coworker 46 | /// 47 | CoWorker, 48 | 49 | /// 50 | /// Colleague 51 | /// 52 | Colleague, 53 | 54 | /// 55 | /// Coresident 56 | /// 57 | CoResident, 58 | 59 | /// 60 | /// Neighbor 61 | /// 62 | Neighbor, 63 | 64 | /// 65 | /// Child 66 | /// 67 | Child, 68 | 69 | /// 70 | /// Parent 71 | /// 72 | Parent, 73 | 74 | /// 75 | /// Sibling 76 | /// 77 | Sibling, 78 | 79 | /// 80 | /// Spouse 81 | /// 82 | Spouse, 83 | 84 | /// 85 | /// Kin 86 | /// 87 | Kin, 88 | 89 | /// 90 | /// Muse 91 | /// 92 | Muse, 93 | 94 | /// 95 | /// Crush 96 | /// 97 | Crush, 98 | 99 | /// 100 | /// Date 101 | /// 102 | Date, 103 | 104 | /// 105 | /// Sweetheart 106 | /// 107 | Sweetheart, 108 | 109 | /// 110 | /// Me 111 | /// 112 | Me 113 | } 114 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/FixedLength/BaseClasses/FieldBaseClass.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Data.FixedLength.Interfaces; 18 | 19 | namespace FileCurator.Data.FixedLength.BaseClasses 20 | { 21 | /// 22 | /// Field base class 23 | /// 24 | /// The type of the field. 25 | /// 26 | public abstract class FieldBaseClass : IField 27 | { 28 | /// 29 | /// Gets or sets the length. 30 | /// 31 | /// The length. 32 | public int Length { get; set; } 33 | 34 | /// 35 | /// Gets or sets the value. 36 | /// 37 | /// The value. 38 | public TField Value { get; set; } 39 | 40 | /// 41 | /// Parses the specified value. 42 | /// 43 | /// The value. 44 | /// The length. 45 | /// The filler character. 46 | public abstract void Parse(string value, int length = -1, string fillerCharacter = " "); 47 | 48 | /// 49 | /// Returns a that represents this instance. 50 | /// 51 | /// A that represents this instance. 52 | public override string ToString() => Value.ToString(); 53 | } 54 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/FixedLength/BaseClasses/FixedLengthBaseClass.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Data.FixedLength.Interfaces; 18 | using FileCurator.Formats.Data.BaseClasses; 19 | using System.Collections.Generic; 20 | using System.Text; 21 | 22 | namespace FileCurator.Data.FixedLength.BaseClasses 23 | { 24 | /// 25 | /// Fixed length base class 26 | /// 27 | /// 28 | public abstract class FixedLengthBaseClass : FileBaseClass 29 | { 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | protected FixedLengthBaseClass() 34 | { 35 | Records = new List(); 36 | } 37 | 38 | /// 39 | /// Gets or sets the records. 40 | /// 41 | /// The records. 42 | protected IList Records { get; set; } 43 | 44 | /// 45 | /// Parses the specified value. 46 | /// 47 | /// The value. 48 | /// The length. 49 | public abstract void Parse(string Value, int Length = -1); 50 | 51 | /// 52 | /// Returns a that represents this instance. 53 | /// 54 | /// A that represents this instance. 55 | public override string ToString() 56 | { 57 | var Builder = new StringBuilder(); 58 | foreach (var Record in Records) 59 | Builder.Append(Record.ToString()); 60 | return Builder.ToString(); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/FixedLength/Interfaces/IField.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Data.FixedLength.Interfaces 18 | { 19 | /// 20 | /// Field interface 21 | /// 22 | /// The type of the field. 23 | public interface IField 24 | { 25 | /// 26 | /// Gets or sets the length. 27 | /// 28 | /// The length. 29 | int Length { get; set; } 30 | 31 | /// 32 | /// Gets or sets the value. 33 | /// 34 | /// The value. 35 | TField Value { get; set; } 36 | 37 | /// 38 | /// Parses the specified value. 39 | /// 40 | /// The value. 41 | /// The length. 42 | /// The filler character. 43 | void Parse(string value, int length = -1, string fillerCharacter = " "); 44 | } 45 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/FixedLength/Interfaces/IRecord.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Data.FixedLength.Interfaces 18 | { 19 | /// 20 | /// Record interface 21 | /// 22 | public interface IRecord 23 | { 24 | /// 25 | /// Gets or sets the length. 26 | /// 27 | /// The length. 28 | int Length { get; set; } 29 | 30 | /// 31 | /// Parses the specified value. 32 | /// 33 | /// The value. 34 | /// The length. 35 | void Parse(string value, int length = -1); 36 | } 37 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/FixedLength/StringField.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using BigBook; 18 | using BigBook.ExtensionMethods; 19 | using FileCurator.Data.FixedLength.BaseClasses; 20 | using System.Text; 21 | 22 | namespace FileCurator.Data.FixedLength 23 | { 24 | /// 25 | /// Basic string field 26 | /// 27 | /// 28 | public class StringField : FieldBaseClass 29 | { 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The value. 34 | /// The length. 35 | public StringField(string value, int length = -1) 36 | { 37 | Parse(value, length); 38 | } 39 | 40 | /// 41 | /// Parses the specified value. 42 | /// 43 | /// The value. 44 | /// The length. 45 | /// The filler character. 46 | public override void Parse(string value, int length = -1, string fillerCharacter = " ") 47 | { 48 | Value = value; 49 | Length = length >= 0 ? length : Value.Length; 50 | if (Value.Length > Length) 51 | { 52 | Value = Value.Left(Length); 53 | return; 54 | } 55 | if (Value.Length == Length) 56 | return; 57 | var Builder = new StringBuilder(); 58 | Builder.Append(Value); 59 | while (Builder.Length < Length) 60 | Builder.Append(fillerCharacter); 61 | Value = Builder.ToString(); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/GenericCell.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using ObjectCartographer; 19 | 20 | namespace FileCurator.Formats.Data 21 | { 22 | /// 23 | /// Generic cell data 24 | /// 25 | /// 26 | public class GenericCell : ICell 27 | { 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The content. 32 | public GenericCell(string content) 33 | { 34 | Content = content; 35 | } 36 | 37 | /// 38 | /// Gets or sets the content. 39 | /// 40 | /// The content. 41 | public string Content { get; set; } 42 | 43 | /// 44 | /// Gets the value as the type specified. 45 | /// 46 | /// The type of the value. 47 | /// The content of the cell as the value type specified. 48 | public TValue GetValue() 49 | { 50 | return Content.To(); 51 | } 52 | 53 | /// 54 | /// Returns a that represents this instance. 55 | /// 56 | /// A that represents this instance. 57 | public override string ToString() => Content; 58 | } 59 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/GenericRow.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using BigBook; 18 | using FileCurator.Formats.Data.Interfaces; 19 | using System.Collections.Generic; 20 | 21 | namespace FileCurator.Formats.Data 22 | { 23 | /// 24 | /// Generic row data 25 | /// 26 | /// 27 | public class GenericRow : IRow 28 | { 29 | /// 30 | /// Gets or sets the cells. 31 | /// 32 | /// The cells. 33 | public IList Cells { get; } = new List(); 34 | 35 | /// 36 | /// Returns a that represents this instance. 37 | /// 38 | /// A that represents this instance. 39 | public override string ToString() => Cells.ToString(x => x.ToString(), " "); 40 | } 41 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/GenericTable.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.BaseClasses; 18 | using System; 19 | 20 | namespace FileCurator.Formats.Data 21 | { 22 | /// 23 | /// Generic table object 24 | /// 25 | /// 26 | public class GenericTable : TableBaseClass 27 | { 28 | /// 29 | /// Compares the object to another object 30 | /// 31 | /// Object to compare to 32 | /// 0 if they are equal, -1 if this is smaller, 1 if it is larger 33 | public override int CompareTo(TableBaseClass other) => string.Compare(other.ToString(), ToString(), StringComparison.OrdinalIgnoreCase); 34 | 35 | /// 36 | /// Determines if the objects are equal 37 | /// 38 | /// Other object to compare to 39 | /// True if they are equal, false otherwise 40 | public override bool Equals(TableBaseClass other) => ToString().Equals(other.ToString(), StringComparison.OrdinalIgnoreCase); 41 | } 42 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/Feed/IEnclosure.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Interfaces 18 | { 19 | /// 20 | /// Enclosure interface 21 | /// 22 | public interface IEnclosure 23 | { 24 | /// 25 | /// Gets or sets the length. 26 | /// 27 | /// The length. 28 | int Length { get; set; } 29 | 30 | /// 31 | /// Gets or sets the type. 32 | /// 33 | /// The type. 34 | string? Type { get; set; } 35 | 36 | /// 37 | /// Gets or sets the URL. 38 | /// 39 | /// The URL. 40 | string? Url { get; set; } 41 | } 42 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/Feed/IFeed.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace FileCurator.Formats.Data.Interfaces 20 | { 21 | /// 22 | /// Feed interface 23 | /// 24 | /// 25 | public interface IFeed : IGenericFile, IList 26 | { 27 | /// 28 | /// Gets the channels. 29 | /// 30 | /// The channels. 31 | IList Channels { get; } 32 | } 33 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/Feed/IFeedGuid.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Interfaces 18 | { 19 | /// 20 | /// Feed Guid 21 | /// 22 | public interface IFeedGuid 23 | { 24 | /// 25 | /// Gets or sets the unique identifier text. 26 | /// 27 | /// The unique identifier text. 28 | string? GuidText { get; set; } 29 | 30 | /// 31 | /// Gets or sets a value indicating whether this instance is perma link. 32 | /// 33 | /// true if this instance is perma link; otherwise, false. 34 | bool IsPermaLink { get; set; } 35 | } 36 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/Feed/IFeedItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | 20 | namespace FileCurator.Formats.Data.Interfaces 21 | { 22 | /// 23 | /// Feed item 24 | /// 25 | public interface IFeedItem 26 | { 27 | /// 28 | /// Gets or sets the author. 29 | /// 30 | /// The author. 31 | string? Author { get; set; } 32 | 33 | /// 34 | /// Gets or sets the categories. 35 | /// 36 | /// The categories. 37 | IList Categories { get; } 38 | 39 | /// 40 | /// Gets the content. 41 | /// 42 | /// The content. 43 | string Content { get; } 44 | 45 | /// 46 | /// Gets or sets the description. 47 | /// 48 | /// The description. 49 | string? Description { get; set; } 50 | 51 | /// 52 | /// Gets or sets the enclosure. 53 | /// 54 | /// The enclosure. 55 | IEnclosure? Enclosure { get; set; } 56 | 57 | /// 58 | /// Gets or sets the unique identifier. 59 | /// 60 | /// The unique identifier. 61 | IFeedGuid? GUID { get; set; } 62 | 63 | /// 64 | /// Gets or sets the link. 65 | /// 66 | /// The link. 67 | string? Link { get; set; } 68 | 69 | /// 70 | /// Gets or sets the pub date. 71 | /// 72 | /// The pub date. 73 | DateTime PubDate { get; set; } 74 | 75 | /// 76 | /// Gets or sets the thumbnail. 77 | /// 78 | /// The thumbnail. 79 | IThumbnail? Thumbnail { get; set; } 80 | 81 | /// 82 | /// Gets or sets the title. 83 | /// 84 | /// The title. 85 | string? Title { get; set; } 86 | } 87 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/Feed/IThumbnail.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Interfaces 18 | { 19 | /// 20 | /// Thumbnail interface 21 | /// 22 | public interface IThumbnail 23 | { 24 | /// 25 | /// Gets or sets the height. 26 | /// 27 | /// The height. 28 | int Height { get; set; } 29 | 30 | /// 31 | /// Gets or sets the URL. 32 | /// 33 | /// The URL. 34 | string? Url { get; set; } 35 | 36 | /// 37 | /// Gets or sets the width. 38 | /// 39 | /// The width. 40 | int Width { get; set; } 41 | } 42 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/IAddress.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Interfaces 18 | { 19 | /// 20 | /// Address interface 21 | /// 22 | public interface IAddress 23 | { 24 | /// 25 | /// Gets or sets the city. 26 | /// 27 | /// The city. 28 | string? City { get; set; } 29 | 30 | /// 31 | /// Gets or sets the country. 32 | /// 33 | /// The country. 34 | string? Country { get; set; } 35 | 36 | /// 37 | /// Gets or sets the name. 38 | /// 39 | /// The name. 40 | string? Name { get; set; } 41 | 42 | /// 43 | /// Gets or sets the state or provence. 44 | /// 45 | /// The state or provence. 46 | string? StateOrProvence { get; set; } 47 | 48 | /// 49 | /// Gets or sets the street. 50 | /// 51 | /// The street. 52 | string? Street { get; set; } 53 | 54 | /// 55 | /// Gets or sets the type. 56 | /// 57 | /// The type. 58 | string? Type { get; set; } 59 | 60 | /// 61 | /// Gets or sets the area code. 62 | /// 63 | /// The area code. 64 | string? ZipCode { get; set; } 65 | } 66 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/ICalendar.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | 20 | namespace FileCurator.Formats.Data.Interfaces 21 | { 22 | /// 23 | /// Calendar item 24 | /// 25 | /// 26 | public interface ICalendar : IGenericFile 27 | { 28 | /// 29 | /// List of attendees 30 | /// 31 | IList AttendeeList { get; } 32 | 33 | /// 34 | /// Determines if the calendar item is being canceled 35 | /// 36 | bool Cancel { get; set; } 37 | 38 | /// 39 | /// The time zone for the calendar event 40 | /// 41 | TimeZoneInfo CurrentTimeZone { get; set; } 42 | 43 | /// 44 | /// Gets the description. 45 | /// 46 | /// The description. 47 | string Description { get; set; } 48 | 49 | /// 50 | /// The end time 51 | /// 52 | DateTime EndTime { get; set; } 53 | 54 | /// 55 | /// The location of the event 56 | /// 57 | string Location { get; set; } 58 | 59 | /// 60 | /// Organizer 61 | /// 62 | IMailAddress Organizer { get; set; } 63 | 64 | /// 65 | /// The start time 66 | /// 67 | DateTime StartTime { get; set; } 68 | 69 | /// 70 | /// Sets the status for the appointment (FREE, BUSY, etc.) 71 | /// 72 | string Status { get; set; } 73 | 74 | /// 75 | /// Gets the subject. 76 | /// 77 | /// The subject. 78 | string Subject { get; set; } 79 | } 80 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/ICard.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Enums; 18 | using FileCurator.Formats.Data.Interface; 19 | using System.Collections.Generic; 20 | 21 | namespace FileCurator.Formats.Data.Interfaces 22 | { 23 | /// 24 | /// Card file type 25 | /// 26 | /// 27 | public interface ICard : IGenericFile 28 | { 29 | /// 30 | /// Gets or sets the addresses. 31 | /// 32 | /// The addresses. 33 | IList Addresses { get; set; } 34 | 35 | /// 36 | /// Work phone number of the individual 37 | /// 38 | IList DirectDial { get; set; } 39 | 40 | /// 41 | /// Email of the individual 42 | /// 43 | IList Email { get; set; } 44 | 45 | /// 46 | /// First name 47 | /// 48 | string FirstName { get; set; } 49 | 50 | /// 51 | /// Gets or sets the full name. 52 | /// 53 | /// The full name. 54 | string FullName { get; } 55 | 56 | /// 57 | /// Last name 58 | /// 59 | string LastName { get; set; } 60 | 61 | /// 62 | /// Middle name 63 | /// 64 | string MiddleName { get; set; } 65 | 66 | /// 67 | /// Organization the person belongs to 68 | /// 69 | string Organization { get; set; } 70 | 71 | /// 72 | /// Prefix 73 | /// 74 | string Prefix { get; set; } 75 | 76 | /// 77 | /// Relationship to the person (uses XFN) 78 | /// 79 | IList Relationships { get; } 80 | 81 | /// 82 | /// Suffix 83 | /// 84 | string Suffix { get; set; } 85 | 86 | /// 87 | /// Gets or sets the title. 88 | /// 89 | /// The title. 90 | new string Title { get; set; } 91 | 92 | /// 93 | /// Url to the person's site 94 | /// 95 | string Url { get; set; } 96 | } 97 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/IGenericFile.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Interfaces 18 | { 19 | /// 20 | /// File interface 21 | /// 22 | public interface IGenericFile 23 | { 24 | /// 25 | /// Parsed content 26 | /// 27 | /// The content. 28 | string Content { get; } 29 | 30 | /// 31 | /// Meta data 32 | /// 33 | /// The meta. 34 | string Meta { get; } 35 | 36 | /// 37 | /// Parsed title 38 | /// 39 | /// The title. 40 | string Title { get; } 41 | } 42 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/IMailAddress.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Interfaces 18 | { 19 | /// 20 | /// Mail address interface 21 | /// 22 | public interface IMailAddress 23 | { 24 | /// 25 | /// Gets or sets the email address. 26 | /// 27 | /// The email address. 28 | string EmailAddress { get; set; } 29 | 30 | /// 31 | /// Gets or sets the name. 32 | /// 33 | /// The name. 34 | string Name { get; set; } 35 | 36 | /// 37 | /// Gets or sets the type. 38 | /// 39 | /// The type. 40 | string Type { get; set; } 41 | } 42 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/IMessage.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | 20 | namespace FileCurator.Formats.Data.Interfaces 21 | { 22 | /// 23 | /// Message interface 24 | /// 25 | /// 26 | public interface IMessage : IGenericFile 27 | { 28 | /// 29 | /// Gets the BCC. 30 | /// 31 | /// The BCC. 32 | IList BCC { get; } 33 | 34 | /// 35 | /// Gets the cc. 36 | /// 37 | /// The cc. 38 | IList CC { get; } 39 | 40 | /// 41 | /// Gets or sets from. 42 | /// 43 | /// From. 44 | string From { get; set; } 45 | 46 | /// 47 | /// Gets or sets the sent. 48 | /// 49 | /// The sent. 50 | DateTime Sent { get; set; } 51 | 52 | /// 53 | /// Gets to. 54 | /// 55 | /// To. 56 | IList To { get; } 57 | } 58 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/IPhoneNumber.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Interface 18 | { 19 | /// 20 | /// Phone number 21 | /// 22 | public interface IPhoneNumber 23 | { 24 | /// 25 | /// Gets or sets the number. 26 | /// 27 | /// The number. 28 | string Number { get; set; } 29 | 30 | /// 31 | /// Gets or sets the type. 32 | /// 33 | /// The type. 34 | string Type { get; set; } 35 | } 36 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/Table/ICell.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.Data.Interfaces 18 | { 19 | /// 20 | /// Cell interface 21 | /// 22 | public interface ICell 23 | { 24 | /// 25 | /// Gets or sets the content. 26 | /// 27 | /// The content. 28 | string Content { get; set; } 29 | 30 | /// 31 | /// Gets the value as the type specified. 32 | /// 33 | /// The type of the value. 34 | /// The content of the cell as the value type specified. 35 | TValue GetValue(); 36 | } 37 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/Table/IRow.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace FileCurator.Formats.Data.Interfaces 20 | { 21 | /// 22 | /// Row interface 23 | /// 24 | public interface IRow 25 | { 26 | /// 27 | /// Gets the cells. 28 | /// 29 | /// The cells. 30 | IList Cells { get; } 31 | } 32 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/Interfaces/Table/ITable.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace FileCurator.Formats.Data.Interfaces 20 | { 21 | /// 22 | /// Table interface 23 | /// 24 | public interface ITable : IGenericFile 25 | { 26 | /// 27 | /// Gets the headers. 28 | /// 29 | /// The headers. 30 | IList Columns { get; } 31 | 32 | /// 33 | /// Gets the data rows. 34 | /// 35 | /// The data rows. 36 | IList Rows { get; } 37 | 38 | /// 39 | /// Converts this instance into the object array of the type specified. 40 | /// 41 | /// The type of the object. 42 | /// The resulting array. 43 | List Convert(); 44 | } 45 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/MailAddress.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | 19 | namespace FileCurator.Formats.Data 20 | { 21 | /// 22 | /// Mail address 23 | /// 24 | /// 25 | public class MailAddress : IMailAddress 26 | { 27 | /// 28 | /// Gets or sets the email address. 29 | /// 30 | /// The email address. 31 | public string EmailAddress { get; set; } 32 | 33 | /// 34 | /// Gets or sets the name. 35 | /// 36 | /// The name. 37 | public string Name { get; set; } 38 | 39 | /// 40 | /// Gets or sets the type. 41 | /// 42 | /// The type. 43 | public string Type { get; set; } 44 | } 45 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Data/PhoneNumber.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interface; 18 | 19 | namespace FileCurator.Formats.Data 20 | { 21 | /// 22 | /// Phone number data holder 23 | /// 24 | /// 25 | public class PhoneNumber : IPhoneNumber 26 | { 27 | /// 28 | /// Gets or sets the number. 29 | /// 30 | /// The number. 31 | public string Number { get; set; } 32 | 33 | /// 34 | /// Gets or sets the type. 35 | /// 36 | /// The type. 37 | public string Type { get; set; } 38 | } 39 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Delimited/DelimitedFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.Delimited 21 | { 22 | /// 23 | /// Delimited file format 24 | /// 25 | /// 26 | public class DelimitedFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "TEXT/CSV", "TEXT/TAB-SEPARATED-VALUES", "TEXT/COMMA-SEPARATED-VALUES", "APPLICATION/CSV" }; 33 | 34 | /// 35 | /// Gets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "Delimited files"; 39 | 40 | /// 41 | /// Gets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "CSV", "TSV", "TAB" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Excel/ExcelFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.Excel 21 | { 22 | /// 23 | /// Excel format 24 | /// 25 | /// 26 | public class ExcelFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.SPREADSHEETML.SHEET" }; 33 | 34 | /// 35 | /// Gets or sets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "Excel"; 39 | 40 | /// 41 | /// Gets or sets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "XLSX" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/HTML/HTMLFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.HTML 21 | { 22 | /// 23 | /// HTML format 24 | /// 25 | /// 26 | public class HTMLFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "TEXT/HTML" }; 33 | 34 | /// 35 | /// Gets or sets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "HTML"; 39 | 40 | /// 41 | /// Gets or sets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "HTML", "HTM", "ASPX", "PHP", "ASP" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/HTML/HTMLWriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using FileCurator.Formats.Interfaces; 19 | using System.IO; 20 | using System.Text; 21 | using System.Threading.Tasks; 22 | 23 | namespace FileCurator.Formats.HTML 24 | { 25 | /// 26 | /// HTML Writer 27 | /// 28 | /// 29 | public class HTMLWriter : IGenericFileWriter 30 | { 31 | /// 32 | /// Writes the file to the specified writer. 33 | /// 34 | /// The writer. 35 | /// The file. 36 | /// True if it writes successfully, false otherwise. 37 | public bool Write(Stream writer, IGenericFile file) 38 | { 39 | if (writer is null || file is null) 40 | return false; 41 | var TempData = Encoding.UTF8.GetBytes(file.ToString()); 42 | try 43 | { 44 | writer.Write(TempData, 0, TempData.Length); 45 | } 46 | catch 47 | { 48 | return false; 49 | } 50 | return true; 51 | } 52 | 53 | /// 54 | /// Writes the file to the specified writer. 55 | /// 56 | /// The writer. 57 | /// The file. 58 | /// True if it writes successfully, false otherwise. 59 | public async Task WriteAsync(Stream writer, IGenericFile file) 60 | { 61 | if (writer is null || file is null) 62 | return false; 63 | var TempData = Encoding.UTF8.GetBytes(file.ToString()); 64 | try 65 | { 66 | await writer.WriteAsync(TempData, 0, TempData.Length).ConfigureAwait(false); 67 | } 68 | catch 69 | { 70 | return false; 71 | } 72 | return true; 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /FileCurator/Formats/ICal/ICalendarFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | 19 | namespace FileCurator.Formats.ICal 20 | { 21 | /// 22 | /// ICal format 23 | /// 24 | /// 25 | public class ICalendarFormat : FormatBaseClass 26 | { 27 | /// 28 | /// Gets the content types. 29 | /// 30 | /// The content types. 31 | public override string[] ContentTypes { get; } = new string[] { "TEXT/CALENDAR" }; 32 | 33 | /// 34 | /// Gets the display name. 35 | /// 36 | /// The display name. 37 | public override string DisplayName { get; } = "ICal"; 38 | 39 | /// 40 | /// Gets the file types. 41 | /// 42 | /// The file types. 43 | public override string[] FileTypes { get; } = new string[] { "ICS" }; 44 | } 45 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Interfaces/IFileReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using System.IO; 19 | using System.Threading.Tasks; 20 | 21 | namespace FileCurator.Formats.Interfaces 22 | { 23 | /// 24 | /// File reader 25 | /// 26 | /// The type of the file. 27 | public interface IGenericFileReader 28 | where TFile : IGenericFile 29 | { 30 | /// 31 | /// Gets the header identifier. 32 | /// 33 | /// The header identifier. 34 | byte[] HeaderIdentifier { get; } 35 | 36 | /// 37 | /// Determines whether this instance can decode the specified file name. 38 | /// 39 | /// Name of the file. 40 | /// True if it can, false otherwise 41 | bool CanRead(string fileName); 42 | 43 | /// 44 | /// Determines whether this instance can decode the specified stream. 45 | /// 46 | /// The stream. 47 | /// True if it can, false otherwise 48 | bool CanRead(Stream stream); 49 | 50 | /// 51 | /// Reads the specified stream. 52 | /// 53 | /// The stream. 54 | /// The file 55 | TFile Read(Stream stream); 56 | 57 | /// 58 | /// Reads the specified stream. 59 | /// 60 | /// The stream. 61 | /// The file 62 | Task ReadAsync(Stream stream); 63 | } 64 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Interfaces/IFileWriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using System.IO; 19 | using System.Threading.Tasks; 20 | 21 | namespace FileCurator.Formats.Interfaces 22 | { 23 | /// 24 | /// File writer interface 25 | /// 26 | public interface IGenericFileWriter 27 | { 28 | /// 29 | /// Writes the file to the specified writer. 30 | /// 31 | /// The writer. 32 | /// The file. 33 | /// True if it writes successfully, false otherwise. 34 | bool Write(Stream writer, IGenericFile file); 35 | 36 | /// 37 | /// Writes the file to the specified writer. 38 | /// 39 | /// The writer. 40 | /// The file. 41 | /// True if it writes successfully, false otherwise. 42 | Task WriteAsync(Stream writer, IGenericFile file); 43 | } 44 | } -------------------------------------------------------------------------------- /FileCurator/Formats/MSG/MSGFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Windows.Formats.MSG 21 | { 22 | /// 23 | /// MSG Format 24 | /// 25 | /// 26 | public class MSGFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes => new[] { "APPLICATION/VND.MS-OUTLOOK" }; 33 | 34 | /// 35 | /// Gets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName => "MSG"; 39 | 40 | /// 41 | /// Gets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes => new[] { "MSG" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/MSG/MSGWriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using FileCurator.Formats.Interfaces; 19 | using System.IO; 20 | using System.Threading.Tasks; 21 | 22 | namespace FileCurator.Windows.Formats.MSG 23 | { 24 | /// 25 | /// MSG Writer 26 | /// 27 | /// 28 | public class MSGWriter : IGenericFileWriter 29 | { 30 | /// 31 | /// Writes the file to the specified writer. 32 | /// 33 | /// The writer. 34 | /// The file. 35 | /// True if it writes successfully, false otherwise. 36 | public bool Write(Stream writer, IGenericFile file) 37 | { 38 | return false; 39 | } 40 | 41 | /// 42 | /// Writes the file to the specified writer. 43 | /// 44 | /// The writer. 45 | /// The file. 46 | /// True if it writes successfully, false otherwise. 47 | public Task WriteAsync(Stream writer, IGenericFile file) => Task.FromResult(false); 48 | } 49 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Mime/MimeFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.Mime 21 | { 22 | /// 23 | /// Mime format 24 | /// 25 | /// 26 | public class MimeFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "MESSAGE/RFC822" }; 33 | 34 | /// 35 | /// Gets or sets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "MIME"; 39 | 40 | /// 41 | /// Gets or sets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "EML", "MHT" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Mime/MimeWriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using FileCurator.Formats.Interfaces; 19 | using System.IO; 20 | using System.Threading.Tasks; 21 | 22 | namespace FileCurator.Formats.Mime 23 | { 24 | /// 25 | /// MIME Writer 26 | /// 27 | /// 28 | public class MimeWriter : IGenericFileWriter 29 | { 30 | /// 31 | /// Writes the file to the specified writer. 32 | /// 33 | /// The writer. 34 | /// The file. 35 | /// True if it writes successfully, false otherwise. 36 | public bool Write(Stream writer, IGenericFile file) => false; 37 | 38 | /// 39 | /// Writes the file to the specified writer. 40 | /// 41 | /// The writer. 42 | /// The file. 43 | /// True if it writes successfully, false otherwise. 44 | public Task WriteAsync(Stream writer, IGenericFile file) => Task.FromResult(false); 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/PDF/PDFFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | using FileCurator.Windows.Formats.PDF; 20 | 21 | namespace FileCurator.Formats.PDF 22 | { 23 | /// 24 | /// PDF Format 25 | /// 26 | /// 27 | public class PDFFormat : FormatBaseClass 28 | { 29 | /// 30 | /// Gets the content types. 31 | /// 32 | /// The content types. 33 | public override string[] ContentTypes => new[] { "APPLICATION/PDF", "TEXT/PDF", "APPLICATION/ACROBAT" }; 34 | 35 | /// 36 | /// Gets or sets the display name. 37 | /// 38 | /// The display name. 39 | public override string DisplayName => "PDF"; 40 | 41 | /// 42 | /// Gets or sets the file types. 43 | /// 44 | /// The file types. 45 | public override string[] FileTypes => new[] { "PDF" }; 46 | } 47 | } -------------------------------------------------------------------------------- /FileCurator/Formats/PDF/PDFReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data; 19 | using FileCurator.Formats.Data.Interfaces; 20 | using System.IO; 21 | using System.Text; 22 | using UglyToad.PdfPig; 23 | using UglyToad.PdfPig.DocumentLayoutAnalysis.TextExtractor; 24 | 25 | namespace FileCurator.Formats.PDF 26 | { 27 | /// 28 | /// PDF Reader 29 | /// 30 | /// 31 | public class PDFReader : ReaderBaseClass 32 | { 33 | /// 34 | /// Gets the header identifier. 35 | /// 36 | /// The header identifier. 37 | public override byte[] HeaderIdentifier => new byte[] { 0x25, 0x50, 0x44, 0x46, 0x2D, 0x31, 0x2E }; 38 | 39 | /// 40 | /// Reads the specified stream. 41 | /// 42 | /// The stream. 43 | /// The file 44 | public override IGenericFile Read(Stream stream) 45 | { 46 | var Builder = new StringBuilder(); 47 | var Title = ""; 48 | var Meta = ""; 49 | try 50 | { 51 | using var Pdf = PdfDocument.Open(stream); 52 | Title = Pdf.Information.Title; 53 | Meta = Pdf.Information.Keywords; 54 | foreach (UglyToad.PdfPig.Content.Page? Page in Pdf.GetPages()) 55 | { 56 | _ = Builder.Append(ContentOrderTextExtractor.GetText(Page) + "\n"); 57 | } 58 | } 59 | catch 60 | { 61 | } 62 | return new GenericFile(Builder.ToString(), Title, Meta); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /FileCurator/Formats/PDF/PDFWriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using FileCurator.Formats.Interfaces; 19 | using System.IO; 20 | using System.Threading.Tasks; 21 | 22 | namespace FileCurator.Windows.Formats.PDF 23 | { 24 | /// 25 | /// PDF writer 26 | /// 27 | /// 28 | public class PDFWriter : IGenericFileWriter 29 | { 30 | /// 31 | /// Writes the file to the specified writer. 32 | /// 33 | /// The writer. 34 | /// The file. 35 | /// True if it writes successfully, false otherwise. 36 | public bool Write(Stream writer, IGenericFile file) 37 | { 38 | return false; 39 | } 40 | 41 | /// 42 | /// Writes the file to the specified writer. 43 | /// 44 | /// The writer. 45 | /// The file. 46 | /// True if it writes successfully, false otherwise. 47 | public Task WriteAsync(Stream writer, IGenericFile file) => Task.FromResult(false); 48 | } 49 | } -------------------------------------------------------------------------------- /FileCurator/Formats/PowerPoint/PowerPointFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.PowerPoint 21 | { 22 | /// 23 | /// PowerPoint format 24 | /// 25 | /// 26 | public class PowerPointFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "APPLICATION/VND.MS-POWERPOINT", "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.PRESENTATIONML.SLIDESHOW" }; 33 | 34 | /// 35 | /// Gets or sets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "PowerPoint"; 39 | 40 | /// 41 | /// Gets or sets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "PPTX", "PPSX" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/PowerPoint/PowerPointWriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using FileCurator.Formats.Interfaces; 19 | using System.IO; 20 | using System.Threading.Tasks; 21 | 22 | namespace FileCurator.Formats.PowerPoint 23 | { 24 | /// 25 | /// PowerPoint file writer. 26 | /// 27 | /// 28 | public class PowerPointWriter : IGenericFileWriter 29 | { 30 | /// 31 | /// Writes the file to the specified writer. 32 | /// 33 | /// The writer. 34 | /// The file. 35 | /// True if it writes successfully, false otherwise. 36 | public bool Write(Stream writer, IGenericFile file) => false; 37 | 38 | /// 39 | /// Writes the file to the specified writer. 40 | /// 41 | /// The writer. 42 | /// The file. 43 | /// True if it writes successfully, false otherwise. 44 | public Task WriteAsync(Stream writer, IGenericFile file) => Task.FromResult(false); 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/RSS/Data/Enclosure.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using System; 19 | using System.Xml.XPath; 20 | 21 | namespace FileCurator.Formats.RSS.Data 22 | { 23 | /// 24 | /// Enclosure 25 | /// 26 | /// 27 | public class Enclosure : IEnclosure 28 | { 29 | /// 30 | /// Constructor 31 | /// 32 | public Enclosure() 33 | { 34 | } 35 | 36 | /// 37 | /// Constructor 38 | /// 39 | /// XML element holding info for the enclosure 40 | public Enclosure(IXPathNavigable doc) 41 | { 42 | if (doc is null) 43 | throw new ArgumentNullException(nameof(doc)); 44 | var Element = doc.CreateNavigator(); 45 | Url = Element.GetAttribute("url", "") ?? string.Empty; 46 | if (int.TryParse(Element.GetAttribute("length", ""), out var TempLength)) 47 | Length = TempLength; 48 | Type = Element.GetAttribute("type", "") ?? string.Empty; 49 | } 50 | 51 | /// 52 | /// Size in bytes 53 | /// 54 | public int Length { get; set; } 55 | 56 | /// 57 | /// File type 58 | /// 59 | public string? Type { get; set; } 60 | 61 | /// 62 | /// Location of the item 63 | /// 64 | public string? Url { get; set; } 65 | 66 | /// 67 | /// to string item. Used for outputting the item to RSS. 68 | /// 69 | /// A string formatted for RSS output 70 | public override string ToString() 71 | { 72 | if (string.IsNullOrEmpty(Url) || string.IsNullOrEmpty(Type)) 73 | return string.Empty; 74 | return "\r\n" 75 | + ""; 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /FileCurator/Formats/RSS/Data/FeedGuid.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | */using FileCurator.Formats.Data.Interfaces; 17 | using System; 18 | using System.Xml.XPath; 19 | 20 | namespace FileCurator.Formats.RSS.Data 21 | { 22 | /// 23 | /// Feed GUID 24 | /// 25 | /// 26 | public class FeedGuid : IFeedGuid 27 | { 28 | /// 29 | /// Constructor 30 | /// 31 | public FeedGuid() 32 | { 33 | } 34 | 35 | /// 36 | /// Constructor 37 | /// 38 | /// XML element holding info for the enclosure 39 | public FeedGuid(IXPathNavigable element) 40 | { 41 | if (element is null) 42 | throw new ArgumentNullException(nameof(element)); 43 | var Navigator = element.CreateNavigator(); 44 | if (!string.IsNullOrEmpty(Navigator.GetAttribute("isPermaLink", ""))) 45 | { 46 | IsPermaLink = bool.Parse(Navigator.GetAttribute("isPermaLink", "")); 47 | } 48 | GuidText = Navigator.Value; 49 | } 50 | 51 | /// 52 | /// GUID Text 53 | /// 54 | public string? GuidText { get; set; } 55 | 56 | /// 57 | /// Is this a perma link? 58 | /// 59 | public bool IsPermaLink { get; set; } 60 | 61 | /// 62 | /// to string item. Used for outputting the item to RSS. 63 | /// 64 | /// A string formatted for RSS output 65 | public override string ToString() 66 | { 67 | if (string.IsNullOrEmpty(GuidText)) 68 | return string.Empty; 69 | return "" + GuidText + "\r\n"; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /FileCurator/Formats/RSS/Data/Thumbnail.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using System; 19 | using System.Globalization; 20 | using System.Xml.XPath; 21 | 22 | namespace FileCurator.Formats.RSS.Data 23 | { 24 | /// 25 | /// Thumbnail 26 | /// 27 | /// 28 | public class Thumbnail : IThumbnail 29 | { 30 | /// 31 | /// Constructor 32 | /// 33 | public Thumbnail() 34 | { 35 | } 36 | 37 | /// 38 | /// Constructor 39 | /// 40 | /// XML element holding info for the enclosure 41 | public Thumbnail(IXPathNavigable doc) 42 | { 43 | if (doc is null) 44 | throw new ArgumentNullException(nameof(doc)); 45 | var Element = doc.CreateNavigator(); 46 | Url = Element.GetAttribute("url", ""); 47 | if (!string.IsNullOrEmpty(Element.GetAttribute("width", ""))) 48 | { 49 | Width = int.Parse(Element.GetAttribute("width", ""), CultureInfo.InvariantCulture); 50 | } 51 | if (!string.IsNullOrEmpty(Element.GetAttribute("height", ""))) 52 | { 53 | Height = int.Parse(Element.GetAttribute("height", ""), CultureInfo.InvariantCulture); 54 | } 55 | } 56 | 57 | /// 58 | /// Image height 59 | /// 60 | public int Height { get; set; } 61 | 62 | /// 63 | /// Location of the item 64 | /// 65 | public string? Url { get; set; } 66 | 67 | /// 68 | /// Image width 69 | /// 70 | public int Width { get; set; } 71 | 72 | /// 73 | /// to string item. Used for outputting the item to RSS. 74 | /// 75 | /// A string formatted for RSS output 76 | public override string ToString() 77 | { 78 | if (!string.IsNullOrEmpty(Url)) 79 | { 80 | return $"\r\n"; 81 | } 82 | return string.Empty; 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /FileCurator/Formats/RSS/Data/Utils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Formats.RSS.Data 18 | { 19 | /// 20 | /// Utility class used by RSS classes. 21 | /// 22 | public static class Utils 23 | { 24 | /// 25 | /// Strips illegal characters from RSS items 26 | /// 27 | /// Original text 28 | /// string stripped of certain characters. 29 | public static string StripIllegalCharacters(string original) 30 | { 31 | return original?.Replace(" ", " ") 32 | .Replace(" ", string.Empty) 33 | .Trim() 34 | .Replace("&", "and") ?? ""; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /FileCurator/Formats/RSS/RSSFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.RSS 21 | { 22 | /// 23 | /// RSS Format 24 | /// 25 | /// 26 | public class RSSFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "APPLICATION/RSS+XML" }; 33 | 34 | /// 35 | /// Gets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "RSS"; 39 | 40 | /// 41 | /// Gets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "RSS" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/RSS/RSSReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using BigBook; 18 | using FileCurator.Formats.BaseClasses; 19 | using FileCurator.Formats.Data.Interfaces; 20 | using FileCurator.Formats.RSS.Data; 21 | using System.IO; 22 | 23 | namespace FileCurator.Formats.RSS 24 | { 25 | /// 26 | /// RSS Reader 27 | /// 28 | /// 29 | public class RSSReader : ReaderBaseClass 30 | { 31 | /// 32 | /// Gets the header identifier. 33 | /// 34 | /// The header identifier. 35 | public override byte[] HeaderIdentifier { get; } = new byte[] { 0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20 }; 36 | 37 | /// 38 | /// Used to determine if a reader can actually read the file 39 | /// 40 | /// The stream. 41 | /// True if it can, false otherwise 42 | public override bool InternalCanRead(Stream stream) 43 | { 44 | try 45 | { 46 | var TempFeed = new Feed(stream.ReadAll()); 47 | if (TempFeed.Channels.Count > 0 && TempFeed.Channels[0].Count > 0) 48 | return true; 49 | } 50 | catch { } 51 | return false; 52 | } 53 | 54 | /// 55 | /// Reads the specified stream. 56 | /// 57 | /// The stream. 58 | /// The file 59 | public override IFeed Read(Stream stream) 60 | { 61 | if (stream is null) 62 | return new Feed(); 63 | return new Feed(GetData(stream)); 64 | } 65 | 66 | /// 67 | /// Gets the data. 68 | /// 69 | /// The stream. 70 | /// The data 71 | private static string GetData(Stream stream) 72 | { 73 | try 74 | { 75 | return stream.ReadAll(); 76 | } 77 | catch 78 | { 79 | return ""; 80 | } 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /FileCurator/Formats/RTF/RTFFormat.cs: -------------------------------------------------------------------------------- 1 | #if NET462 2 | /* 3 | Copyright 2017 James Craig 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | using FileCurator.Formats.BaseClasses; 19 | using FileCurator.Formats.Data.Interfaces; 20 | 21 | namespace FileCurator.Windows.Formats.RTF 22 | { 23 | /// 24 | /// RTF format 25 | /// 26 | /// 27 | public class RTFFormat : FormatBaseClass 28 | { 29 | /// 30 | /// Gets the content types. 31 | /// 32 | /// The content types. 33 | public override string[] ContentTypes => new[] { "TEXT/RTF", "APPLICATION/RTF", "TEXT/RICHTEXT" }; 34 | 35 | /// 36 | /// Gets the display name. 37 | /// 38 | /// The display name. 39 | public override string DisplayName => "RTF"; 40 | 41 | /// 42 | /// Gets or sets the file types. 43 | /// 44 | /// The file types. 45 | public override string[] FileTypes => new[] { "RTF" }; 46 | } 47 | } 48 | #endif -------------------------------------------------------------------------------- /FileCurator/Formats/RTF/RTFReader.cs: -------------------------------------------------------------------------------- 1 | #if NET462 2 | /* 3 | Copyright 2017 James Craig 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | using BigBook; 19 | using FileCurator.Formats.BaseClasses; 20 | using FileCurator.Formats.Data; 21 | using FileCurator.Formats.Data.Interfaces; 22 | using System.IO; 23 | 24 | namespace FileCurator.Windows.Formats.RTF 25 | { 26 | /// 27 | /// RTF Reader 28 | /// 29 | /// 30 | public class RTFReader : ReaderBaseClass 31 | { 32 | /// 33 | /// Gets the header identifier. 34 | /// 35 | /// The header identifier. 36 | public override byte[] HeaderIdentifier => new byte[] { 0x7B, 0x5C, 0x72, 0x74, 0x66 }; 37 | 38 | /// 39 | /// Reads the specified stream. 40 | /// 41 | /// The stream. 42 | /// The file 43 | public override IGenericFile Read(Stream stream) 44 | { 45 | var TempBox = new System.Windows.Forms.RichTextBox 46 | { 47 | Rtf = stream.ReadAll() 48 | }; 49 | return new GenericFile(TempBox.Text, "", ""); 50 | } 51 | } 52 | } 53 | #endif -------------------------------------------------------------------------------- /FileCurator/Formats/RTF/RTFWriter.cs: -------------------------------------------------------------------------------- 1 | #if NET462 2 | /* 3 | Copyright 2017 James Craig 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | using FileCurator.Formats.Data.Interfaces; 19 | using FileCurator.Formats.Interfaces; 20 | using System.IO; 21 | 22 | namespace FileCurator.Windows.Formats.RTF 23 | { 24 | /// 25 | /// RTF file writer 26 | /// 27 | /// 28 | public class RTFWriter : IGenericFileWriter 29 | { 30 | /// 31 | /// Writes the file to the specified writer. 32 | /// 33 | /// The writer. 34 | /// The file. 35 | /// True if it writes successfully, false otherwise. 36 | public bool Write(Stream writer, IGenericFile file) 37 | { 38 | return false; 39 | } 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /FileCurator/Formats/Txt/TxtFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.Txt 21 | { 22 | /// 23 | /// Text format 24 | /// 25 | /// 26 | public class TxtFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "TEXT/PLAIN" }; 33 | 34 | /// 35 | /// Gets or sets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "Text"; 39 | 40 | /// 41 | /// Gets or sets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "TXT" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Txt/TxtReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using BigBook; 18 | using FileCurator.Formats.BaseClasses; 19 | using FileCurator.Formats.Data; 20 | using FileCurator.Formats.Data.Interfaces; 21 | using System; 22 | using System.IO; 23 | 24 | namespace FileCurator.Formats.Txt 25 | { 26 | /// 27 | /// TXT file reader 28 | /// 29 | /// 30 | public class TxtReader : ReaderBaseClass 31 | { 32 | /// 33 | /// Gets the header identifier. 34 | /// 35 | /// The header identifier. 36 | public override byte[] HeaderIdentifier { get; } = Array.Empty(); 37 | 38 | /// 39 | /// Reads the specified stream. 40 | /// 41 | /// The stream. 42 | /// The file 43 | public override IGenericFile Read(Stream stream) 44 | { 45 | return new GenericFile(GetData(stream), "", ""); 46 | } 47 | 48 | /// 49 | /// Gets the data. 50 | /// 51 | /// The stream. 52 | /// 53 | private static string GetData(Stream? stream) 54 | { 55 | try 56 | { 57 | return stream?.ReadAll() ?? ""; 58 | } 59 | catch 60 | { 61 | return ""; 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Txt/TxtWriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using FileCurator.Formats.Interfaces; 19 | using System.IO; 20 | using System.Text; 21 | using System.Threading.Tasks; 22 | 23 | namespace FileCurator.Formats.Txt 24 | { 25 | /// 26 | /// Txt Writer 27 | /// 28 | /// 29 | public class TxtWriter : IGenericFileWriter 30 | { 31 | /// 32 | /// Writes the file to the specified writer. 33 | /// 34 | /// The writer. 35 | /// The file. 36 | /// True if it writes successfully, false otherwise. 37 | public bool Write(Stream writer, IGenericFile file) 38 | { 39 | if (writer is null) 40 | return false; 41 | var TempData = Encoding.UTF8.GetBytes(file?.ToString() ?? ""); 42 | try 43 | { 44 | writer.Write(TempData, 0, TempData.Length); 45 | } 46 | catch 47 | { 48 | return false; 49 | } 50 | return true; 51 | } 52 | 53 | /// 54 | /// Writes the file to the specified writer. 55 | /// 56 | /// The writer. 57 | /// The file. 58 | /// True if it writes successfully, false otherwise. 59 | public async Task WriteAsync(Stream writer, IGenericFile file) 60 | { 61 | if (writer is null) 62 | return false; 63 | var TempData = Encoding.UTF8.GetBytes(file?.ToString() ?? ""); 64 | try 65 | { 66 | await writer.WriteAsync(TempData, 0, TempData.Length).ConfigureAwait(false); 67 | } 68 | catch 69 | { 70 | return false; 71 | } 72 | return true; 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /FileCurator/Formats/VCalendar/VCalendarFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.VCalendar 21 | { 22 | /// 23 | /// VCal format 24 | /// 25 | /// 26 | public class VCalendarFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new string[] { "APPLICATION/HBS-VCS", "TEXT/X-VCALENDAR" }; 33 | 34 | /// 35 | /// Gets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "VCal"; 39 | 40 | /// 41 | /// Gets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new string[] { "VCS" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/VCard/VCardFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.VCard 21 | { 22 | /// 23 | /// VCard format 24 | /// 25 | /// 26 | public class VCardFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "TEXT/VCARD" }; 33 | 34 | /// 35 | /// Gets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "vCard"; 39 | 40 | /// 41 | /// Gets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "VCF", "VCARD" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Word/WordFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.Word 21 | { 22 | /// 23 | /// Word format 24 | /// 25 | /// 26 | public class WordFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "APPLICATION/MSWORD", "APPLICATION/VND.OPENXMLFORMATS-OFFICEDOCUMENT.WORDPROCESSINGML.DOCUMENT" }; 33 | 34 | /// 35 | /// Gets or sets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "Word"; 39 | 40 | /// 41 | /// Gets or sets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "DOCX" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/Word/WordReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using BigBook; 18 | using DocumentFormat.OpenXml.Packaging; 19 | using DocumentFormat.OpenXml.Wordprocessing; 20 | using FileCurator.Formats.BaseClasses; 21 | using FileCurator.Formats.Data; 22 | using FileCurator.Formats.Data.Interfaces; 23 | using System.IO; 24 | 25 | namespace FileCurator.Formats.Word 26 | { 27 | /// 28 | /// Word reader 29 | /// 30 | /// 31 | public class WordReader : ReaderBaseClass 32 | { 33 | /// 34 | /// Gets the header identifier. 35 | /// 36 | /// The header identifier. 37 | public override byte[] HeaderIdentifier { get; } = new byte[] { 0x50, 0x4B, 0x03, 0x04 }; 38 | 39 | /// 40 | /// Used to determine if a reader can actually read the file 41 | /// 42 | /// The stream. 43 | /// True if it can, false otherwise 44 | public override bool InternalCanRead(Stream stream) 45 | { 46 | try 47 | { 48 | var Result = WordprocessingDocument.Open(stream, false); 49 | if (Result.MainDocumentPart?.ContentType != "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml") 50 | return false; 51 | } 52 | catch { return false; } 53 | return true; 54 | } 55 | 56 | /// 57 | /// Reads the specified stream. 58 | /// 59 | /// The stream. 60 | /// The file 61 | public override IGenericFile Read(Stream stream) 62 | { 63 | if (stream is null) 64 | return new GenericFile("", "", ""); 65 | try 66 | { 67 | using var Doc = WordprocessingDocument.Open(stream, false); 68 | return new GenericFile(Doc.MainDocumentPart.Document.Body.Descendants().ToString(x => x.InnerText, "\n"), 69 | Doc.PackageProperties.Title, 70 | Doc.PackageProperties.Subject); 71 | } 72 | catch 73 | { 74 | return new GenericFile("", "", ""); 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /FileCurator/Formats/XML/XMLFormat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.BaseClasses; 18 | using FileCurator.Formats.Data.Interfaces; 19 | 20 | namespace FileCurator.Formats.XML 21 | { 22 | /// 23 | /// XML Format 24 | /// 25 | /// 26 | public class XMLFormat : FormatBaseClass 27 | { 28 | /// 29 | /// Gets the content types. 30 | /// 31 | /// The content types. 32 | public override string[] ContentTypes { get; } = new[] { "TEXT/XML", "APPLICATION/XML" }; 33 | 34 | /// 35 | /// Gets the display name. 36 | /// 37 | /// The display name. 38 | public override string DisplayName { get; } = "XML"; 39 | 40 | /// 41 | /// Gets the file types. 42 | /// 43 | /// The file types. 44 | public override string[] FileTypes { get; } = new[] { "XML" }; 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/Formats/XML/XMLReader.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using BigBook; 18 | using FileCurator.Formats.BaseClasses; 19 | using FileCurator.Formats.Data; 20 | using FileCurator.Formats.Data.Interfaces; 21 | using System.IO; 22 | using System.Xml.Linq; 23 | 24 | namespace FileCurator.Formats.XML 25 | { 26 | /// 27 | /// XML Reader 28 | /// 29 | /// 30 | public class XMLReader : ReaderBaseClass 31 | { 32 | /// 33 | /// Gets the header identifier. 34 | /// 35 | /// The header identifier. 36 | public override byte[] HeaderIdentifier { get; } = new byte[] { 0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22 }; 37 | 38 | /// 39 | /// Reads the specified stream. 40 | /// 41 | /// The stream. 42 | /// The file 43 | public override IGenericFile Read(Stream stream) 44 | { 45 | var Content = stream.ReadAll(); 46 | return new GenericFile(XDocument.Parse(Content) 47 | .Descendants() 48 | .ToString(x => x.Value, "\n"), 49 | "", 50 | ""); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /FileCurator/Formats/XML/XMLWriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using FileCurator.Formats.Data.Interfaces; 18 | using FileCurator.Formats.Interfaces; 19 | using System.IO; 20 | using System.Threading.Tasks; 21 | 22 | namespace FileCurator.Formats.XML 23 | { 24 | /// 25 | /// XML Writer 26 | /// 27 | /// 28 | public class XMLWriter : IGenericFileWriter 29 | { 30 | /// 31 | /// Writes the file to the specified writer. 32 | /// 33 | /// The writer. 34 | /// The file. 35 | /// True if it writes successfully, false otherwise. 36 | public bool Write(Stream writer, IGenericFile file) => false; 37 | 38 | /// 39 | /// Writes the file to the specified writer. 40 | /// 41 | /// The writer. 42 | /// The file. 43 | /// True if it writes successfully, false otherwise. 44 | public Task WriteAsync(Stream writer, IGenericFile file) => Task.FromResult(false); 45 | } 46 | } -------------------------------------------------------------------------------- /FileCurator/HelperMethods/InternalHttpClientFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Net.Http; 5 | 6 | namespace FileCurator.HelperMethods 7 | { 8 | /// 9 | /// Internal HTTP Client Factory 10 | /// 11 | /// 12 | /// 13 | public class InternalHttpClientFactory : IDisposable 14 | { 15 | /// 16 | /// Gets the lock object. 17 | /// 18 | /// The lock object. 19 | private static object LockObj { get; } = new object(); 20 | 21 | /// 22 | /// Gets or sets the clients. 23 | /// 24 | /// The clients. 25 | private Dictionary Clients { get; } = new Dictionary(); 26 | 27 | /// 28 | /// Performs application-defined tasks associated with freeing, releasing, or resetting 29 | /// unmanaged resources. 30 | /// 31 | public void Dispose() 32 | { 33 | foreach (var Item in Clients) 34 | { 35 | Item.Value?.Dispose(); 36 | } 37 | Clients.Clear(); 38 | } 39 | 40 | /// 41 | /// Gets the client. 42 | /// 43 | /// The credentials. 44 | /// 45 | public HttpClient GetClient(Credentials? credentials) 46 | { 47 | credentials ??= Credentials.NoCredentials; 48 | if (Clients.TryGetValue(credentials, out var Result)) 49 | return Result; 50 | lock (LockObj) 51 | { 52 | if (Clients.TryGetValue(credentials, out Result)) 53 | return Result; 54 | var Handler = new HttpClientHandler(); 55 | if (!string.IsNullOrEmpty(credentials?.UserName) && !string.IsNullOrEmpty(credentials?.Password)) 56 | { 57 | if (!string.IsNullOrEmpty(credentials?.Domain)) 58 | Handler.Credentials = new NetworkCredential(credentials?.UserName, credentials?.Password, credentials?.Domain); 59 | else 60 | Handler.Credentials = new NetworkCredential(credentials?.UserName, credentials?.Password); 61 | } 62 | else 63 | { 64 | Handler.UseDefaultCredentials = credentials?.UseDefaultCredentials ?? false; 65 | } 66 | Result = new HttpClient(Handler); 67 | Clients.Add(credentials, Result); 68 | } 69 | return Result; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /FileCurator/HelperMethods/Services.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | 4 | namespace FileCurator.HelperMethods 5 | { 6 | /// 7 | /// Services class 8 | /// 9 | internal static class Services 10 | { 11 | /// 12 | /// Gets the service provider. 13 | /// 14 | /// The service provider. 15 | public static IServiceProvider? ServiceProvider 16 | { 17 | get 18 | { 19 | if (_ServiceProvider is not null) 20 | return _ServiceProvider; 21 | lock (ServiceProviderLock) 22 | { 23 | _ServiceProvider = (ServiceDescriptors ?? new ServiceCollection().AddCanisterModules())?.BuildServiceProvider(); 24 | } 25 | return _ServiceProvider; 26 | } 27 | } 28 | 29 | /// 30 | /// The service descriptors 31 | /// 32 | internal static IServiceCollection? ServiceDescriptors; 33 | 34 | /// 35 | /// The service provider lock 36 | /// 37 | private static readonly object ServiceProviderLock = new(); 38 | 39 | /// 40 | /// The service provider 41 | /// 42 | private static IServiceProvider? _ServiceProvider; 43 | } 44 | } -------------------------------------------------------------------------------- /FileCurator/Interfaces/IFileSystem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | namespace FileCurator.Interfaces 18 | { 19 | /// 20 | /// Interface for the file system 21 | /// 22 | public interface IFileSystem 23 | { 24 | /// 25 | /// Name of the file system 26 | /// 27 | string Name { get; } 28 | 29 | /// 30 | /// Gets the order (lower numbers occur first). 31 | /// 32 | /// The order. 33 | int Order { get; } 34 | 35 | /// 36 | /// Returns true if it can handle the path, false otherwise 37 | /// 38 | /// The path to check against 39 | /// True if it can handle the path, false otherwise 40 | bool CanHandle(string path); 41 | 42 | /// 43 | /// Gets the directory representation for the directory 44 | /// 45 | /// Path to the directory 46 | /// The credentials. 47 | /// The directory object 48 | IDirectory Directory(string path, Credentials? credentials = null); 49 | 50 | /// 51 | /// Gets the class representation for the file 52 | /// 53 | /// Path to the file 54 | /// The credentials. 55 | /// The file object 56 | IFile File(string path, Credentials? credentials = null); 57 | } 58 | } -------------------------------------------------------------------------------- /FileCurator/Module/FileCuratorModule.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using Canister.Interfaces; 18 | using Microsoft.Extensions.DependencyInjection; 19 | 20 | namespace FileCurator.Module 21 | { 22 | /// 23 | /// File curator module 24 | /// 25 | public class FileCuratorModule : IModule 26 | { 27 | /// 28 | /// Order to run it in 29 | /// 30 | public int Order => 0; 31 | 32 | /// 33 | /// Loads the module 34 | /// 35 | /// The bootstrapper. 36 | public void Load(IServiceCollection? bootstrapper) => bootstrapper?.RegisterFileCurator(); 37 | } 38 | } -------------------------------------------------------------------------------- /FileCurator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following set of attributes. 5 | // Change these attribute values to modify the information associated with an assembly. 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("")] 8 | [assembly: AssemblyProduct("FileCurator")] 9 | [assembly: AssemblyTrademark("")] 10 | 11 | // Setting ComVisible to false makes the types in this assembly not visible to COM components. If you 12 | // need to access a type in this assembly from COM, set the ComVisible attribute to true on that type. 13 | [assembly: ComVisible(false)] 14 | 15 | // The following GUID is for the ID of the typelib if this project is exposed to COM 16 | [assembly: Guid("800cbf12-4f73-46bb-8ddc-ee5d6279cd15")] -------------------------------------------------------------------------------- /FileCurator/Registration/CanisterExtension.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 James Craig 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | using BigBook.Registration; 18 | using Canister.Interfaces; 19 | using FileCurator; 20 | using FileCurator.Formats; 21 | using FileCurator.Formats.Interfaces; 22 | using FileCurator.HelperMethods; 23 | using FileCurator.Interfaces; 24 | 25 | namespace Microsoft.Extensions.DependencyInjection 26 | { 27 | /// 28 | /// Canister registration extension 29 | /// 30 | public static class FileCuratorCanisterExtensions 31 | { 32 | /// 33 | /// Registers the big book of data types. 34 | /// 35 | /// The bootstrapper. 36 | /// The bootstrapper 37 | public static ICanisterConfiguration? RegisterFileCurator(this ICanisterConfiguration? bootstrapper) 38 | { 39 | return bootstrapper?.RegisterBigBookOfDataTypes() 40 | ?.AddAssembly(typeof(FileCuratorCanisterExtensions).Assembly); 41 | } 42 | 43 | /// 44 | /// Registers the FileCurator services with the specified service collection. 45 | /// 46 | /// The service collection to register the services with. 47 | /// The updated service collection. 48 | public static IServiceCollection? RegisterFileCurator(this IServiceCollection? services) 49 | { 50 | if (services.Exists()) 51 | return services; 52 | Services.ServiceDescriptors = services; 53 | return services?.AddAllTransient() 54 | ?.AddSingleton() 55 | ?.AddAllSingleton() 56 | ?.AddSingleton() 57 | ?.AddSingleton() 58 | ?.RegisterBigBookOfDataTypes(); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/Icon.png -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | -------- | ------------------ | 7 | | latest | :white_check_mark: | 8 | | < latest | :x: | 9 | -------------------------------------------------------------------------------- /docfx_project/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # folder # 3 | ############### 4 | /**/DROP/ 5 | /**/TEMP/ 6 | /**/packages/ 7 | /**/bin/ 8 | /**/obj/ 9 | 10 | -------------------------------------------------------------------------------- /docfx_project/api/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # temp file # 3 | ############### 4 | *.yml 5 | .manifest 6 | -------------------------------------------------------------------------------- /docfx_project/api/index.md: -------------------------------------------------------------------------------- 1 | # Welcome 2 | Welcome to the API browser. -------------------------------------------------------------------------------- /docfx_project/articles/intro.md: -------------------------------------------------------------------------------- 1 | # Code 2 | [!code-csharp[](../../FileCurator.Example/Program.cs)] 3 | 4 | # Output 5 | 6 | ``` 7 | File Info: 8 | File: C:\*********\MyFile.txt 9 | File Exists: True 10 | File Extension: .txt 11 | File Name: MyFile.txt 12 | File length: 24 13 | 14 | PDF Content: 15 | This is a test docx 16 | 17 | CSV Content: 18 | Header 1 Header 2 Header 3 Header 4 Header 5 Header 6 19 | This is a test CSV file 20 | Tons of data in here is super 21 | important 22 | Columns: Header 1,Header 2,Header 3,Header 4,Header 5,Header 6 23 | Rows: This, is, a, test, CSV, file 24 | Tons, of, data, in here, is, super 25 | important 26 | 27 | "Header 1","Header 2","Header 3","Header 4","Header 5","Header 6" 28 | "This","is","a","test","CSV","file" 29 | "Tons","of","data","in here","is","super" 30 | "important" 31 | ``` -------------------------------------------------------------------------------- /docfx_project/articles/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Example 2 | href: intro.md 3 | -------------------------------------------------------------------------------- /docfx_project/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": ["FileCurator/FileCurator.csproj"], 7 | "src": "../" 8 | } 9 | ], 10 | "dest": "api", 11 | "properties": { 12 | "TargetFramework": "net8.0" 13 | }, 14 | "includePrivateMembers": false, 15 | "disableGitFeatures": false, 16 | "disableDefaultFilter": false, 17 | "noRestore": false, 18 | "namespaceLayout": "flattened", 19 | "memberLayout": "samePage", 20 | "allowCompilationErrors": false 21 | } 22 | ], 23 | "build": { 24 | "globalMetadata": { 25 | "_appTitle": "FileCurator API Reference", 26 | "_appName": "FileCurator", 27 | "_appLogoPath": "images/icon.png", 28 | "_appFooter": "Open in Github", 29 | "_copyrightFooter": "© James Craig. All rights reserved.", 30 | "_enableSearch": true, 31 | "_disableSideFilter": false, 32 | "_enableNewTab": true, 33 | "_disableContribution": false, 34 | "_disableBreadcrumb": false 35 | }, 36 | "content": [ 37 | { 38 | "files": [ 39 | "api/**.yml", 40 | "api/index.md" 41 | ] 42 | }, 43 | { 44 | "files": [ 45 | "articles/**.md", 46 | "articles/**/toc.yml", 47 | "toc.yml", 48 | "*.md" 49 | ] 50 | } 51 | ], 52 | "resource": [ 53 | { 54 | "files": [ 55 | "images/**" 56 | ] 57 | } 58 | ], 59 | "output": "_site", 60 | "globalMetadataFiles": [], 61 | "fileMetadataFiles": [], 62 | "template": [ 63 | "default", 64 | "modern", 65 | "./templates/mytemplate" 66 | ], 67 | "postProcessors": [], 68 | "keepFileLink": false, 69 | "disableGitFeatures": false 70 | } 71 | } -------------------------------------------------------------------------------- /docfx_project/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaCraig/FileCurator/56357027e6dbeb1e643dce3ae0cd34df9ea5aa1b/docfx_project/images/icon.png -------------------------------------------------------------------------------- /docfx_project/index.md: -------------------------------------------------------------------------------- 1 | [!INCLUDE [README.md](../README.md)] -------------------------------------------------------------------------------- /docfx_project/templates/mytemplate/public/main.css: -------------------------------------------------------------------------------- 1 | img#logo { 2 | height: 35px; 3 | padding-right: 10px; 4 | } -------------------------------------------------------------------------------- /docfx_project/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Example 2 | href: articles/ 3 | - name: Api Documentation 4 | href: api/ 5 | homepage: api/index.md 6 | -------------------------------------------------------------------------------- /setup.bat: -------------------------------------------------------------------------------- 1 | dotnet new tool-manifest 2 | dotnet tool install Husky 3 | dotnet tool install Versionize 4 | dotnet tool update -g docfx 5 | docfx init --quiet 6 | dotnet husky install --------------------------------------------------------------------------------