├── .gitattributes
├── .gitignore
├── README.md
├── docs
├── _config.yml
├── images
│ ├── screenshot.png
│ └── screenshotSmall.png
└── index.md
├── license.txt
└── src
└── FileSharper
├── FileSharper.sln
├── FileSharper
├── AboutControl.xaml
├── AboutControl.xaml.cs
├── App.xaml
├── App.xaml.cs
├── EulaControl.xaml
├── EulaControl.xaml.cs
├── FileSharper.csproj
├── FileSharper.ico
├── FileSharperFile.ico
├── FileSharperSettings.cs
├── FileSharperUtil.cs
├── MainViewModel.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── ManageTemplatesControl.xaml
├── ManageTemplatesControl.xaml.cs
├── PathHelpControl.xaml
├── PathHelpControl.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ ├── Settings.settings
│ └── app.manifest
├── SearchTemplateInfo.cs
├── Templates
│ ├── 01 Simple Search.fsh
│ └── 02 Regex Replace.fsh
├── app.config
└── packages.config
├── FileSharperCore.Tests
├── ExpectedResults
│ ├── CommandLineProcessorTests
│ │ └── RunsCommandLine
│ │ │ └── BasicTextFile.txt
│ ├── CopyFileProcessorTests
│ │ ├── DoesNotOverwrite
│ │ │ └── out.txt
│ │ ├── Overwrites
│ │ │ └── out.txt
│ │ └── Success
│ │ │ └── out.txt
│ ├── CreateOrUpdateFileProcessorTests
│ │ ├── CreatesFile
│ │ │ └── out.txt
│ │ ├── DoesNotUpdateDate
│ │ │ └── out.txt
│ │ ├── ExceptionUpdatingDate
│ │ │ └── out.txt
│ │ └── UpdatesDate
│ │ │ └── out.txt
│ ├── CsvProcessorTests
│ │ ├── ClassicMacOS
│ │ │ └── ClassicMacOS.csv
│ │ ├── FullPath
│ │ │ └── FullPath.csv
│ │ ├── NameThenDirectory
│ │ │ └── NameThenDirectory.csv
│ │ ├── Unix
│ │ │ └── Unix.csv
│ │ └── Windows
│ │ │ └── Windows.csv
│ ├── FileDateProcessorTests
│ │ ├── FailsWhenFileLocked
│ │ │ └── out.txt
│ │ ├── SetsAccessedDate
│ │ │ └── out.txt
│ │ ├── SetsCreatedDate
│ │ │ └── out.txt
│ │ └── SetsModificationDate
│ │ │ └── out.txt
│ ├── FilterLinesProcessorTests
│ │ ├── FailsFileExists
│ │ │ └── out.txt
│ │ ├── FailsFileInUse
│ │ │ └── out.txt
│ │ ├── SuccessCaseInsensitiveNoRegex
│ │ │ └── out.txt
│ │ ├── SuccessCaseInsensitiveRegex
│ │ │ └── out.txt
│ │ ├── SuccessCaseSensitiveNoRegex
│ │ │ └── out.txt
│ │ ├── SuccessCaseSensitiveRegex
│ │ │ └── out.txt
│ │ ├── SuccessKeepNoRegex
│ │ │ └── out.txt
│ │ ├── SuccessKeepRegex
│ │ │ └── out.txt
│ │ ├── SuccessNoTrailingNewline
│ │ │ └── out.txt
│ │ ├── SuccessRemoveNoRegex
│ │ │ └── out.txt
│ │ └── SuccessRemoveRegex
│ │ │ └── out.txt
│ ├── ImageResizeProcessorTests
│ │ ├── Height100Jpeg
│ │ │ └── out.jpg
│ │ ├── Height900Jpeg
│ │ │ └── out.jpg
│ │ ├── ResizeBeetleOverwriteFalse
│ │ │ └── out.jpg
│ │ ├── ResizeBeetleOverwriteTrueFailure
│ │ │ └── out.jpg
│ │ ├── ResizeBeetleOverwriteTrueSuccess
│ │ │ └── out.jpg
│ │ ├── Width100Bmp
│ │ │ └── out.bmp
│ │ ├── Width100Exif
│ │ │ └── out.exif
│ │ ├── Width100Gif
│ │ │ └── out.gif
│ │ ├── Width100Jpeg
│ │ │ └── out.jpg
│ │ ├── Width100Png
│ │ │ └── out.png
│ │ ├── Width100Tiff
│ │ │ └── out.tif
│ │ ├── Width1200Jpeg
│ │ │ └── out.jpg
│ │ └── out.jpg
│ ├── LineProcessorTests
│ │ ├── FailsExistingFile
│ │ │ └── out.txt
│ │ ├── FailsFileInUse
│ │ │ └── out.txt
│ │ ├── SucceedsExistingFile
│ │ │ └── out.txt
│ │ ├── Success
│ │ │ └── out.txt
│ │ ├── SuccessClassicMacOS
│ │ │ └── out.txt
│ │ ├── SuccessMatchInput
│ │ │ └── out.txt
│ │ ├── SuccessNoTrailingNewline
│ │ │ └── out.txt
│ │ ├── SuccessUnix
│ │ │ └── out.txt
│ │ ├── SuccessUtf16
│ │ │ └── out.txt
│ │ └── SuccessWindows
│ │ │ └── out.txt
│ ├── PrependOrAppendTextProcessorTests
│ │ ├── AppendOneNewlineSuccess
│ │ │ └── out.txt
│ │ ├── AppendSuccess
│ │ │ └── out.txt
│ │ ├── AppendTwoNewlineSuccess
│ │ │ └── out.txt
│ │ ├── FailsFileExists
│ │ │ └── out.txt
│ │ ├── FailsFileInUse
│ │ │ └── out.txt
│ │ ├── PrependClassicMacOSSuccess
│ │ │ └── out.txt
│ │ ├── PrependOneNewlineSuccess
│ │ │ └── out.txt
│ │ ├── PrependSuccess
│ │ │ └── out.txt
│ │ ├── PrependTwoNewlineSuccess
│ │ │ └── out.txt
│ │ ├── PrependUtf16Success
│ │ │ └── out.txt
│ │ └── SucceedsFileExists
│ │ │ └── out.txt
│ ├── ProcessorBaseTests
│ │ ├── CopyAndDeleteTempFile_DoesNotOverwrite
│ │ │ └── out.txt
│ │ ├── CopyAndDeleteTempFile_MovesToRecycleBin
│ │ │ └── out.txt
│ │ ├── CopyAndDeleteTempFile_Overwrites
│ │ │ └── out.txt
│ │ ├── CopyAndDeleteTempFile_Success
│ │ │ └── out.txt
│ │ ├── GetProcessingResultFromCopyAndDeleteTempFile_Failure
│ │ │ └── out.txt
│ │ └── GetProcessingResultFromCopyAndDeleteTempFile_Successs
│ │ │ └── out.txt
│ ├── RecycleProcessorTests
│ │ └── FailsWhenFileInUse
│ │ │ └── out.txt
│ ├── RemoveRepeatedLinesProcessorTests
│ │ ├── FailsFileExists
│ │ │ └── out.txt
│ │ ├── FailsFileInUse
│ │ │ └── out.txt
│ │ ├── SucceedsFileExists
│ │ │ └── out.txt
│ │ ├── Success
│ │ │ └── out.txt
│ │ ├── SuccessClassicMacOS
│ │ │ └── out.txt
│ │ ├── SuccessNoTrailingNewline
│ │ │ └── out.txt
│ │ └── SuccessUtf16
│ │ │ └── out.txt
│ └── ZipProcessorTests
│ │ ├── GeneratedFiles_PerGeneratedFile
│ │ ├── TextFile1ForZip.zip
│ │ ├── TextFile2ForZip.zip
│ │ └── TextFile3ForZip.zip
│ │ ├── GeneratedFiles_PerInputFile
│ │ └── BasicTextFile.zip
│ │ ├── OneZipPerSearch
│ │ └── output.zip
│ │ ├── OneZipPerSearch_AddContainingFolder
│ │ └── output.zip
│ │ ├── OneZipPerSearch_DoesNotOverwrite
│ │ └── output.zip
│ │ ├── OneZipPerSearch_Overwrites
│ │ └── output.zip
│ │ ├── SingleFiles
│ │ ├── TextFile1ForZip.zip
│ │ ├── TextFile2ForZip.zip
│ │ └── TextFile3ForZip.zip
│ │ └── SingleFiles_AddContainingFolder
│ │ ├── TextFile1ForZip.zip
│ │ ├── TextFile2ForZip.zip
│ │ └── TextFile3ForZip.zip
├── FileSharperCore.Tests.csproj
├── Processors
│ ├── CommandLineProcessorTests.cs
│ ├── CsvProcessorTests.cs
│ ├── DoNothingProcessorTests.cs
│ ├── Filesystem
│ │ ├── CopyFileProcessorTests.cs
│ │ ├── CreateDirectoryProcessorTests.cs
│ │ ├── CreateOrUpdateFileProcessorTests.cs
│ │ ├── FileDateProcessorTests.cs
│ │ └── RecycleProcessorTests.cs
│ ├── Image
│ │ └── ImageResizeProcessorTests.cs
│ ├── MultiProcessorTests.cs
│ ├── ProcessorBaseTests.cs
│ ├── SingleFileProcessorBaseTests.cs
│ ├── Text
│ │ ├── ChangeCaseProcessorTests.cs
│ │ ├── ChangeLineEndingsProcessorTests.cs
│ │ ├── FilterLinesProcessorTests.cs
│ │ ├── LineProcessorTests.cs
│ │ ├── PrependOrAppendTextProcessorTests.cs
│ │ └── RemoveRepeatedLinesProcessorTests.cs
│ └── ZipProcessorTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── TestBase.cs
├── TestFiles
│ ├── BasicTextFile.txt
│ ├── Lipsum.txt
│ ├── LipsumWithRepeatedLines.txt
│ ├── LipsumWithRepeatedLinesAndNoTrailingNewline.txt
│ ├── TextFileWithNewlines.txt
│ ├── TextFileWithNoTrailingNewline.txt
│ ├── ZipHierarchy
│ │ └── Subdir1
│ │ │ └── Subdir2
│ │ │ ├── Subdir3
│ │ │ ├── TextFile2ForZip.txt
│ │ │ └── TextFile3ForZip.txt
│ │ │ └── TextFile1ForZip.txt
│ └── beetle.jpg
├── TestUtil.cs
├── app.config
└── packages.config
├── FileSharperCore
├── ConditionCatalog.cs
├── ConditionNode.cs
├── Conditions
│ ├── AllCondition.cs
│ ├── AnyCondition.cs
│ ├── Binary
│ │ ├── BinaryDataContainsByteSequenceCondition.cs
│ │ ├── BinaryDataContainsTextCondition.cs
│ │ └── BinaryDataSearchCondition.cs
│ ├── CompoundCondition.cs
│ ├── ConditionBase.cs
│ ├── Filesystem
│ │ ├── FileAgeCondition.cs
│ │ ├── FileDateCondition.cs
│ │ ├── FileLengthCondition.cs
│ │ ├── FilePathContainsTextCondition.cs
│ │ └── ReadOnlyCondition.cs
│ ├── Image
│ │ ├── ImageAspectRatioCondition.cs
│ │ └── ImageDimensionCondition.cs
│ ├── MatchEverythingCondition.cs
│ ├── NotCondition.cs
│ ├── Text
│ │ ├── ContainsTextCondition.cs
│ │ ├── LineCountCondition.cs
│ │ ├── LineEndingsCondition.cs
│ │ ├── TextEncodingCondition.cs
│ │ └── WordCountCondition.cs
│ └── Xml
│ │ ├── XPathNodeCountCondition.cs
│ │ └── XPathStringValueCondition.cs
├── Editors
│ ├── DateTimePickerEditor.cs
│ ├── FileSharperMultiLineTextEditor.cs
│ ├── FolderChooserEditor.xaml
│ ├── FolderChooserEditor.xaml.cs
│ ├── OpenFileEditor.xaml
│ ├── OpenFileEditor.xaml.cs
│ ├── SaveFileEditor.xaml
│ └── SaveFileEditor.xaml.cs
├── Enums.cs
├── ExceptionInfo.cs
├── FieldSourceCatalog.cs
├── FieldSourceNode.cs
├── FieldSources
│ ├── FieldSourceBase.cs
│ ├── Filesystem
│ │ ├── FileAgeFieldSource.cs
│ │ ├── FileDateFieldSource.cs
│ │ ├── FileLengthFieldSource.cs
│ │ └── ReadOnlyFieldSource.cs
│ ├── Image
│ │ └── ImageDimensionsFieldSource.cs
│ ├── NothingFieldSource.cs
│ ├── Text
│ │ ├── LineCountFieldSource.cs
│ │ ├── LineEndingsFieldSource.cs
│ │ ├── TextEncodingFieldSource.cs
│ │ └── WordCountFieldSource.cs
│ └── Xml
│ │ ├── XPathNodeCountFieldSource.cs
│ │ └── XPathStringValueFieldSource.cs
├── FieldSourcesNode.cs
├── FileCaches
│ └── BitmapFileCache.cs
├── FileProgressInfo.cs
├── FileSharperCore.csproj
├── FileSourceCatalog.cs
├── FileSourceNode.cs
├── FileSources
│ ├── DirectorySearchFileSource.cs
│ ├── FileFileSource.cs
│ ├── FileSourceBase.cs
│ ├── ListFileSource.cs
│ └── TempFileWithTextFileSource.cs
├── ICondition.cs
├── IFieldSource.cs
├── IFileCache.cs
├── IFileSource.cs
├── IPluggableItem.cs
├── IPluggableItemWithColumns.cs
├── IPluggableItemWithColumnsAndCacheTypes.cs
├── IProcessor.cs
├── IRunInfo.cs
├── MatchResult.cs
├── PluggableItemBase.cs
├── PluggableItemWithColumnsAndCacheTypesBase.cs
├── PluggableItemWithColumnsBase.cs
├── ProcessingResult.cs
├── ProcessorCatalog.cs
├── ProcessorNode.cs
├── Processors
│ ├── CommandLineProcessor.cs
│ ├── CsvProcessor.cs
│ ├── DoNothingProcessor.cs
│ ├── Filesystem
│ │ ├── CopyFileProcessor.cs
│ │ ├── CreateDirectoryProcessor.cs
│ │ ├── CreateOrUpdateFileProcessor.cs
│ │ ├── FileDateProcessor.cs
│ │ └── RecycleProcessor.cs
│ ├── Image
│ │ └── ImageResizeProcessor.cs
│ ├── MultiProcessor.cs
│ ├── ProcessorBase.cs
│ ├── Shell
│ │ ├── OpenContainingFolderProcessor.cs
│ │ └── OpenFileProcessor.cs
│ ├── SingleFileProcessorBase.cs
│ ├── Text
│ │ ├── ChangeCaseProcessor.cs
│ │ ├── ChangeLineEndingsProcessor.cs
│ │ ├── FilterLinesProcessor.cs
│ │ ├── LineProcessor.cs
│ │ ├── PrependOrAppendTextProcessor.cs
│ │ ├── RemoveRepeatedLinesProcessor.cs
│ │ ├── ReplaceTextProcessor.cs
│ │ ├── SortLinesProcessor.cs
│ │ ├── SpacesToTabsProcessor.cs
│ │ ├── TabsToSpacesProcessor.cs
│ │ └── TrimWhitespaceProcessor.cs
│ └── ZipProcessor.cs
├── ProcessorsNode.cs
├── Properties
│ └── AssemblyInfo.cs
├── RunInfo.cs
├── SearchDocument.cs
├── SearchViewModel.cs
├── SharperEngine.cs
├── Util
│ ├── CompareUtil.cs
│ ├── HeaderUtil.cs
│ ├── PositiveFraction.cs
│ ├── ReplaceUtil.cs
│ ├── ReverseComparer.cs
│ ├── TextUtil.cs
│ ├── UnitUtil.cs
│ ├── UpgradeUtil.cs
│ └── XmlUtil.cs
├── app.config
└── packages.config
├── FileSharperSetup
└── FileSharperSetup.vdproj
├── FileSharperUI
├── ConditionNodeControl.xaml
├── ConditionNodeControl.xaml.cs
├── ConditionNodeListControl.xaml
├── ConditionNodeListControl.xaml.cs
├── ConditionNodeRowControl.xaml
├── ConditionNodeRowControl.xaml.cs
├── FieldSourceNodeControl.xaml
├── FieldSourceNodeControl.xaml.cs
├── FieldSourceNodeRowControl.xaml
├── FieldSourceNodeRowControl.xaml.cs
├── FieldSourcesNodeControl.xaml
├── FieldSourcesNodeControl.xaml.cs
├── FileSharperUI.csproj
├── FileSourceNodeControl.xaml
├── FileSourceNodeControl.xaml.cs
├── MatchLimitsControl.xaml
├── MatchLimitsControl.xaml.cs
├── ProcessorNodeControl.xaml
├── ProcessorNodeControl.xaml.cs
├── ProcessorNodeRowControl.xaml
├── ProcessorNodeRowControl.xaml.cs
├── ProcessorsNodeControl.xaml
├── ProcessorsNodeControl.xaml.cs
├── Properties
│ └── AssemblyInfo.cs
├── SearchDocumentControl.xaml
├── SearchDocumentControl.xaml.cs
├── SearchDocumentSetupControl.xaml
├── SearchDocumentSetupControl.xaml.cs
├── SearchViewModelControl.xaml
├── SearchViewModelControl.xaml.cs
├── app.config
└── packages.config
└── FileSharperUIHelpers
├── BoolToVisibilityConverter.cs
├── CountToVisibilityConverter.cs
├── FileSharperUIHelpers.csproj
├── HowOftenToVisibilityConverter.cs
├── InverseBooleanConverter.cs
├── ObjectToVisibilityConverter.cs
├── Properties
└── AssemblyInfo.cs
├── SearchViewModelToDynamicGridViewConverter.cs
├── SubtractNumberConverter.cs
├── TypeNameToConditionConverter.cs
├── TypeNameToFieldSourceConverter.cs
├── TypeNameToFileSourceConverter.cs
├── TypeNameToProcessorConverter.cs
└── app.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Many test files and test outputs have non-Windows line endings
5 | # that should be preserved.
6 | *.txt binary
7 | *.csv binary
8 | *.jpg binary
9 | *.png binary
10 | *.gif binary
11 | *.bmp binary
12 | *.exif binary
13 | *.zip binary
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | /src/FileSharper/FileSharper/bin
6 | /src/FileSharper/FileSharper/obj
7 | /src/FileSharper/.vs
8 | /src/FileSharper/FileSharperCore/bin
9 | /src/FileSharper/FileSharperCore/obj
10 | /src/FileSharper/FileSharperUI/bin
11 | /src/FileSharper/FileSharperUI/obj
12 | /src/FileSharper/FileSharperUIHelpers/bin
13 | /src/FileSharper/FileSharperUIHelpers/obj
14 | /src/FileSharper/packages
15 | *.csproj.user
16 | /README.md.bak
17 | /src/FileSharper/FileSharper/Thumbs.db
18 | /src/FileSharper/FileSharperSetup/Debug
19 | /src/FileSharper/FileSharperSetup/Release
20 | /src/FileSharper/FileSharperCore.Tests/bin/Debug
21 | /src/FileSharper/FileSharperCore.Tests/obj/Debug
22 | /src/FileSharper/FileSharperCore.Tests/bin/Release
23 | /src/FileSharper/FileSharperCore.Tests/obj/Release
24 |
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-slate
--------------------------------------------------------------------------------
/docs/images/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/docs/images/screenshot.png
--------------------------------------------------------------------------------
/docs/images/screenshotSmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/docs/images/screenshotSmall.png
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | Hopefully this will be the new homepage.
2 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Andrew Vardeman
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/AboutControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharper
8 | {
9 | ///
10 | /// Interaction logic for AboutControl.xaml
11 | ///
12 | public partial class AboutControl : UserControl
13 | {
14 | public AboutControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/App.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows;
6 | using System.Windows.Threading;
7 | using System.Runtime.InteropServices;
8 | using System;
9 | using System.IO;
10 | using System.Collections.Generic;
11 |
12 | namespace FileSharper
13 | {
14 | ///
15 | /// Interaction logic for App.xaml
16 | ///
17 | public partial class App : Application
18 | {
19 |
20 | public static FileInfo[] StartupFiles { get; set; }
21 |
22 | // https://stackoverflow.com/a/13523188
23 | void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
24 | {
25 | COMException ex = e.Exception as COMException;
26 | if (ex != null && ex.ErrorCode == -2147221040)
27 | e.Handled = true;
28 | }
29 |
30 | private void Application_Startup(object sender, StartupEventArgs e)
31 | {
32 | DirectoryInfo dir = new DirectoryInfo(Environment.CurrentDirectory);
33 | List allFiles = new List();
34 | foreach (string arg in e.Args)
35 | {
36 | try {
37 | // handle arguments like "*.fsh"
38 | allFiles.AddRange(dir.GetFiles(arg));
39 | }
40 | catch (Exception ex)
41 | {
42 | try
43 | {
44 | // most common scenario: full path
45 | allFiles.Add(new FileInfo(arg));
46 | }
47 | catch (Exception ex2)
48 | {
49 | // Oh I don't know. Whatever.
50 | }
51 | }
52 | }
53 | StartupFiles = allFiles.ToArray();
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/EulaControl.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 | License
11 | Copyright (c) 2017-2018 Andrew Vardeman
12 | Permission is hereby granted, free of charge, to any person obtaining a copy
13 | of this software and associated documentation files (the "Software"), to deal
14 | in the Software without restriction, including without limitation the rights
15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 | copies of the Software, and to permit persons to whom the Software is
17 | furnished to do so, subject to the following conditions:
18 | The above copyright notice and this permission notice shall be included in all
19 | copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | SOFTWARE.
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/EulaControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Data;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Navigation;
18 | using System.Windows.Shapes;
19 |
20 | namespace FileSharper
21 | {
22 | ///
23 | /// Interaction logic for EulaControl.xaml
24 | ///
25 | public partial class EulaControl : UserControl
26 | {
27 | public EulaControl()
28 | {
29 | InitializeComponent();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/FileSharper.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharper/FileSharper.ico
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/FileSharperFile.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharper/FileSharperFile.ico
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/FileSharperUtil.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Reflection;
9 |
10 | namespace FileSharper
11 | {
12 | public class FileSharperUtil
13 | {
14 | public static void LoadAssemblies()
15 | {
16 | HashSet existingDlls = new HashSet();
17 | List pathsToSearch = new List();
18 | pathsToSearch.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
19 | try
20 | {
21 | string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
22 | string configDirPath = Path.Combine(appDataPath, "FileSharper");
23 | Directory.CreateDirectory(configDirPath);
24 | string configFilePath = Path.Combine(configDirPath, "pluginDirs.conf");
25 | if (File.Exists(configFilePath))
26 | {
27 | pathsToSearch.AddRange(File.ReadAllLines(configFilePath));
28 | }
29 | }
30 | catch (Exception)
31 | {
32 | Console.WriteLine("Error loading plugins");
33 | }
34 | if (pathsToSearch.Count > 1)
35 | {
36 | foreach (string path in pathsToSearch)
37 | {
38 | try
39 | {
40 | DirectoryInfo dir = new DirectoryInfo(path);
41 | foreach (FileInfo dll in dir.GetFiles("*.dll"))
42 | {
43 | if (!existingDlls.Contains(dll.Name))
44 | {
45 | Assembly.LoadFrom(dll.FullName);
46 | existingDlls.Add(dll.Name);
47 | }
48 | }
49 | }
50 | catch (Exception ex)
51 | {
52 | Console.WriteLine($"Error searching DLLs from {path}: {ex.ToString()}");
53 | }
54 | }
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.ComponentModel;
7 | using System.Windows;
8 |
9 | namespace FileSharper
10 | {
11 | ///
12 | /// Interaction logic for MainWindow.xaml
13 | ///
14 | public partial class MainWindow : Window
15 | {
16 | public MainWindow()
17 | {
18 | FileSharperUtil.LoadAssemblies();
19 | InitializeComponent();
20 | DataContext = new MainViewModel();
21 | }
22 |
23 | protected override void OnClosing(CancelEventArgs e)
24 | {
25 | base.OnClosing(e);
26 | try
27 | {
28 | ((MainViewModel)DataContext)?.Settings?.Save();
29 | }
30 | catch (Exception ex)
31 | {
32 | MessageBox.Show(this, "Error saving settings: " + ex.ToString());
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/ManageTemplatesControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Data;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Navigation;
18 | using System.Windows.Shapes;
19 |
20 | namespace FileSharper
21 | {
22 | ///
23 | /// Interaction logic for ManageTemplatesControl.xaml
24 | ///
25 | public partial class ManageTemplatesControl : UserControl
26 | {
27 | public ManageTemplatesControl()
28 | {
29 | InitializeComponent();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/PathHelpControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharper
8 | {
9 | ///
10 | /// Interaction logic for PathHelpControl.xaml
11 | ///
12 | public partial class PathHelpControl : UserControl
13 | {
14 | public PathHelpControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace FileSharper.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/Templates/01 Simple Search.fsh:
--------------------------------------------------------------------------------
1 | {
2 | "FileSourceExpanded": true,
3 | "ConditionExpanded": false,
4 | "FieldSourcesExpanded": false,
5 | "TestedProcessorsExpanded": false,
6 | "MatchedProcessorsExpanded": false,
7 | "FileSourceNode": {
8 | "FileSourceTypeName": "FileSharperCore.FileSources.DirectorySearchFileSource",
9 | "Description": "Searches through the specified directory for files matching the specified pattern.",
10 | "Parameters": {
11 | "Directory": "C:\\",
12 | "Recursive": true,
13 | "FilePattern": "*",
14 | "SearchOrder": "SystemDefault",
15 | "IncludeHidden": false,
16 | "IncludeSystem": false
17 | }
18 | },
19 | "ConditionNode": {
20 | "ConditionTypeName": null,
21 | "Not": false,
22 | "Description": null,
23 | "Parameters": null,
24 | "ChildNodes": []
25 | },
26 | "FieldSourcesNode": {
27 | "FieldSourceNodes": [
28 | {
29 | "FieldSourceTypeName": null,
30 | "Description": null,
31 | "Parameters": null
32 | }
33 | ]
34 | },
35 | "TestedProcessorsNode": {
36 | "ProcessorNodes": [
37 | {
38 | "ProcessorTypeName": null,
39 | "Description": null,
40 | "InputFileSource": "OriginalFile",
41 | "Parameters": null,
42 | "ChildProcessorsNode": null
43 | }
44 | ]
45 | },
46 | "MatchedProcessorsNode": {
47 | "ProcessorNodes": [
48 | {
49 | "ProcessorTypeName": null,
50 | "Description": null,
51 | "InputFileSource": "OriginalFile",
52 | "Parameters": null,
53 | "ChildProcessorsNode": null
54 | }
55 | ]
56 | },
57 | "LimitMatches": false,
58 | "MaxToMatch": 1000,
59 | "MaxResultsDisplayed": 200,
60 | "MaxExceptionsDisplayed": 20
61 | }
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/Templates/02 Regex Replace.fsh:
--------------------------------------------------------------------------------
1 | {
2 | "FileSourceExpanded": true,
3 | "ConditionExpanded": false,
4 | "FieldSourcesExpanded": false,
5 | "TestedProcessorsExpanded": false,
6 | "MatchedProcessorsExpanded": true,
7 | "FileSourceNode": {
8 | "FileSourceTypeName": "FileSharperCore.FileSources.DirectorySearchFileSource",
9 | "Description": "Searches through the specified directory for files matching the specified pattern.",
10 | "Parameters": {
11 | "Directory": "ENTER A DIRECTORY",
12 | "Recursive": true,
13 | "FilePattern": "*.txt",
14 | "SearchOrder": "SystemDefault",
15 | "IncludeHidden": false,
16 | "IncludeSystem": false
17 | }
18 | },
19 | "ConditionNode": {
20 | "ConditionTypeName": null,
21 | "Not": false,
22 | "Description": null,
23 | "Parameters": null,
24 | "ChildNodes": []
25 | },
26 | "FieldSourcesNode": {
27 | "FieldSourceNodes": [
28 | {
29 | "FieldSourceTypeName": null,
30 | "Description": null,
31 | "Parameters": null
32 | }
33 | ]
34 | },
35 | "TestedProcessorsNode": {
36 | "ProcessorNodes": [
37 | {
38 | "ProcessorTypeName": null,
39 | "Description": null,
40 | "InputFileSource": "OriginalFile",
41 | "Parameters": null,
42 | "ChildProcessorsNode": null
43 | }
44 | ]
45 | },
46 | "MatchedProcessorsNode": {
47 | "ProcessorNodes": [
48 | {
49 | "ProcessorTypeName": "FileSharperCore.Processors.Text.ReplaceTextProcessor",
50 | "Description": "Replace text, optionally using a regular expression",
51 | "InputFileSource": "OriginalFile",
52 | "Parameters": {
53 | "TextToMatch": "YOUR REGEX HERE",
54 | "ReplacementText": null,
55 | "MatchOnlyWithinSingleLine": true,
56 | "UseRegex": true,
57 | "RegexStartAndEndMatchPerLine": false,
58 | "RegexDotMatchesNewline": false,
59 | "CaseSensitive": false,
60 | "LineEndings": "SystemDefault",
61 | "OutputEncoding": "MatchInput",
62 | "FileName": "{DirectoryName}\\{NameWithoutExtension}{Extension}",
63 | "OverwriteExistingFile": true,
64 | "MoveOriginalToRecycleBin": true
65 | },
66 | "ChildProcessorsNode": null
67 | }
68 | ]
69 | },
70 | "LimitMatches": false,
71 | "MaxToMatch": 1000,
72 | "MaxResultsDisplayed": 200,
73 | "MaxExceptionsDisplayed": 20
74 | }
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharper/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CommandLineProcessorTests/RunsCommandLine/BasicTextFile.txt:
--------------------------------------------------------------------------------
1 | This is a text file.
2 |
3 | It is a basic text file.
4 | Some of the lines are close together like this.
5 |
6 |
7 |
8 |
9 |
10 | Some of the lines are far apart, like this.
11 |
12 |
13 |
14 | This file ends with a new line, as all good UNIX text files should.
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CopyFileProcessorTests/DoesNotOverwrite/out.txt:
--------------------------------------------------------------------------------
1 | This file will not be overwritten.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CopyFileProcessorTests/Overwrites/out.txt:
--------------------------------------------------------------------------------
1 | This is a text file.
2 |
3 | It is a basic text file.
4 | Some of the lines are close together like this.
5 |
6 |
7 |
8 |
9 |
10 | Some of the lines are far apart, like this.
11 |
12 |
13 |
14 | This file ends with a new line, as all good UNIX text files should.
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CopyFileProcessorTests/Success/out.txt:
--------------------------------------------------------------------------------
1 | This is a text file.
2 |
3 | It is a basic text file.
4 | Some of the lines are close together like this.
5 |
6 |
7 |
8 |
9 |
10 | Some of the lines are far apart, like this.
11 |
12 |
13 |
14 | This file ends with a new line, as all good UNIX text files should.
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CreateOrUpdateFileProcessorTests/CreatesFile/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CreateOrUpdateFileProcessorTests/CreatesFile/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CreateOrUpdateFileProcessorTests/DoesNotUpdateDate/out.txt:
--------------------------------------------------------------------------------
1 | This file will not have its date updated.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CreateOrUpdateFileProcessorTests/ExceptionUpdatingDate/out.txt:
--------------------------------------------------------------------------------
1 | This file will have its date updated.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CreateOrUpdateFileProcessorTests/UpdatesDate/out.txt:
--------------------------------------------------------------------------------
1 | This file will have its date updated.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CsvProcessorTests/ClassicMacOS/ClassicMacOS.csv:
--------------------------------------------------------------------------------
1 | Path,Filename,Matches,foo,bar,baz,hello,world
\\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles,BasicTextFile.txt,Yes,a,b,c,d,e
\\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles,TextFileWithNewlines.txt,No,q,w,e,r,t
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CsvProcessorTests/FullPath/FullPath.csv:
--------------------------------------------------------------------------------
1 | Filename,Matches,foo,bar,baz,hello,world
2 | \\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles\BasicTextFile.txt,Yes,a,b,c,d,e
3 | \\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles\TextFileWithNewlines.txt,No,q,w,e,r,t
4 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CsvProcessorTests/NameThenDirectory/NameThenDirectory.csv:
--------------------------------------------------------------------------------
1 | Filename,Path,Matches,foo,bar,baz,hello,world
2 | BasicTextFile.txt,\\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles,Yes,a,b,c,d,e
3 | TextFileWithNewlines.txt,\\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles,No,q,w,e,r,t
4 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CsvProcessorTests/Unix/Unix.csv:
--------------------------------------------------------------------------------
1 | Path,Filename,Matches,foo,bar,baz,hello,world
2 | \\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles,BasicTextFile.txt,Yes,a,b,c,d,e
3 | \\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles,TextFileWithNewlines.txt,No,q,w,e,r,t
4 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/CsvProcessorTests/Windows/Windows.csv:
--------------------------------------------------------------------------------
1 | Path,Filename,Matches,foo,bar,baz,hello,world
2 | \\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles,BasicTextFile.txt,Yes,a,b,c,d,e
3 | \\Mac\Home\Documents\GitHub\FileSharper\src\FileSharper\FileSharperCore.Tests\TestFiles,TextFileWithNewlines.txt,No,q,w,e,r,t
4 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FileDateProcessorTests/FailsWhenFileLocked/out.txt:
--------------------------------------------------------------------------------
1 | This file will not have its date set.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FileDateProcessorTests/SetsAccessedDate/out.txt:
--------------------------------------------------------------------------------
1 | This file will have its date set.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FileDateProcessorTests/SetsCreatedDate/out.txt:
--------------------------------------------------------------------------------
1 | This file will have its date set.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FileDateProcessorTests/SetsModificationDate/out.txt:
--------------------------------------------------------------------------------
1 | This file will have its date set.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/FailsFileExists/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/FailsFileExists/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/FailsFileInUse/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/FailsFileInUse/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessCaseInsensitiveNoRegex/out.txt:
--------------------------------------------------------------------------------
1 | Vivamus interdum lobortis semper.
2 | Vivamus eu ullamcorper erat.
3 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessCaseInsensitiveRegex/out.txt:
--------------------------------------------------------------------------------
1 | Vivamus interdum lobortis semper.
2 | Vivamus eu ullamcorper erat.
3 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessCaseSensitiveNoRegex/out.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessCaseSensitiveRegex/out.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessKeepNoRegex/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | in volutpat nisl consectetur et.
4 | Orci varius natoque penatibus et magnis dis parturient montes,
5 | nascetur ridiculus mus.
6 | Vestibulum maximus nulla pretium est fringilla placerat.
7 | Fusce sit amet erat a mi vehicula bibendum.
8 | Vestibulum vulputate mi eget est laoreet,
9 | id porttitor est pharetra.
10 | Quisque eget ligula auctor elit faucibus lacinia.
11 | Nunc sit amet maximus leo.
12 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessKeepRegex/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | Orci varius natoque penatibus et magnis dis parturient montes,
3 | Vestibulum vulputate mi eget est laoreet,
4 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessNoTrailingNewline/out.txt:
--------------------------------------------------------------------------------
1 | This text file has two lines of text
2 | and no trailing newline.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessRemoveNoRegex/out.txt:
--------------------------------------------------------------------------------
1 | Curabitur ac ipsum at purus malesuada sagittis.
2 | Vivamus interdum lobortis semper.
3 | Cras vestibulum eleifend dolor,
4 | Sed id est sem.
5 | Morbi ut orci est.
6 | Sed ornare ullamcorper magna,
7 | eu commodo sem.
8 | Pellentesque eros quam,
9 | tristique non maximus a,
10 | pellentesque ac dolor.
11 | Vivamus eu ullamcorper erat.
12 | Curabitur euismod dui sed felis pulvinar euismod.
13 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/FilterLinesProcessorTests/SuccessRemoveRegex/out.txt:
--------------------------------------------------------------------------------
1 | consectetur adipiscing elit.
2 | Curabitur ac ipsum at purus malesuada sagittis.
3 | Vivamus interdum lobortis semper.
4 | Cras vestibulum eleifend dolor,
5 | in volutpat nisl consectetur et.
6 | Sed id est sem.
7 | nascetur ridiculus mus.
8 | Vestibulum maximus nulla pretium est fringilla placerat.
9 | Morbi ut orci est.
10 | Sed ornare ullamcorper magna,
11 | eu commodo sem.
12 | Pellentesque eros quam,
13 | tristique non maximus a,
14 | pellentesque ac dolor.
15 | Fusce sit amet erat a mi vehicula bibendum.
16 | Vivamus eu ullamcorper erat.
17 | id porttitor est pharetra.
18 | Quisque eget ligula auctor elit faucibus lacinia.
19 | Nunc sit amet maximus leo.
20 | Curabitur euismod dui sed felis pulvinar euismod.
21 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Height100Jpeg/out.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Height100Jpeg/out.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Height900Jpeg/out.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Height900Jpeg/out.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/ResizeBeetleOverwriteFalse/out.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/ResizeBeetleOverwriteFalse/out.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/ResizeBeetleOverwriteTrueFailure/out.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/ResizeBeetleOverwriteTrueFailure/out.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/ResizeBeetleOverwriteTrueSuccess/out.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/ResizeBeetleOverwriteTrueSuccess/out.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Bmp/out.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Bmp/out.bmp
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Exif/out.exif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Exif/out.exif
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Gif/out.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Gif/out.gif
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Jpeg/out.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Jpeg/out.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Png/out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Png/out.png
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Tiff/out.tif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width100Tiff/out.tif
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width1200Jpeg/out.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/Width1200Jpeg/out.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/out.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ImageResizeProcessorTests/out.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/FailsExistingFile/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/FailsExistingFile/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/FailsFileInUse/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/FailsFileInUse/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/SucceedsExistingFile/out.txt:
--------------------------------------------------------------------------------
1 | The transformed line
2 | The transformed line
3 | The transformed line
4 | The transformed line
5 | The transformed line
6 | The transformed line
7 | The transformed line
8 | The transformed line
9 | The transformed line
10 | The transformed line
11 | The transformed line
12 | The transformed line
13 | The transformed line
14 | The transformed line
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/Success/out.txt:
--------------------------------------------------------------------------------
1 | The transformed line
2 | The transformed line
3 | The transformed line
4 | The transformed line
5 | The transformed line
6 | The transformed line
7 | The transformed line
8 | The transformed line
9 | The transformed line
10 | The transformed line
11 | The transformed line
12 | The transformed line
13 | The transformed line
14 | The transformed line
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/SuccessClassicMacOS/out.txt:
--------------------------------------------------------------------------------
1 | The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
The transformed line
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/SuccessMatchInput/out.txt:
--------------------------------------------------------------------------------
1 | The transformed line
2 | The transformed line
3 | The transformed line
4 | The transformed line
5 | The transformed line
6 | The transformed line
7 | The transformed line
8 | The transformed line
9 | The transformed line
10 | The transformed line
11 | The transformed line
12 | The transformed line
13 | The transformed line
14 | The transformed line
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/SuccessNoTrailingNewline/out.txt:
--------------------------------------------------------------------------------
1 | The transformed line
2 | The transformed line
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/SuccessUnix/out.txt:
--------------------------------------------------------------------------------
1 | The transformed line
2 | The transformed line
3 | The transformed line
4 | The transformed line
5 | The transformed line
6 | The transformed line
7 | The transformed line
8 | The transformed line
9 | The transformed line
10 | The transformed line
11 | The transformed line
12 | The transformed line
13 | The transformed line
14 | The transformed line
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/SuccessUtf16/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/SuccessUtf16/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/LineProcessorTests/SuccessWindows/out.txt:
--------------------------------------------------------------------------------
1 | The transformed line
2 | The transformed line
3 | The transformed line
4 | The transformed line
5 | The transformed line
6 | The transformed line
7 | The transformed line
8 | The transformed line
9 | The transformed line
10 | The transformed line
11 | The transformed line
12 | The transformed line
13 | The transformed line
14 | The transformed line
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/AppendOneNewlineSuccess/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
24 | foo bar baz
25 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/AppendSuccess/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
24 | foo bar baz
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/AppendTwoNewlineSuccess/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
24 | foo bar baz
25 |
26 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/FailsFileExists/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/FailsFileExists/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/FailsFileInUse/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/FailsFileInUse/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/PrependClassicMacOSSuccess/out.txt:
--------------------------------------------------------------------------------
1 | foo bar bazLorem ipsum dolor sit amet,
consectetur adipiscing elit.
Curabitur ac ipsum at purus malesuada sagittis.
Vivamus interdum lobortis semper.
Cras vestibulum eleifend dolor,
in volutpat nisl consectetur et.
Sed id est sem.
Orci varius natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus.
Vestibulum maximus nulla pretium est fringilla placerat.
Morbi ut orci est.
Sed ornare ullamcorper magna,
eu commodo sem.
Pellentesque eros quam,
tristique non maximus a,
pellentesque ac dolor.
Fusce sit amet erat a mi vehicula bibendum.
Vivamus eu ullamcorper erat.
Vestibulum vulputate mi eget est laoreet,
id porttitor est pharetra.
Quisque eget ligula auctor elit faucibus lacinia.
Nunc sit amet maximus leo.
Curabitur euismod dui sed felis pulvinar euismod.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/PrependOneNewlineSuccess/out.txt:
--------------------------------------------------------------------------------
1 | foo bar baz
2 | Lorem ipsum dolor sit amet,
3 | consectetur adipiscing elit.
4 | Curabitur ac ipsum at purus malesuada sagittis.
5 | Vivamus interdum lobortis semper.
6 | Cras vestibulum eleifend dolor,
7 | in volutpat nisl consectetur et.
8 | Sed id est sem.
9 | Orci varius natoque penatibus et magnis dis parturient montes,
10 | nascetur ridiculus mus.
11 | Vestibulum maximus nulla pretium est fringilla placerat.
12 | Morbi ut orci est.
13 | Sed ornare ullamcorper magna,
14 | eu commodo sem.
15 | Pellentesque eros quam,
16 | tristique non maximus a,
17 | pellentesque ac dolor.
18 | Fusce sit amet erat a mi vehicula bibendum.
19 | Vivamus eu ullamcorper erat.
20 | Vestibulum vulputate mi eget est laoreet,
21 | id porttitor est pharetra.
22 | Quisque eget ligula auctor elit faucibus lacinia.
23 | Nunc sit amet maximus leo.
24 | Curabitur euismod dui sed felis pulvinar euismod.
25 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/PrependSuccess/out.txt:
--------------------------------------------------------------------------------
1 | foo bar bazLorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
24 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/PrependTwoNewlineSuccess/out.txt:
--------------------------------------------------------------------------------
1 | foo bar baz
2 |
3 | Lorem ipsum dolor sit amet,
4 | consectetur adipiscing elit.
5 | Curabitur ac ipsum at purus malesuada sagittis.
6 | Vivamus interdum lobortis semper.
7 | Cras vestibulum eleifend dolor,
8 | in volutpat nisl consectetur et.
9 | Sed id est sem.
10 | Orci varius natoque penatibus et magnis dis parturient montes,
11 | nascetur ridiculus mus.
12 | Vestibulum maximus nulla pretium est fringilla placerat.
13 | Morbi ut orci est.
14 | Sed ornare ullamcorper magna,
15 | eu commodo sem.
16 | Pellentesque eros quam,
17 | tristique non maximus a,
18 | pellentesque ac dolor.
19 | Fusce sit amet erat a mi vehicula bibendum.
20 | Vivamus eu ullamcorper erat.
21 | Vestibulum vulputate mi eget est laoreet,
22 | id porttitor est pharetra.
23 | Quisque eget ligula auctor elit faucibus lacinia.
24 | Nunc sit amet maximus leo.
25 | Curabitur euismod dui sed felis pulvinar euismod.
26 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/PrependUtf16Success/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/PrependUtf16Success/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/PrependOrAppendTextProcessorTests/SucceedsFileExists/out.txt:
--------------------------------------------------------------------------------
1 | foo bar bazLorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
24 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ProcessorBaseTests/CopyAndDeleteTempFile_DoesNotOverwrite/out.txt:
--------------------------------------------------------------------------------
1 | This file will not be overwritten.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ProcessorBaseTests/CopyAndDeleteTempFile_MovesToRecycleBin/out.txt:
--------------------------------------------------------------------------------
1 | This is the final text.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ProcessorBaseTests/CopyAndDeleteTempFile_Overwrites/out.txt:
--------------------------------------------------------------------------------
1 | This is the final text.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ProcessorBaseTests/CopyAndDeleteTempFile_Success/out.txt:
--------------------------------------------------------------------------------
1 | This is the output text.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ProcessorBaseTests/GetProcessingResultFromCopyAndDeleteTempFile_Failure/out.txt:
--------------------------------------------------------------------------------
1 | This file will not be overwritten.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ProcessorBaseTests/GetProcessingResultFromCopyAndDeleteTempFile_Successs/out.txt:
--------------------------------------------------------------------------------
1 | This is the final text.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RecycleProcessorTests/FailsWhenFileInUse/out.txt:
--------------------------------------------------------------------------------
1 | This file will not be moved to the Recycle Bin.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/FailsFileExists/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/FailsFileExists/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/FailsFileInUse/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/FailsFileInUse/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/SucceedsFileExists/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
24 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/Success/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
24 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/SuccessClassicMacOS/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Curabitur ac ipsum at purus malesuada sagittis.
Vivamus interdum lobortis semper.
Cras vestibulum eleifend dolor,
in volutpat nisl consectetur et.
Sed id est sem.
Orci varius natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus.
Vestibulum maximus nulla pretium est fringilla placerat.
Morbi ut orci est.
Sed ornare ullamcorper magna,
eu commodo sem.
Pellentesque eros quam,
tristique non maximus a,
pellentesque ac dolor.
Fusce sit amet erat a mi vehicula bibendum.
Vivamus eu ullamcorper erat.
Vestibulum vulputate mi eget est laoreet,
id porttitor est pharetra.
Quisque eget ligula auctor elit faucibus lacinia.
Nunc sit amet maximus leo.
Curabitur euismod dui sed felis pulvinar euismod.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/SuccessNoTrailingNewline/out.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/SuccessUtf16/out.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/RemoveRepeatedLinesProcessorTests/SuccessUtf16/out.txt
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/GeneratedFiles_PerGeneratedFile/TextFile1ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/GeneratedFiles_PerGeneratedFile/TextFile1ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/GeneratedFiles_PerGeneratedFile/TextFile2ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/GeneratedFiles_PerGeneratedFile/TextFile2ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/GeneratedFiles_PerGeneratedFile/TextFile3ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/GeneratedFiles_PerGeneratedFile/TextFile3ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/GeneratedFiles_PerInputFile/BasicTextFile.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/GeneratedFiles_PerInputFile/BasicTextFile.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/OneZipPerSearch/output.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/OneZipPerSearch/output.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/OneZipPerSearch_AddContainingFolder/output.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/OneZipPerSearch_AddContainingFolder/output.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/OneZipPerSearch_DoesNotOverwrite/output.zip:
--------------------------------------------------------------------------------
1 | This file will not be replaced. Also it's not really a zip file.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/OneZipPerSearch_Overwrites/output.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/OneZipPerSearch_Overwrites/output.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles/TextFile1ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles/TextFile1ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles/TextFile2ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles/TextFile2ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles/TextFile3ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles/TextFile3ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles_AddContainingFolder/TextFile1ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles_AddContainingFolder/TextFile1ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles_AddContainingFolder/TextFile2ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles_AddContainingFolder/TextFile2ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles_AddContainingFolder/TextFile3ForZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/ExpectedResults/ZipProcessorTests/SingleFiles_AddContainingFolder/TextFile3ForZip.zip
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/Processors/DoNothingProcessorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.IO;
6 | using System.Threading;
7 | using FileSharperCore.Processors;
8 | using Microsoft.VisualStudio.TestTools.UnitTesting;
9 |
10 | namespace FileSharperCore.Tests.Processors
11 | {
12 | [TestClass]
13 | public class DoNothingProcessorTests: TestBase
14 | {
15 | [TestMethod]
16 | public void Succeeds()
17 | {
18 | DoNothingProcessor p = new DoNothingProcessor();
19 | p.Init(RunInfo);
20 | FileInfo file = GetTestFile("BasicTextFile.txt");
21 | ProcessingResult result = p.Process(file, MatchResultType.Yes, new string[0], new FileInfo[0],
22 | ProcessInput.OriginalFile, CancellationToken.None);
23 | Assert.AreEqual(ProcessingResultType.Success, result.Type);
24 | p.Cleanup();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/Processors/Filesystem/CreateDirectoryProcessorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.IO;
6 | using System.Threading;
7 | using FileSharperCore.Processors.Filesystem;
8 | using Microsoft.VisualStudio.TestTools.UnitTesting;
9 |
10 | namespace FileSharperCore.Tests.Processors.Filesystem
11 | {
12 | [TestClass]
13 | public class CreateDirectoryProcessorTests : TestBase
14 | {
15 | [TestMethod]
16 | public void Success()
17 | {
18 | CreateDirectoryProcessor processor = new CreateDirectoryProcessor();
19 | processor.SetParameter("DirectoryPath", GetCurrentTestResultsFilePath("Subdir"));
20 | FileInfo file = GetTestFile("BasicTextFile.txt");
21 | processor.Init(RunInfo);
22 | ProcessingResult result = processor.Process(file, MatchResultType.Yes,
23 | new string[0], new FileInfo[0], ProcessInput.OriginalFile,
24 | CancellationToken.None);
25 | processor.Cleanup();
26 | Assert.AreEqual(ProcessingResultType.Success, result.Type);
27 | Assert.AreEqual(0, result.OutputFiles.Length);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/Processors/Filesystem/RecycleProcessorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.IO;
6 | using System.Threading;
7 | using FileSharperCore.Processors.Filesystem;
8 | using Microsoft.VisualStudio.TestTools.UnitTesting;
9 |
10 | namespace FileSharperCore.Tests.Processors.Filesystem
11 | {
12 | [TestClass]
13 | public class RecycleProcessorTests : TestBase
14 | {
15 | [TestMethod]
16 | public void RecyclesFile()
17 | {
18 | RecycleProcessor processor = new RecycleProcessor();
19 | string outputPath = GetCurrentTestResultsFilePath("out.txt");
20 | FileInfo outputFile = new FileInfo(outputPath);
21 | File.WriteAllText(outputPath, "This file will be moved to the Recycle Bin.");
22 | processor.Init(RunInfo);
23 | ProcessingResult result = processor.Process(outputFile, MatchResultType.Yes,
24 | new string[0], new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None);
25 | processor.Cleanup();
26 | Assert.IsFalse(File.Exists(outputPath));
27 | Assert.AreEqual(ProcessingResultType.Success, result.Type);
28 | Assert.AreEqual(0, result.OutputFiles.Length);
29 | }
30 |
31 | [TestMethod]
32 | public void FailsWhenFileInUse()
33 | {
34 | RecycleProcessor processor = new RecycleProcessor();
35 | string outputPath = GetCurrentTestResultsFilePath("out.txt");
36 | FileInfo outputFile = new FileInfo(outputPath);
37 | File.WriteAllText(outputPath, "This file will not be moved to the Recycle Bin.");
38 | ProcessingResult result;
39 | using (FileStream stream = File.OpenRead(outputPath))
40 | {
41 | processor.Init(RunInfo);
42 | result = processor.Process(outputFile, MatchResultType.Yes, new string[0],
43 | new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None);
44 | processor.Cleanup();
45 | }
46 | Assert.IsTrue(File.Exists(outputPath));
47 | Assert.AreEqual(ProcessingResultType.Failure, result.Type);
48 | Assert.AreEqual(0, result.OutputFiles.Length);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/Processors/Text/ChangeLineEndingsProcessorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using FileSharperCore.Processors.Text;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 |
8 | namespace FileSharperCore.Tests.Processors.Text
9 | {
10 | [TestClass]
11 | public class ChangeLineEndingsProcessorTests : TestBase
12 | {
13 | [TestMethod]
14 | public void ExposesParameters()
15 | {
16 | // The use of these properties is tested in LineProcessorTests.
17 | // All we need to do here is verify that the parameters are
18 | // being exposed properly.
19 |
20 | ChangeLineEndingsProcessor processor = new ChangeLineEndingsProcessor();
21 |
22 | processor.SetParameter("MoveOriginalToRecycleBin", true);
23 | Assert.AreEqual(true, processor.MoveOriginalToRecycleBin);
24 |
25 | processor.SetParameter("LineEndings", LineEndingsNoFile.ClassicMacOS);
26 | Assert.AreEqual(LineEndings.ClassicMacOS, processor.LineEndings);
27 |
28 | processor.SetParameter("OutputEncoding", OutputEncodingType.UTF16_LE);
29 | Assert.AreEqual(OutputEncodingType.UTF16_LE, processor.OutputEncodingType);
30 |
31 | processor.SetParameter("FileName", @"C:\foo.txt");
32 | Assert.AreEqual(@"C:\foo.txt", processor.FileName);
33 |
34 | processor.SetParameter("OverwriteExistingFile", true);
35 | Assert.AreEqual(true, processor.OverwriteExistingFile);
36 | }
37 |
38 | [TestMethod]
39 | public void TransformLineSuccess()
40 | {
41 | ChangeLineEndingsProcessor processor = new ChangeLineEndingsProcessor();
42 | processor.SetParameter("LineEndings", LineEndingsNoFile.ClassicMacOS);
43 |
44 | processor.Init(RunInfo);
45 |
46 | string line = "The quick brown fox jumps over the lazy dog.";
47 | string transformedLine = processor.TransformLine(line);
48 | Assert.AreEqual(line, transformedLine);
49 |
50 | processor.Cleanup();
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Reflection;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | [assembly: AssemblyTitle("FileSharperCore.Tests")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("FileSharperCore.Tests")]
14 | [assembly: AssemblyCopyright("Copyright © 2018")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | [assembly: ComVisible(false)]
19 |
20 | [assembly: Guid("5c535cf6-2b91-450e-9e53-b8160c2dd6b3")]
21 |
22 | // [assembly: AssemblyVersion("1.0.*")]
23 | [assembly: AssemblyVersion("1.0.0.0")]
24 | [assembly: AssemblyFileVersion("1.0.0.0")]
25 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/BasicTextFile.txt:
--------------------------------------------------------------------------------
1 | This is a text file.
2 |
3 | It is a basic text file.
4 | Some of the lines are close together like this.
5 |
6 |
7 |
8 |
9 |
10 | Some of the lines are far apart, like this.
11 |
12 |
13 |
14 | This file ends with a new line, as all good UNIX text files should.
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/Lipsum.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Vivamus interdum lobortis semper.
5 | Cras vestibulum eleifend dolor,
6 | in volutpat nisl consectetur et.
7 | Sed id est sem.
8 | Orci varius natoque penatibus et magnis dis parturient montes,
9 | nascetur ridiculus mus.
10 | Vestibulum maximus nulla pretium est fringilla placerat.
11 | Morbi ut orci est.
12 | Sed ornare ullamcorper magna,
13 | eu commodo sem.
14 | Pellentesque eros quam,
15 | tristique non maximus a,
16 | pellentesque ac dolor.
17 | Fusce sit amet erat a mi vehicula bibendum.
18 | Vivamus eu ullamcorper erat.
19 | Vestibulum vulputate mi eget est laoreet,
20 | id porttitor est pharetra.
21 | Quisque eget ligula auctor elit faucibus lacinia.
22 | Nunc sit amet maximus leo.
23 | Curabitur euismod dui sed felis pulvinar euismod.
24 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/LipsumWithRepeatedLines.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Curabitur ac ipsum at purus malesuada sagittis.
5 | Curabitur ac ipsum at purus malesuada sagittis.
6 | Curabitur ac ipsum at purus malesuada sagittis.
7 | Vivamus interdum lobortis semper.
8 | Cras vestibulum eleifend dolor,
9 | in volutpat nisl consectetur et.
10 | Sed id est sem.
11 | Orci varius natoque penatibus et magnis dis parturient montes,
12 | nascetur ridiculus mus.
13 | Vestibulum maximus nulla pretium est fringilla placerat.
14 | Morbi ut orci est.
15 | Sed ornare ullamcorper magna,
16 | Sed ornare ullamcorper magna,
17 | eu commodo sem.
18 | Pellentesque eros quam,
19 | tristique non maximus a,
20 | pellentesque ac dolor.
21 | Fusce sit amet erat a mi vehicula bibendum.
22 | Fusce sit amet erat a mi vehicula bibendum.
23 | Fusce sit amet erat a mi vehicula bibendum.
24 | Vivamus eu ullamcorper erat.
25 | Vestibulum vulputate mi eget est laoreet,
26 | id porttitor est pharetra.
27 | Quisque eget ligula auctor elit faucibus lacinia.
28 | Nunc sit amet maximus leo.
29 | Curabitur euismod dui sed felis pulvinar euismod.
30 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/LipsumWithRepeatedLinesAndNoTrailingNewline.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet,
2 | consectetur adipiscing elit.
3 | Curabitur ac ipsum at purus malesuada sagittis.
4 | Curabitur ac ipsum at purus malesuada sagittis.
5 | Curabitur ac ipsum at purus malesuada sagittis.
6 | Curabitur ac ipsum at purus malesuada sagittis.
7 | Vivamus interdum lobortis semper.
8 | Cras vestibulum eleifend dolor,
9 | in volutpat nisl consectetur et.
10 | Sed id est sem.
11 | Orci varius natoque penatibus et magnis dis parturient montes,
12 | nascetur ridiculus mus.
13 | Vestibulum maximus nulla pretium est fringilla placerat.
14 | Morbi ut orci est.
15 | Sed ornare ullamcorper magna,
16 | Sed ornare ullamcorper magna,
17 | eu commodo sem.
18 | Pellentesque eros quam,
19 | tristique non maximus a,
20 | pellentesque ac dolor.
21 | Fusce sit amet erat a mi vehicula bibendum.
22 | Fusce sit amet erat a mi vehicula bibendum.
23 | Fusce sit amet erat a mi vehicula bibendum.
24 | Vivamus eu ullamcorper erat.
25 | Vestibulum vulputate mi eget est laoreet,
26 | id porttitor est pharetra.
27 | Quisque eget ligula auctor elit faucibus lacinia.
28 | Nunc sit amet maximus leo.
29 | Curabitur euismod dui sed felis pulvinar euismod.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/TextFileWithNewlines.txt:
--------------------------------------------------------------------------------
1 | This line is the first line.
2 | This line is the second line.
3 |
4 | There was an empty line.
5 | Here is the fourth non-empty line.
6 |
7 |
8 | Above are two empty lines.
9 |
10 | Empty lines again.
11 | Two lines together.
12 |
13 | This file ends in two newlines.
14 |
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/TextFileWithNoTrailingNewline.txt:
--------------------------------------------------------------------------------
1 | This text file has two lines of text
2 | and no trailing newline.
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/ZipHierarchy/Subdir1/Subdir2/Subdir3/TextFile2ForZip.txt:
--------------------------------------------------------------------------------
1 | This is the second text file for testing the ZipProcessor. There is nothing special about it.
2 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/ZipHierarchy/Subdir1/Subdir2/Subdir3/TextFile3ForZip.txt:
--------------------------------------------------------------------------------
1 | This is the third text file for testing the ZipProcessor. There is nothing special about it.
2 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/ZipHierarchy/Subdir1/Subdir2/TextFile1ForZip.txt:
--------------------------------------------------------------------------------
1 | This is the first text file for testing the ZipProcessor. There is nothing special about it.
2 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/TestFiles/beetle.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adv12/FileSharper/af5c5c4114addf9aacaefc0f7cbd9adce87efbd3/src/FileSharper/FileSharperCore.Tests/TestFiles/beetle.jpg
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/AllCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.Conditions
11 | {
12 | public class AllCondition : CompoundCondition
13 | {
14 |
15 | public override object Parameters { get; } = new object();
16 |
17 | public override string Name
18 | {
19 | get
20 | {
21 | return "All";
22 | }
23 | }
24 |
25 | public override string Description
26 | {
27 | get
28 | {
29 | return "Returns Yes if all of the specified conditions return Yes";
30 | }
31 | }
32 |
33 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
34 | {
35 | List values = new List();
36 | MatchResultType type = MatchResultType.Yes;
37 | foreach (ICondition c in Conditions)
38 | {
39 | token.ThrowIfCancellationRequested();
40 | MatchResult result = c.Matches(file, fileCaches, token);
41 | if (result.Values != null)
42 | {
43 | values.AddRange(result.Values);
44 | }
45 | if (result.Type != MatchResultType.Yes)
46 | {
47 | type = MatchResultType.No;
48 | // DO NOT short-circuit. We need all conditions to be evaluated for their ouptut values.
49 | }
50 | }
51 | return new MatchResult(type, values.ToArray());
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/AnyCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.Conditions
11 | {
12 | public class AnyCondition : CompoundCondition
13 | {
14 |
15 | public override object Parameters { get; } = new object();
16 |
17 | public override string Name => "Any";
18 |
19 | public override string Description => "Returns Yes if any of the specified conditions returns Yes";
20 |
21 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
22 | {
23 | List values = new List();
24 | MatchResultType type = MatchResultType.No;
25 | foreach (ICondition c in Conditions)
26 | {
27 | token.ThrowIfCancellationRequested();
28 | MatchResult result = c.Matches(file, fileCaches, token);
29 | if (result.Values != null)
30 | {
31 | values.AddRange(result.Values);
32 | }
33 | if (result.Type == MatchResultType.Yes)
34 | {
35 | type = MatchResultType.Yes;
36 | // DO NOT short-circuit. We need all conditions to be evaluated for their ouptut values.
37 | }
38 | }
39 | return new MatchResult(type, values.ToArray());
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Binary/BinaryDataContainsTextCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Text;
9 | using System.Threading;
10 | using FileSharperCore.Util;
11 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
12 |
13 | namespace FileSharperCore.Conditions.Binary
14 | {
15 | public class BinaryDataContainsTextParameters
16 | {
17 | [PropertyOrder(1, UsageContextEnum.Both)]
18 | public string Text { get; set; }
19 | [PropertyOrder(2, UsageContextEnum.Both)]
20 | public SearchTextEncodingType Encoding { get; set; } = SearchTextEncodingType.UTF8;
21 | }
22 |
23 | public class BinaryDataContainsTextCondition : BinaryDataSearchCondition
24 | {
25 | private BinaryDataContainsTextParameters m_Parameters = new BinaryDataContainsTextParameters();
26 |
27 | private byte[] m_bytes;
28 |
29 | protected override byte[] Bytes => m_bytes;
30 |
31 | public override int ColumnCount => 1;
32 |
33 | public override string[] ColumnHeaders => new string[] { "Binary Data Contains \"" + m_Parameters.Text + "\"" };
34 |
35 | public override string Category => "Binary";
36 |
37 | public override string Name => "Binary Data Contains Text";
38 |
39 | public override string Description => "Tests whether a binary file's data contains the specified text in the specified encoding";
40 |
41 | public override object Parameters => m_Parameters;
42 |
43 | public override void LocalInit()
44 | {
45 | base.LocalInit();
46 | Encoding encoding = TextUtil.GetSearchTextEncoding(m_Parameters.Encoding);
47 | m_bytes = encoding.GetBytes(m_Parameters.Text);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Binary/BinaryDataSearchCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.Conditions.Binary
11 | {
12 | public abstract class BinaryDataSearchCondition : ConditionBase
13 | {
14 | protected abstract byte[] Bytes { get; }
15 |
16 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
17 | {
18 | LinkedList currentBytes = new LinkedList();
19 | byte[] bytes = this.Bytes;
20 | using (FileStream stream = file.OpenRead())
21 | {
22 | int b;
23 | if (stream.Length < bytes.Length)
24 | {
25 | return new MatchResult(MatchResultType.No, "No");
26 | }
27 | for (int i = 0; i < bytes.Length - 1; i++)
28 | {
29 | currentBytes.AddLast((byte)stream.ReadByte());
30 | }
31 | while ((b = stream.ReadByte()) != -1)
32 | {
33 | currentBytes.AddLast((byte)b);
34 | bool match = true;
35 | int i = 0;
36 | foreach (byte cb in currentBytes)
37 | {
38 | if (bytes[i++] != cb)
39 | {
40 | match = false;
41 | break;
42 | }
43 | }
44 | if (match)
45 | {
46 | return new MatchResult(MatchResultType.Yes, "Yes");
47 | }
48 | currentBytes.RemoveFirst();
49 | }
50 | }
51 | return new MatchResult(MatchResultType.No, "No");
52 | }
53 |
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/ConditionBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.Conditions
11 | {
12 | public abstract class ConditionBase : PluggableItemWithColumnsAndCacheTypesBase, ICondition
13 | {
14 | public abstract MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Filesystem/FileLengthCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
11 |
12 | namespace FileSharperCore.Conditions.Filesystem
13 | {
14 |
15 | public class FileLengthComparisonParameters
16 | {
17 | [PropertyOrder(1, UsageContextEnum.Both)]
18 | public ComparisonType ComparisonType { get; set; } = ComparisonType.LessThan;
19 | [PropertyOrder(2, UsageContextEnum.Both)]
20 | public double Value { get; set; } = 1;
21 | [PropertyOrder(3, UsageContextEnum.Both)]
22 | public SizeUnits Units { get; set; } = SizeUnits.Kilobytes;
23 | [PropertyOrder(4, UsageContextEnum.Both)]
24 | public bool Metric { get; set; }
25 | [PropertyOrder(5, UsageContextEnum.Both)]
26 | public string Format { get; set; } = "F2";
27 | }
28 |
29 | public class FileLengthCondition : ConditionBase
30 | {
31 | private FileLengthComparisonParameters m_Parameters = new FileLengthComparisonParameters();
32 |
33 | public override string Name => "File Length";
34 |
35 | public override string Description => "File length compares to the specified length";
36 |
37 | public override string Category => "Filesystem";
38 |
39 | public override object Parameters => m_Parameters;
40 |
41 | public override int ColumnCount => 1;
42 |
43 | public override string[] ColumnHeaders => new string[] { "File Length (" + UnitUtil.GetUnitSymbol(m_Parameters.Units) + ")" };
44 |
45 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
46 | {
47 | double size = UnitUtil.ConvertSize(file.Length, SizeUnits.Bytes, m_Parameters.Units, m_Parameters.Metric);
48 | MatchResultType resultType = CompareUtil.Compare(size, m_Parameters.ComparisonType, m_Parameters.Value);
49 | return new MatchResult(resultType, new string[] { size.ToString(m_Parameters.Format) });
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Filesystem/ReadOnlyCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.Conditions.Filesystem
11 | {
12 | public class ReadOnlyCondition : ConditionBase
13 | {
14 | public override string Name => "Read-Only";
15 |
16 | public override string Description => "File is read-only";
17 |
18 | public override string Category => "Filesystem";
19 |
20 | public override object Parameters => null;
21 |
22 | public override int ColumnCount => 1;
23 |
24 | public override string[] ColumnHeaders => new string[] { "Read-Only" };
25 |
26 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
27 | {
28 | string output = file.IsReadOnly ? "Yes" : "No";
29 | string[] outputs = new string[] { output };
30 | if (file.IsReadOnly)
31 | {
32 | return new MatchResult(MatchResultType.Yes, outputs);
33 | }
34 | else
35 | {
36 | return new MatchResult(MatchResultType.No, outputs);
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Image/ImageDimensionCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Drawing;
8 | using System.IO;
9 | using System.Threading;
10 | using FileSharperCore.FileCaches;
11 | using FileSharperCore.Util;
12 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
13 |
14 | namespace FileSharperCore.Conditions.Image
15 | {
16 | public class ImageDimensionComparisonParameters
17 | {
18 | [PropertyOrder(1, UsageContextEnum.Both)]
19 | public MediaDimension Dimension { get; set; }
20 | [PropertyOrder(2, UsageContextEnum.Both)]
21 | public ComparisonType ComparisonType { get; set; }
22 | [PropertyOrder(3, UsageContextEnum.Both)]
23 | public int Size { get; set; }
24 | }
25 |
26 | public class ImageDimensionCondition : ConditionBase
27 | {
28 | private ImageDimensionComparisonParameters m_Parameters = new ImageDimensionComparisonParameters();
29 |
30 | public override int ColumnCount => 1;
31 |
32 | public override string[] ColumnHeaders => new string[] { m_Parameters.Dimension.ToString() };
33 |
34 | public override string Name => "Image Size";
35 |
36 | public override string Category => "Image";
37 |
38 | public override string Description => "Compares the width or height of an image to the specified value";
39 |
40 | public override object Parameters => m_Parameters;
41 |
42 | public override Type[] CacheTypes => new Type[] { typeof(BitmapFileCache) };
43 |
44 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
45 | {
46 | BitmapFileCache cache = fileCaches[typeof(BitmapFileCache)] as BitmapFileCache;
47 | if (cache == null || !cache.IsBitmap)
48 | {
49 | return new MatchResult(MatchResultType.NotApplicable, "N/A");
50 | }
51 | Bitmap bitmap = cache.Bitmap;
52 | int imageSize = m_Parameters.Dimension == MediaDimension.Height ? bitmap.Height : bitmap.Width;
53 | MatchResultType resultType = CompareUtil.Compare(imageSize, m_Parameters.ComparisonType, m_Parameters.Size);
54 | return new MatchResult(resultType, imageSize.ToString());
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/MatchEverythingCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.Conditions
11 | {
12 | public class MatchEverythingCondition : ConditionBase
13 | {
14 | public override string Name => null;
15 |
16 | public override string Description => null;
17 |
18 | public override string Category => string.Empty;
19 |
20 | public override object Parameters => null;
21 |
22 | public override int ColumnCount => 0;
23 |
24 | public override string[] ColumnHeaders => new string[0];
25 |
26 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
27 | {
28 | return new MatchResult(MatchResultType.Yes, new string[0]);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Text/LineCountCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 |
11 | namespace FileSharperCore.Conditions.Text
12 | {
13 | public class LineCountCondition : ConditionBase
14 | {
15 | private CountComparisonParameters m_Parameters = new CountComparisonParameters();
16 |
17 | public override string Name => "Line Count";
18 |
19 | public override string Category => "Text";
20 |
21 | public override string Description => "Compares the line count to the specified value";
22 |
23 | public override object Parameters => m_Parameters;
24 |
25 | public override int ColumnCount => 1;
26 |
27 | public override string[] ColumnHeaders => new string[] { "Line Count" };
28 |
29 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
30 | {
31 | int lineCount = 0;
32 | MatchResultType resultType = MatchResultType.NotApplicable;
33 | try
34 | {
35 | using (StreamReader reader = new StreamReader(file.FullName))
36 | {
37 | lineCount = TextUtil.GetLineCount(reader, token);
38 | }
39 | resultType = CompareUtil.Compare(lineCount, m_Parameters.ComparisonType, m_Parameters.Count);
40 | }
41 | catch (Exception ex)
42 | {
43 |
44 | }
45 | return new MatchResult(resultType, lineCount.ToString());
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Text/LineEndingsCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 |
11 | namespace FileSharperCore.Conditions.Text
12 | {
13 |
14 | public class LineEndingsParameters
15 | {
16 | public DetectedLineEndings LineEndings { get; set; }
17 | }
18 |
19 | public class LineEndingsCondition : ConditionBase
20 | {
21 |
22 | private LineEndingsParameters m_Parameters = new LineEndingsParameters();
23 |
24 | public override int ColumnCount => 1;
25 |
26 | public override string[] ColumnHeaders => new string[] { "Line Endings" };
27 |
28 | public override string Name => "Line Endings";
29 |
30 | public override string Category => "Text";
31 |
32 | public override string Description => "Tests whether the line endings match the specified value";
33 |
34 | public override object Parameters => m_Parameters;
35 |
36 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
37 | {
38 | MatchResultType resultType = MatchResultType.NotApplicable;
39 | DetectedLineEndings lineEndings = DetectedLineEndings.NotApplicable;
40 | try
41 | {
42 | using (StreamReader reader = new StreamReader(file.FullName))
43 | {
44 | lineEndings = TextUtil.GetLineEndings(reader, false, token);
45 | }
46 | if (lineEndings == m_Parameters.LineEndings)
47 | {
48 | resultType = MatchResultType.Yes;
49 | }
50 | else
51 | {
52 | resultType = MatchResultType.No;
53 | }
54 | }
55 | catch (Exception ex)
56 | {
57 |
58 | }
59 | return new MatchResult(resultType, lineEndings.ToString());
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Text/TextEncodingCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 |
11 | namespace FileSharperCore.Conditions.Text
12 | {
13 |
14 | public class TextEncodingTestParameters
15 | {
16 | public DetectedEncodingType Encoding { get; set; } = DetectedEncodingType.ASCII;
17 | }
18 |
19 | public class TextEncodingCondition : ConditionBase
20 | {
21 | private TextEncodingTestParameters m_Parameters = new TextEncodingTestParameters();
22 |
23 | public override int ColumnCount => 1;
24 |
25 | public override string[] ColumnHeaders => new string[] { "Encoding" };
26 |
27 | public override string Category => "Text";
28 |
29 | public override string Name => "Text Encoding Matches";
30 |
31 | public override string Description => null;
32 |
33 | public override object Parameters => m_Parameters;
34 |
35 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
36 | {
37 | MatchResultType resultType = MatchResultType.NotApplicable;
38 | string encodingString = "N/A";
39 | try
40 | {
41 | DetectedEncodingType encoding = TextUtil.GetDetectedEncodingType(file);
42 | if (encoding == m_Parameters.Encoding)
43 | {
44 | resultType = MatchResultType.Yes;
45 | }
46 | else
47 | {
48 | resultType = MatchResultType.No;
49 | }
50 | encodingString = encoding.ToString();
51 | }
52 | catch (Exception)
53 | {
54 |
55 | }
56 | return new MatchResult(resultType, encodingString);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Conditions/Text/WordCountCondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
11 |
12 | namespace FileSharperCore.Conditions.Text
13 | {
14 |
15 | public class CountComparisonParameters
16 | {
17 | [PropertyOrder(1, UsageContextEnum.Both)]
18 | public ComparisonType ComparisonType { get; set; } = ComparisonType.GreaterThan;
19 | [PropertyOrder(2, UsageContextEnum.Both)]
20 | public int Count { get; set; } = 300;
21 | }
22 |
23 | public class WordCountCondition : ConditionBase
24 | {
25 | private CountComparisonParameters m_Parameters = new CountComparisonParameters();
26 |
27 | public override string Name => "Word Count";
28 |
29 | public override string Category => "Text";
30 |
31 | public override string Description => "Compares the word count to the specified value";
32 |
33 | public override object Parameters => m_Parameters;
34 |
35 | public override int ColumnCount => 1;
36 |
37 | public override string[] ColumnHeaders => new string[] { "Word Count" };
38 |
39 | public override MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token)
40 | {
41 | int wordCount = 0;
42 | MatchResultType resultType = MatchResultType.NotApplicable;
43 | try
44 | {
45 | using (StreamReader reader = new StreamReader(file.FullName))
46 | {
47 | wordCount = TextUtil.GetWordCount(reader, token);
48 | }
49 | resultType = CompareUtil.Compare(wordCount, m_Parameters.ComparisonType, m_Parameters.Count);
50 | }
51 | catch (Exception ex)
52 | {
53 |
54 | }
55 | return new MatchResult(resultType, wordCount.ToString());
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Editors/DateTimePickerEditor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows;
6 | using System.Windows.Data;
7 | using Xceed.Wpf.Toolkit;
8 | using Xceed.Wpf.Toolkit.PropertyGrid;
9 | using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
10 |
11 | namespace FileSharperCore.Editors
12 | {
13 | public class DateTimePickerEditor : DateTimePicker, ITypeEditor
14 | {
15 | public DateTimePickerEditor()
16 | {
17 | Format = DateTimeFormat.Custom;
18 | FormatString = "yyyy/MM/dd hh:mm:ss tt";
19 |
20 | TimePickerVisibility = System.Windows.Visibility.Visible;
21 | ShowButtonSpinner = false;
22 | AutoCloseCalendar = true;
23 | }
24 |
25 | public FrameworkElement ResolveEditor(PropertyItem propertyItem)
26 | {
27 | Binding binding = new Binding("Value");
28 | binding.Source = propertyItem;
29 | binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
30 |
31 | BindingOperations.SetBinding(this, ValueProperty, binding);
32 | return this;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Editors/FileSharperMultiLineTextEditor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using Xceed.Wpf.Toolkit;
9 | using Xceed.Wpf.Toolkit.PropertyGrid;
10 | using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
11 |
12 | namespace FileSharperCore.Editors
13 | {
14 | public class FileSharperMultiLineTextEditor: MultiLineTextEditor, ITypeEditor
15 | {
16 | public string Value
17 | {
18 | get { return (string)GetValue(TextProperty); }
19 | set { SetValue(TextProperty, value); }
20 | }
21 |
22 | public FrameworkElement ResolveEditor(PropertyItem propertyItem)
23 | {
24 | Binding binding = new Binding("Value");
25 | binding.Source = propertyItem;
26 | binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
27 |
28 | BindingOperations.SetBinding(this, TextProperty, binding);
29 | return this;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Editors/FolderChooserEditor.xaml:
--------------------------------------------------------------------------------
1 |
6 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Editors/FolderChooserEditor.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using Ookii.Dialogs.Wpf;
9 | using Xceed.Wpf.Toolkit.PropertyGrid;
10 | using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
11 |
12 | namespace FileSharperCore.Editors
13 | {
14 | ///
15 | /// Interaction logic for OpenFileEditor.xaml
16 | ///
17 | public partial class FolderChooserEditor : UserControl, ITypeEditor
18 | {
19 | public string Value
20 | {
21 | get { return (string)GetValue(ValueProperty); }
22 | set { SetValue(ValueProperty, value); }
23 | }
24 |
25 | public FolderChooserEditor()
26 | {
27 | InitializeComponent();
28 | }
29 |
30 | // Using a DependencyProperty as the backing store for Value.This enables animation, styling, binding, etc...
31 | public static readonly DependencyProperty ValueProperty =
32 | DependencyProperty.Register("Value", typeof(string), typeof(FolderChooserEditor), new PropertyMetadata(null));
33 |
34 | public FrameworkElement ResolveEditor(PropertyItem propertyItem)
35 | {
36 | Binding binding = new Binding("Value");
37 | binding.Source = propertyItem;
38 | binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
39 | BindingOperations.SetBinding(this, ValueProperty, binding);
40 | return this;
41 | }
42 |
43 | private void chooseFolderButton_Click(object sender, RoutedEventArgs e)
44 | {
45 | VistaFolderBrowserDialog fd = new VistaFolderBrowserDialog();
46 | fd.SelectedPath = Value;
47 | if (fd.ShowDialog() == true)
48 | {
49 | Value = fd.SelectedPath;
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Editors/OpenFileEditor.xaml:
--------------------------------------------------------------------------------
1 |
6 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Editors/OpenFileEditor.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using Microsoft.Win32;
9 | using Xceed.Wpf.Toolkit.PropertyGrid;
10 | using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
11 |
12 | namespace FileSharperCore.Editors
13 | {
14 | ///
15 | /// Interaction logic for OpenFileEditor.xaml
16 | ///
17 | public partial class OpenFileEditor : UserControl, ITypeEditor
18 | {
19 | public string Value
20 | {
21 | get { return (string)GetValue(ValueProperty); }
22 | set { SetValue(ValueProperty, value); }
23 | }
24 |
25 | public OpenFileEditor()
26 | {
27 | InitializeComponent();
28 | }
29 |
30 | // Using a DependencyProperty as the backing store for Value.This enables animation, styling, binding, etc...
31 | public static readonly DependencyProperty ValueProperty =
32 | DependencyProperty.Register("Value", typeof(string), typeof(OpenFileEditor), new PropertyMetadata(null));
33 |
34 | public FrameworkElement ResolveEditor(PropertyItem propertyItem)
35 | {
36 | Binding binding = new Binding("Value");
37 | binding.Source = propertyItem;
38 | binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
39 | BindingOperations.SetBinding(this, ValueProperty, binding);
40 | return this;
41 | }
42 |
43 | private void chooseFileButton_Click(object sender, RoutedEventArgs e)
44 | {
45 | OpenFileDialog fd = new OpenFileDialog();
46 | fd.FileName = Value;
47 | if (fd.ShowDialog() == true && fd.CheckFileExists)
48 | {
49 | Value = fd.FileName;
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Editors/SaveFileEditor.xaml:
--------------------------------------------------------------------------------
1 |
6 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Editors/SaveFileEditor.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using Microsoft.Win32;
9 | using Xceed.Wpf.Toolkit.PropertyGrid;
10 | using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
11 |
12 | namespace FileSharperCore.Editors
13 | {
14 | ///
15 | /// Interaction logic for SaveFileEditor.xaml
16 | ///
17 | public partial class SaveFileEditor : UserControl, ITypeEditor
18 | {
19 | public string Value
20 | {
21 | get { return (string)GetValue(ValueProperty); }
22 | set { SetValue(ValueProperty, value); }
23 | }
24 |
25 | public SaveFileEditor()
26 | {
27 | InitializeComponent();
28 | }
29 |
30 | // Using a DependencyProperty as the backing store for Value.This enables animation, styling, binding, etc...
31 | public static readonly DependencyProperty ValueProperty =
32 | DependencyProperty.Register("Value", typeof(string), typeof(SaveFileEditor), new PropertyMetadata(null));
33 |
34 | public FrameworkElement ResolveEditor(PropertyItem propertyItem)
35 | {
36 | Binding binding = new Binding("Value");
37 | binding.Source = propertyItem;
38 | binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
39 | BindingOperations.SetBinding(this, ValueProperty, binding);
40 | return this;
41 | }
42 |
43 | private void chooseFileButton_Click(object sender, RoutedEventArgs e)
44 | {
45 | SaveFileDialog fd = new SaveFileDialog();
46 | fd.FileName = Value;
47 | if (fd.ShowDialog() == true)
48 | {
49 | Value = fd.FileName;
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/ExceptionInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.IO;
7 |
8 | namespace FileSharperCore
9 | {
10 | public class ExceptionInfo
11 | {
12 | public Exception Exception { get; set; }
13 | public FileInfo File { get; set; }
14 |
15 | public ExceptionInfo(Exception exception, FileInfo file = null)
16 | {
17 | Exception = exception;
18 | File = file;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FieldSources/FieldSourceBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.FieldSources
11 | {
12 | public abstract class FieldSourceBase : PluggableItemWithColumnsAndCacheTypesBase, IFieldSource
13 | {
14 | public abstract string[] GetValues(FileInfo file, Dictionary fileCaches, CancellationToken token);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FieldSources/Filesystem/FileLengthFieldSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
11 |
12 | namespace FileSharperCore.FieldSources.Filesystem
13 | {
14 | public class FileLengthParameters
15 | {
16 | [PropertyOrder(1, UsageContextEnum.Both)]
17 | public SizeUnits Units { get; set; } = SizeUnits.Kilobytes;
18 | [PropertyOrder(2, UsageContextEnum.Both)]
19 | public bool Metric { get; set; }
20 | [PropertyOrder(3, UsageContextEnum.Both)]
21 | public string Format { get; set; } = "F2";
22 | }
23 |
24 | public class FileLengthFieldSource : FieldSourceBase
25 | {
26 | private FileLengthParameters m_Parameters = new FileLengthParameters();
27 |
28 | public override int ColumnCount => 1;
29 |
30 | public override string[] ColumnHeaders => new string[] { "File Length (" + UnitUtil.GetUnitSymbol(m_Parameters.Units) + ")" };
31 |
32 | public override string Name => "File Length";
33 |
34 | public override string Description => "The length of the file in the specified units";
35 |
36 | public override string Category => "Filesystem";
37 |
38 | public override object Parameters => m_Parameters;
39 |
40 | public override string[] GetValues(FileInfo file, Dictionary cacheTypes, CancellationToken token)
41 | {
42 | return new string[] { UnitUtil.ConvertSize(file.Length, SizeUnits.Bytes, m_Parameters.Units, m_Parameters.Metric).ToString(m_Parameters.Format) };
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FieldSources/Filesystem/ReadOnlyFieldSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.FieldSources.Filesystem
11 | {
12 | public class ReadOnlyFieldSource : FieldSourceBase
13 | {
14 | public override int ColumnCount => 1;
15 |
16 | public override string[] ColumnHeaders => new string[] { "Read-Only" };
17 |
18 | public override string Name => "Read-Only";
19 |
20 | public override string Description => "Whether the file is read-only";
21 |
22 | public override string Category => "Filesystem";
23 |
24 | public override object Parameters => null;
25 |
26 | public override string[] GetValues(FileInfo file, Dictionary cacheTypes, CancellationToken token)
27 | {
28 | string field = file.IsReadOnly ? "Yes" : "No";
29 | string[] fields = new string[] { field };
30 | return fields;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FieldSources/NothingFieldSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading;
11 | using System.Threading.Tasks;
12 |
13 | namespace FileSharperCore.FieldSources
14 | {
15 | public class NothignFieldSource : FieldSourceBase
16 | {
17 | public override int ColumnCount => 0;
18 |
19 | public override string[] ColumnHeaders => new string[0];
20 |
21 | public override string Name => null;
22 |
23 | public override string Category => string.Empty;
24 |
25 | public override string Description => null;
26 |
27 | public override object Parameters => null;
28 |
29 | public override string[] GetValues(FileInfo file, Dictionary cacheTypes, CancellationToken token)
30 | {
31 | return new string[0];
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FieldSources/Text/LineCountFieldSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 |
11 | namespace FileSharperCore.FieldSources.Text
12 | {
13 | public class LineCountFieldSource : FieldSourceBase
14 | {
15 | public override int ColumnCount => 1;
16 |
17 | public override string[] ColumnHeaders => new string[] { "Line Count" };
18 |
19 | public override string Name => "Line Count";
20 |
21 | public override string Description => "The number of lines in the text file";
22 |
23 | public override string Category => "Text";
24 |
25 | public override object Parameters => null;
26 |
27 | public override string[] GetValues(FileInfo file, Dictionary fileCaches, CancellationToken token)
28 | {
29 | int lineCount = 0;
30 | string value = "N/A";
31 | try
32 | {
33 | using (StreamReader reader = new StreamReader(file.FullName))
34 | {
35 | lineCount = TextUtil.GetLineCount(reader, token);
36 | }
37 | value = lineCount.ToString();
38 | }
39 | catch (Exception ex)
40 | {
41 |
42 | }
43 | return new string[] { value };
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FieldSources/Text/LineEndingsFieldSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 |
11 | namespace FileSharperCore.FieldSources.Text
12 | {
13 | public class LineEndingsFieldSource : FieldSourceBase
14 | {
15 | public override int ColumnCount => 1;
16 |
17 | public override string[] ColumnHeaders => new string[] { "Line Endings" };
18 |
19 | public override string Name => "Line Endings";
20 |
21 | public override string Category => "Text";
22 |
23 | public override string Description => "The type of line endings used in the text file";
24 |
25 | public override object Parameters => null;
26 |
27 | public override string[] GetValues(FileInfo file, Dictionary fileCaches, CancellationToken token)
28 | {
29 | DetectedLineEndings lineEndings = DetectedLineEndings.NotApplicable;
30 | string value = "N/A";
31 | try
32 | {
33 | using (StreamReader reader = new StreamReader(file.FullName))
34 | {
35 | lineEndings = TextUtil.GetLineEndings(reader, false, token);
36 | }
37 | value = lineEndings.ToString();
38 | }
39 | catch (Exception ex)
40 | {
41 |
42 | }
43 | return new string[] { value };
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FieldSources/Text/TextEncodingFieldSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 |
11 | namespace FileSharperCore.FieldSources.Text
12 | {
13 | public class TextEncodingFieldSource : FieldSourceBase
14 | {
15 | public override int ColumnCount => 1;
16 |
17 | public override string[] ColumnHeaders => new string[] { "Encoding" };
18 |
19 | public override string Category => "Text";
20 |
21 | public override string Name => "Text Encoding";
22 |
23 | public override string Description => null;
24 |
25 | public override object Parameters => null;
26 |
27 | public override string[] GetValues(FileInfo file, Dictionary fileCaches, CancellationToken token)
28 | {
29 | string encoding = "N/A";
30 | try
31 | {
32 | encoding = TextUtil.GetDetectedEncodingType(file).ToString();
33 | }
34 | catch (Exception)
35 | {
36 |
37 | }
38 | return new string[] { encoding };
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FieldSources/Text/WordCountFieldSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using FileSharperCore.Util;
10 |
11 | namespace FileSharperCore.FieldSources.Text
12 | {
13 | public class WordCountFieldSource : FieldSourceBase
14 | {
15 | public override int ColumnCount => 1;
16 |
17 | public override string[] ColumnHeaders => new string[] { "Word Count" };
18 |
19 | public override string Name => "Word Count";
20 |
21 | public override string Category => "Text";
22 |
23 | public override string Description => "The number of words in the text file";
24 |
25 | public override object Parameters => null;
26 |
27 | public override string[] GetValues(FileInfo file, Dictionary fileCaches, CancellationToken token)
28 | {
29 | int wordCount = 0;
30 | string value = "N/A";
31 | try
32 | {
33 | using (StreamReader reader = new StreamReader(file.FullName))
34 | {
35 | wordCount = TextUtil.GetWordCount(reader, token);
36 | }
37 | value = wordCount.ToString();
38 | }
39 | catch (Exception ex)
40 | {
41 |
42 | }
43 | return new string[] { value };
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FileCaches/BitmapFileCache.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Drawing;
7 | using System.IO;
8 |
9 | namespace FileSharperCore.FileCaches
10 | {
11 | public class BitmapFileCache : IFileCache
12 | {
13 | public Bitmap Bitmap
14 | {
15 | get;
16 | private set;
17 | }
18 |
19 | public bool IsBitmap
20 | {
21 | get;
22 | private set;
23 | }
24 |
25 | public void Load(FileInfo file)
26 | {
27 | try
28 | {
29 | Bitmap = new Bitmap(file.FullName);
30 | IsBitmap = true;
31 | }
32 | catch (Exception)
33 | {
34 |
35 | }
36 | }
37 |
38 | public void Dispose()
39 | {
40 | Bitmap?.Dispose();
41 | Bitmap = null;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FileProgressInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.IO;
6 |
7 | namespace FileSharperCore
8 | {
9 | public class FileProgressInfo
10 | {
11 | public FileInfo File;
12 | public MatchResultType ResultType;
13 | public string[] Values;
14 | public FileProgressInfo(FileInfo file, MatchResultType resultType, string[] values)
15 | {
16 | File = file;
17 | ResultType = resultType;
18 | Values = values;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FileSources/FileSourceBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Collections.Generic;
6 | using System.IO;
7 |
8 | namespace FileSharperCore.FileSources
9 | {
10 | public abstract class FileSourceBase : PluggableItemBase, IFileSource
11 | {
12 | public abstract IEnumerable Files
13 | {
14 | get;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FileSources/ListFileSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using FileSharperCore.Util;
9 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
10 |
11 | namespace FileSharperCore.FileSources
12 | {
13 | public class FileListParameters
14 | {
15 | [PropertyOrder(1, UsageContextEnum.Both)]
16 | public List Files { get; set; } = new List();
17 | }
18 |
19 | public class ListFileSource : FileSourceBase
20 | {
21 | private FileListParameters m_Parameters = new FileListParameters();
22 |
23 | public override IEnumerable Files
24 | {
25 | get
26 | {
27 | foreach (string filename in m_Parameters.Files)
28 | {
29 | if (RunInfo.StopRequested)
30 | {
31 | yield break;
32 | }
33 | RunInfo.CancellationToken.ThrowIfCancellationRequested();
34 | string name = filename;
35 | name = ReplaceUtil.Replace(name, (FileInfo)null);
36 | FileInfo fi = null;
37 | try
38 | {
39 | fi = new FileInfo(name);
40 | }
41 | catch (Exception ex)
42 | {
43 | RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex));
44 | }
45 | if (fi != null)
46 | {
47 | yield return fi;
48 | }
49 | }
50 | }
51 | }
52 |
53 | public override string Name => "List of Paths";
54 |
55 | public override string Category => "Miscellaneous";
56 |
57 | public override string Description => "A list of file paths";
58 |
59 | public override object Parameters => m_Parameters;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/FileSources/TempFileWithTextFileSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel;
8 | using System.IO;
9 | using FileSharperCore.Editors;
10 |
11 | namespace FileSharperCore.FileSources
12 | {
13 | public class TempFileWithTextParameters
14 | {
15 | [Editor(typeof(FileSharperMultiLineTextEditor), typeof(FileSharperMultiLineTextEditor))]
16 | public string TempFileText { get; set; } = string.Empty;
17 | }
18 |
19 | public class TempFileWithTextFileSource : FileSourceBase
20 | {
21 | private TempFileWithTextParameters m_Parameters = new TempFileWithTextParameters();
22 | private string m_TempFilePath;
23 |
24 | public override string Category => "Miscellaneous";
25 |
26 | public override string Name => "Single Temp File With Text";
27 |
28 | public override string Description => "Creates a temp file with the specified text as its content and returns that file.";
29 |
30 | public override object Parameters => m_Parameters;
31 |
32 | public override void LocalInit()
33 | {
34 | base.LocalInit();
35 | m_TempFilePath = Path.GetTempFileName();
36 | File.WriteAllText(m_TempFilePath, m_Parameters.TempFileText);
37 | }
38 |
39 | public override IEnumerable Files
40 | {
41 | get
42 | {
43 | yield return new FileInfo(m_TempFilePath);
44 | }
45 | }
46 |
47 | public override void LocalCleanup()
48 | {
49 | File.Delete(m_TempFilePath);
50 | base.LocalCleanup();
51 | }
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/ICondition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Threading;
6 | using System.IO;
7 | using System;
8 | using System.Collections.Generic;
9 |
10 | namespace FileSharperCore
11 | {
12 | public interface ICondition : IPluggableItemWithColumnsAndCacheTypes
13 | {
14 | MatchResult Matches(FileInfo file, Dictionary fileCaches, CancellationToken token);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/IFieldSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore
11 | {
12 | public interface IFieldSource: IPluggableItemWithColumnsAndCacheTypes
13 | {
14 | string[] GetValues(FileInfo file, Dictionary fileCaches, CancellationToken token);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/IFileCache.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.IO;
7 |
8 | namespace FileSharperCore
9 | {
10 | public interface IFileCache : IDisposable
11 | {
12 | void Load(FileInfo file);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/IFileSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Collections.Generic;
6 | using System.IO;
7 |
8 | namespace FileSharperCore
9 | {
10 | public interface IFileSource : IPluggableItem
11 | {
12 | IEnumerable Files
13 | {
14 | get;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/IPluggableItem.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | namespace FileSharperCore
6 | {
7 | public interface IPluggableItem
8 | {
9 | object Parameters
10 | {
11 | get;
12 | }
13 |
14 | string Category
15 | {
16 | get;
17 | }
18 |
19 | string Name
20 | {
21 | get;
22 | }
23 |
24 | string Description
25 | {
26 | get;
27 | }
28 |
29 | void Init(IRunInfo inf);
30 |
31 | void Cleanup();
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/IPluggableItemWithColumns.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | namespace FileSharperCore
6 | {
7 | public interface IPluggableItemWithColumns : IPluggableItem
8 | {
9 | int ColumnCount
10 | {
11 | get;
12 | }
13 |
14 | string[] ColumnHeaders
15 | {
16 | get;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/IPluggableItemWithColumnsAndCacheTypes.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 |
7 | namespace FileSharperCore
8 | {
9 | public interface IPluggableItemWithColumnsAndCacheTypes: IPluggableItemWithColumns
10 | {
11 | Type[] CacheTypes { get; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/IProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Concurrent;
7 | using System.Collections.Generic;
8 | using System.IO;
9 | using System.Threading;
10 |
11 | namespace FileSharperCore
12 | {
13 | public interface IProcessor: IPluggableItem
14 | {
15 | InputFileSource InputFileSource { get; set; }
16 | ProcessingResult Process(FileInfo originalFile, MatchResultType matchResultType, string[] values,
17 | FileInfo[] generatedFiles, ProcessInput whatToProcess, CancellationToken token);
18 | void ProcessAggregated(CancellationToken token);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/IRunInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Concurrent;
7 | using System.Collections.Generic;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore
11 | {
12 | public interface IRunInfo
13 | {
14 | IFileSource FileSource { get; }
15 |
16 | ICondition Condition
17 | {
18 | get;
19 | }
20 |
21 | IFieldSource[] FieldSources
22 | {
23 | get;
24 | }
25 |
26 | IProcessor[] TestedProcessors
27 | {
28 | get;
29 | }
30 |
31 | IProcessor[] MatchedProcessors
32 | {
33 | get;
34 | }
35 |
36 | int MaxToMatch
37 | {
38 | get;
39 | }
40 |
41 | CancellationToken CancellationToken
42 | {
43 | get;
44 | }
45 |
46 | IProgress FileSourceProgress
47 | {
48 | get;
49 | }
50 |
51 | ConcurrentQueue TestedFileProgressInfos
52 | {
53 | get;
54 | }
55 |
56 | ConcurrentQueue MatchedFileProgressInfos
57 | {
58 | get;
59 | }
60 |
61 | ConcurrentQueue ExceptionInfos
62 | {
63 | get;
64 | }
65 |
66 | IProgress> TestedProgress
67 | {
68 | get;
69 | }
70 |
71 | IProgress> MatchedProgress
72 | {
73 | get;
74 | }
75 |
76 | IProgress> ExceptionProgress
77 | {
78 | get;
79 | }
80 |
81 | IProgress CompleteProgress
82 | {
83 | get;
84 | }
85 |
86 | bool StopRequested
87 | {
88 | get;
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/MatchResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | namespace FileSharperCore
6 | {
7 | public class MatchResult
8 | {
9 |
10 | public MatchResultType Type
11 | {
12 | get;
13 | private set;
14 | }
15 |
16 | public string[] Values
17 | {
18 | get;
19 | private set;
20 | }
21 |
22 | public MatchResult(MatchResultType type, params string[] values)
23 | {
24 | Type = type;
25 | Values = values;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/PluggableItemBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Threading;
8 | using System.Reflection;
9 |
10 | namespace FileSharperCore
11 | {
12 | public abstract class PluggableItemBase : MarshalByRefObject, IPluggableItem
13 | {
14 |
15 | protected IRunInfo RunInfo
16 | {
17 | get;
18 | private set;
19 | }
20 |
21 | protected CancellationToken CancellationToken
22 | {
23 | get => RunInfo.CancellationToken;
24 | }
25 |
26 | protected IProgress> ExceptionProgress
27 | {
28 | get => RunInfo.ExceptionProgress;
29 | }
30 |
31 | public abstract string Category
32 | {
33 | get;
34 | }
35 |
36 | public abstract string Name
37 | {
38 | get;
39 | }
40 |
41 | public abstract string Description
42 | {
43 | get;
44 | }
45 |
46 | public abstract object Parameters
47 | {
48 | get;
49 | }
50 |
51 | public void Init(IRunInfo inf)
52 | {
53 | RunInfo = inf;
54 | LocalInit();
55 | }
56 |
57 | public virtual void LocalInit()
58 | {
59 |
60 | }
61 |
62 | public void SetParameter(string name, object value)
63 | {
64 | object parameters = Parameters;
65 | Type t = parameters.GetType();
66 | PropertyInfo property = t.GetProperty(name);
67 | property.SetValue(parameters, value);
68 | }
69 |
70 | public object GetParameter(string name)
71 | {
72 | object parameters = Parameters;
73 | Type t = parameters.GetType();
74 | PropertyInfo property = t.GetProperty(name);
75 | return property.GetValue(parameters);
76 | }
77 |
78 | public void Cleanup()
79 | {
80 | LocalCleanup();
81 | RunInfo = null;
82 | }
83 |
84 | public virtual void LocalCleanup()
85 | {
86 |
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/PluggableItemWithColumnsAndCacheTypesBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 |
7 | namespace FileSharperCore
8 | {
9 | public abstract class PluggableItemWithColumnsAndCacheTypesBase : PluggableItemWithColumnsBase, IPluggableItemWithColumnsAndCacheTypes
10 | {
11 | public virtual Type[] CacheTypes => new Type[0];
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/PluggableItemWithColumnsBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | namespace FileSharperCore
6 | {
7 | public abstract class PluggableItemWithColumnsBase : PluggableItemBase, IPluggableItemWithColumns
8 | {
9 | public abstract int ColumnCount
10 | {
11 | get;
12 | }
13 |
14 | public abstract string[] ColumnHeaders
15 | {
16 | get;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/ProcessingResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.IO;
6 |
7 | namespace FileSharperCore
8 | {
9 | public class ProcessingResult
10 | {
11 |
12 | public ProcessingResultType Type
13 | {
14 | get;
15 | private set;
16 | }
17 |
18 | public string Message
19 | {
20 | get;
21 | private set;
22 | }
23 |
24 | public FileInfo[] OutputFiles
25 | {
26 | get;
27 | private set;
28 | }
29 |
30 | public ProcessingResult(ProcessingResultType type, string message, FileInfo[] outputFiles)
31 | {
32 | Type = type;
33 | Message = message;
34 | OutputFiles = outputFiles ?? throw new System.ArgumentNullException(nameof(outputFiles),
35 | "outputFiles must not be null");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/CommandLineProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.IO;
7 | using System.Threading;
8 | using System.Diagnostics;
9 | using FileSharperCore.Util;
10 |
11 | namespace FileSharperCore.Processors
12 | {
13 |
14 | public class CommandLineParameters
15 | {
16 | public string CommandLine { get; set; } = "echo \"{FullName}\"";
17 | public bool WaitForTaskToFinish { get; set; } = false;
18 | }
19 |
20 | public class CommandLineProcessor : SingleFileProcessorBase
21 | {
22 | private CommandLineParameters m_Parameters = new CommandLineParameters();
23 |
24 | public override string Name => "Execute command line";
25 |
26 | public override string Category => "Miscellaneous";
27 |
28 | public override string Description => "Executes the specified command line";
29 |
30 | public override object Parameters => m_Parameters;
31 |
32 | protected internal override ProcessingResult Process(FileInfo file, string[] values,
33 | CancellationToken token)
34 | {
35 | try
36 | {
37 | string comandLine = ReplaceUtil.Replace(m_Parameters.CommandLine, file);
38 | Process process = System.Diagnostics.Process.Start("cmd", "/c " + comandLine);
39 | if (m_Parameters.WaitForTaskToFinish)
40 | {
41 | process.WaitForExit();
42 | }
43 | }
44 | catch (Exception ex)
45 | {
46 | RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex, file));
47 | return new ProcessingResult(ProcessingResultType.Failure, ex.Message, new FileInfo[] { file });
48 | }
49 | return new ProcessingResult(ProcessingResultType.Success, "Success", new FileInfo[] { file });
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/DoNothingProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.IO;
6 | using System.Threading;
7 |
8 | namespace FileSharperCore.Processors
9 | {
10 | public class DoNothingProcessor : ProcessorBase
11 | {
12 | public override string Name => null;
13 |
14 | public override string Category => string.Empty;
15 |
16 | public override string Description => null;
17 |
18 | public override object Parameters => null;
19 |
20 | public override ProcessingResult Process(FileInfo file,
21 | MatchResultType matchResultType, string[] values,
22 | FileInfo[] generatedFiles, ProcessInput whatToProcess,
23 | CancellationToken token)
24 | {
25 | return new ProcessingResult(ProcessingResultType.Success, "Success", new FileInfo[] { file });
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/Filesystem/CopyFileProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.IO;
7 | using System.Threading;
8 | using FileSharperCore.Util;
9 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
10 |
11 | namespace FileSharperCore.Processors.Filesystem
12 | {
13 | public class CopyFileParameters
14 | {
15 | [PropertyOrder(1, UsageContextEnum.Both)]
16 | public string NewPath { get; set; } = @"{Desktop}\{Name}";
17 | [PropertyOrder(2, UsageContextEnum.Both)]
18 | public bool Overwrite { get; set; } = false;
19 | }
20 |
21 | public class CopyFileProcessor : SingleFileProcessorBase
22 | {
23 | private CopyFileParameters m_Parameters = new CopyFileParameters();
24 |
25 | public override string Name => "Copy file";
26 |
27 | public override string Category => "Filesystem";
28 |
29 | public override string Description => "Copy file to the specified location";
30 |
31 | public override object Parameters => m_Parameters;
32 |
33 | protected internal override ProcessingResult Process(FileInfo file, string[] values,
34 | CancellationToken token)
35 | {
36 | string newPath = ReplaceUtil.Replace(m_Parameters.NewPath, file);
37 | string message = "Success";
38 | FileInfo result = null;
39 | try
40 | {
41 | string dirPath = Path.GetDirectoryName(newPath);
42 | Directory.CreateDirectory(dirPath);
43 | if (m_Parameters.Overwrite || !File.Exists(newPath))
44 | {
45 | result = file.CopyTo(newPath, m_Parameters.Overwrite);
46 | }
47 | }
48 | catch (Exception ex)
49 | {
50 | RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex, file));
51 | message = ex.Message;
52 | }
53 | if (result == null)
54 | {
55 | return new ProcessingResult(ProcessingResultType.Failure, message ?? "Failure", new FileInfo[0]);
56 | }
57 | return new ProcessingResult(ProcessingResultType.Success, "Success", new FileInfo[] { new FileInfo(newPath) });
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/Filesystem/CreateDirectoryProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.IO;
7 | using System.Threading;
8 | using FileSharperCore.Util;
9 |
10 | namespace FileSharperCore.Processors.Filesystem
11 | {
12 | public class CreateDirectoryParameters
13 | {
14 | public string DirectoryPath { get; set; } = @"{DirectoryName}\NewSubdirectory";
15 | }
16 |
17 | public class CreateDirectoryProcessor : SingleFileProcessorBase
18 | {
19 | private CreateDirectoryParameters m_Parameters = new CreateDirectoryParameters();
20 |
21 | public override string Category => "Filesystem";
22 |
23 | public override string Name => "Create directory";
24 |
25 | public override string Description => "Create a directory if it does not exist";
26 |
27 | public override object Parameters => m_Parameters;
28 |
29 | protected internal override ProcessingResult Process(FileInfo file, string[] values, CancellationToken token)
30 | {
31 | string directoryPath = ReplaceUtil.Replace(m_Parameters.DirectoryPath, file);
32 | ProcessingResultType resultType = ProcessingResultType.Failure;
33 | string message = "Failed to create directory";
34 | try
35 | {
36 | if (Directory.Exists(directoryPath))
37 | {
38 | resultType = ProcessingResultType.Success;
39 | message = "Directory already exists";
40 | }
41 | else if (!File.Exists(directoryPath))
42 | {
43 | Directory.CreateDirectory(directoryPath);
44 | resultType = ProcessingResultType.Success;
45 | message = "Directory created";
46 | }
47 | }
48 | catch (Exception ex)
49 | {
50 | RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex, file));
51 | message = ex.Message;
52 | }
53 | return new ProcessingResult(resultType, message, new FileInfo[0]);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/Filesystem/FileDateProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.IO;
7 | using System.Threading;
8 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
9 |
10 | namespace FileSharperCore.Processors.Filesystem
11 | {
12 | public class FileDateProcessorParameters
13 | {
14 | [PropertyOrder(1, UsageContextEnum.Both)]
15 | public FileDateType FileDateType { get; set; } = FileDateType.Modified;
16 | [PropertyOrder(2, UsageContextEnum.Both)]
17 | public DateTime Date { get; set; } = DateTime.Now;
18 | }
19 |
20 | public class FileDateProcessor : SingleFileProcessorBase
21 | {
22 | private FileDateProcessorParameters m_Parameters = new FileDateProcessorParameters();
23 |
24 | public override string Name => "Set file date";
25 |
26 | public override string Category => "Filesystem";
27 |
28 | public override string Description => "Sets the specified file date property to the specified date";
29 |
30 | public override object Parameters => m_Parameters;
31 |
32 | protected internal override ProcessingResult Process(FileInfo file, string[] values,
33 | CancellationToken token)
34 | {
35 | try
36 | {
37 | switch (m_Parameters.FileDateType)
38 | {
39 | case FileDateType.Accessed:
40 | File.SetLastAccessTime(file.FullName, m_Parameters.Date);
41 | break;
42 | case FileDateType.Created:
43 | File.SetCreationTime(file.FullName, m_Parameters.Date);
44 | break;
45 | case FileDateType.Modified:
46 | File.SetLastWriteTime(file.FullName, m_Parameters.Date);
47 | break;
48 | }
49 | }
50 | catch (Exception ex)
51 | {
52 | RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex, file));
53 | return new ProcessingResult(ProcessingResultType.Failure, ex.Message, new FileInfo[0]);
54 | }
55 | return new ProcessingResult(ProcessingResultType.Success, "Success", new FileInfo[] { file });
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/Filesystem/RecycleProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 | using Microsoft.VisualBasic.FileIO;
10 |
11 | namespace FileSharperCore.Processors.Filesystem
12 | {
13 | public class RecycleProcessor : SingleFileProcessorBase
14 | {
15 | public override string Name => "Move to Recycle Bin";
16 |
17 | public override string Category => "Filesystem";
18 |
19 | public override string Description => "Move the file to the Recycle Bin";
20 |
21 | public override object Parameters => null;
22 |
23 | protected internal override ProcessingResult Process(FileInfo file, string[] values,
24 | CancellationToken token)
25 | {
26 | try
27 | {
28 | FileSystem.DeleteFile(file.FullName, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin,
29 | UICancelOption.DoNothing);
30 | }
31 | catch (Exception ex)
32 | {
33 | RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex, file));
34 | return new ProcessingResult(ProcessingResultType.Failure, ex.Message, new FileInfo[0]);
35 | }
36 | return new ProcessingResult(ProcessingResultType.Success, "Success", new FileInfo[0]);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/Shell/OpenContainingFolderProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.Processors.Shell
11 | {
12 | public class OpenContainingFolderProcessor : SingleFileProcessorBase
13 | {
14 | private HashSet m_OpenedFolders = new HashSet();
15 |
16 | public override string Name => "Open containing folder";
17 |
18 | public override string Category => "Shell";
19 |
20 | public override string Description => "Opens the folder containing the file";
21 |
22 | public override object Parameters => null;
23 |
24 | public override void LocalInit()
25 | {
26 | m_OpenedFolders.Clear();
27 | }
28 |
29 | protected internal override ProcessingResult Process(FileInfo file, string[] values,
30 | CancellationToken token)
31 | {
32 | ProcessingResultType type = ProcessingResultType.Failure;
33 | string message = "Success";
34 | if (!m_OpenedFolders.Contains(file.DirectoryName))
35 | {
36 | try
37 | {
38 | System.Diagnostics.Process.Start(file.DirectoryName);
39 | m_OpenedFolders.Add(file.DirectoryName);
40 | type = ProcessingResultType.Success;
41 | }
42 | catch (Exception ex)
43 | {
44 | message = ex.Message;
45 | RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex, file));
46 | }
47 | }
48 | return new ProcessingResult(type, message, new FileInfo[] { file });
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/Shell/OpenFileProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Threading;
9 |
10 | namespace FileSharperCore.Processors.Shell
11 | {
12 | public class OpenFileProcessor: SingleFileProcessorBase
13 | {
14 | public override string Name => "Open file";
15 |
16 | public override string Category => "Shell";
17 |
18 | public override string Description => "Opens the file in its default editor";
19 |
20 | public override object Parameters => null;
21 |
22 | protected internal override ProcessingResult Process(FileInfo file, string[] values,
23 | CancellationToken token)
24 | {
25 | ProcessingResultType type = ProcessingResultType.Failure;
26 | string message = "Success";
27 | try
28 | {
29 | System.Diagnostics.Process.Start(file.FullName);
30 | type = ProcessingResultType.Success;
31 | }
32 | catch (Exception ex)
33 | {
34 | message = ex.Message;
35 | RunInfo.ExceptionInfos.Enqueue(new ExceptionInfo(ex, file));
36 | }
37 | return new ProcessingResult(type, message, new FileInfo[] { file });
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/Text/ChangeCaseProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
6 |
7 | namespace FileSharperCore.Processors.Text
8 | {
9 |
10 | public class ChangeCaseParameters
11 | {
12 | [PropertyOrder(1, UsageContextEnum.Both)]
13 | public TextCase Case { get; set; }
14 | [PropertyOrder(2, UsageContextEnum.Both)]
15 | public LineEndings LineEndings { get; set; } = LineEndings.MatchInput;
16 | [PropertyOrder(3, UsageContextEnum.Both)]
17 | public OutputEncodingType OutputEncoding { get; set; } = OutputEncodingType.MatchInput;
18 | [PropertyOrder(4, UsageContextEnum.Both)]
19 | public string FileName { get; set; } = ProcessorBase.ORIGINAL_FILE_PATH;
20 | [PropertyOrder(5, UsageContextEnum.Both)]
21 | public bool OverwriteExistingFile { get; set; } = true;
22 | [PropertyOrder(6, UsageContextEnum.Both)]
23 | public bool MoveOriginalToRecycleBin { get; set; }
24 | }
25 |
26 | public class ChangeCaseProcessor : LineProcessor
27 | {
28 | private ChangeCaseParameters m_Parameters = new ChangeCaseParameters();
29 |
30 | public override string Name => "Convert case";
31 |
32 | public override string Category => "Text";
33 |
34 | public override string Description => "Changes the text to upper- or lowercase";
35 |
36 | public override object Parameters => m_Parameters;
37 |
38 | protected internal override bool MoveOriginalToRecycleBin => m_Parameters.MoveOriginalToRecycleBin;
39 |
40 | protected internal override LineEndings LineEndings => m_Parameters.LineEndings;
41 |
42 | protected internal override OutputEncodingType OutputEncodingType => m_Parameters.OutputEncoding;
43 |
44 | protected internal override string FileName => m_Parameters.FileName;
45 |
46 | protected internal override bool OverwriteExistingFile => m_Parameters.OverwriteExistingFile;
47 |
48 | protected internal override string TransformLine(string line)
49 | {
50 | if (m_Parameters.Case == TextCase.Uppercase)
51 | {
52 | return line.ToUpper();
53 | }
54 | else
55 | {
56 | return line.ToLower();
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Processors/Text/ChangeLineEndingsProcessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using FileSharperCore.Util;
6 | using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
7 |
8 | namespace FileSharperCore.Processors.Text
9 | {
10 | public class ChangeLineEndingsParameters
11 | {
12 | [PropertyOrder(1, UsageContextEnum.Both)]
13 | public LineEndingsNoFile LineEndings { get; set; } = LineEndingsNoFile.SystemDefault;
14 | [PropertyOrder(2, UsageContextEnum.Both)]
15 | public OutputEncodingType OutputEncoding { get; set; } = OutputEncodingType.MatchInput;
16 | [PropertyOrder(3, UsageContextEnum.Both)]
17 | public string FileName { get; set; } = ProcessorBase.ORIGINAL_FILE_PATH;
18 | [PropertyOrder(4, UsageContextEnum.Both)]
19 | public bool OverwriteExistingFile { get; set; } = true;
20 | [PropertyOrder(5, UsageContextEnum.Both)]
21 | public bool MoveOriginalToRecycleBin { get; set; }
22 | }
23 |
24 | public class ChangeLineEndingsProcessor : LineProcessor
25 | {
26 | private ChangeLineEndingsParameters m_Parameters = new ChangeLineEndingsParameters();
27 |
28 | public override string Name => "Change line endings";
29 |
30 | public override string Category => "Text";
31 |
32 | public override string Description => "Changes the line endings to the selected type";
33 |
34 | public override object Parameters => m_Parameters;
35 |
36 | protected internal override bool MoveOriginalToRecycleBin => m_Parameters.MoveOriginalToRecycleBin;
37 |
38 | protected internal override LineEndings LineEndings => TextUtil.GetLineEndings(m_Parameters.LineEndings);
39 |
40 | protected internal override OutputEncodingType OutputEncodingType => m_Parameters.OutputEncoding;
41 |
42 | protected internal override string FileName => m_Parameters.FileName;
43 |
44 | protected internal override bool OverwriteExistingFile => m_Parameters.OverwriteExistingFile;
45 |
46 | protected internal override string TransformLine(string line)
47 | {
48 | return line;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Reflection;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("FileSharperCore")]
13 | [assembly: AssemblyDescription("")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("")]
16 | [assembly: AssemblyProduct("FileSharperCore")]
17 | [assembly: AssemblyCopyright("Copyright © 2016")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("adb11369-a7ce-4ff3-afe9-9201f3180d20")]
28 |
29 | // Version information for an assembly consists of the following four values:
30 | //
31 | // Major Version
32 | // Minor Version
33 | // Build Number
34 | // Revision
35 | //
36 | // You can specify all the values or you can default the Build and Revision Numbers
37 | // by using the '*' as shown below:
38 | // [assembly: AssemblyVersion("1.0.*")]
39 | [assembly: AssemblyVersion("1.0.0.0")]
40 | [assembly: AssemblyFileVersion("1.0.0.0")]
41 |
42 | [assembly: InternalsVisibleTo("FileSharperCore.Tests")]
43 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Util/HeaderUtil.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Collections.Generic;
6 | using System.Text.RegularExpressions;
7 |
8 | namespace FileSharperCore.Util
9 | {
10 | public class HeaderUtil
11 | {
12 | public static string[] GetUniqueHeaders(List uniqueHeaders, ICondition condition,
13 | IFieldSource[] fieldSources, bool forBinding = false)
14 | {
15 | List headers = new List();
16 | HashSet usedHeaders = new HashSet(uniqueHeaders);
17 | if (condition != null)
18 | {
19 | headers.AddRange(condition.ColumnHeaders);
20 | }
21 | if (fieldSources != null)
22 | {
23 | foreach (IFieldSource fieldSource in fieldSources)
24 | {
25 | headers.AddRange(fieldSource.ColumnHeaders);
26 | }
27 | }
28 | foreach (string header in headers)
29 | {
30 | string baseHeader = forBinding ? Regex.Replace(header, @"[^a-zA-Z0-9_\- ]", "X") : header;
31 | int num = 2;
32 | string newHeader = baseHeader;
33 | while (usedHeaders.Contains(newHeader))
34 | {
35 | newHeader = baseHeader + " " + num;
36 | num++;
37 | }
38 | uniqueHeaders.Add(newHeader);
39 | usedHeaders.Add(newHeader);
40 | }
41 | return uniqueHeaders.ToArray();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Util/ReverseComparer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace FileSharperCore.Util
8 | {
9 | public class ReverseComparer : IComparer
10 | {
11 | public IComparer m_Comparer;
12 |
13 | public ReverseComparer(IComparer comparer)
14 | {
15 | m_Comparer = comparer;
16 | }
17 |
18 | public int Compare(T x, T y)
19 | {
20 | return m_Comparer.Compare(y, x);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/Util/XmlUtil.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Text.RegularExpressions;
11 | using System.Threading.Tasks;
12 | using System.Xml;
13 | using System.Xml.XPath;
14 |
15 | namespace FileSharperCore.Util
16 | {
17 | public class XmlUtil
18 | {
19 | public static XmlNamespaceManager GetNamespaceManager(XmlDocument xmlDoc, XPathNavigator navigator,
20 | bool ignoreDefaultNamespace, string defaultNamespacePrefixIfNotIgnored)
21 | {
22 | XmlNamespaceManager namespaceManager = null;
23 | if (navigator.NameTable != null)
24 | {
25 | namespaceManager = new XmlNamespaceManager(navigator.NameTable);
26 | if (!ignoreDefaultNamespace)
27 | {
28 | namespaceManager.AddNamespace(defaultNamespacePrefixIfNotIgnored,
29 | xmlDoc.DocumentElement.NamespaceURI);
30 | }
31 | IDictionary namespaces =
32 | xmlDoc.DocumentElement.CreateNavigator().GetNamespacesInScope(XmlNamespaceScope.All);
33 | foreach (KeyValuePair pair in namespaces)
34 | {
35 | if (pair.Key != null && pair.Key != string.Empty)
36 | {
37 | namespaceManager.AddNamespace(pair.Key, pair.Value);
38 | }
39 | }
40 | }
41 | return namespaceManager;
42 | }
43 |
44 | public static void LoadXmlDocument(XmlDocument xmlDoc, FileInfo file, bool ignoreDefaultNamespace)
45 | {
46 | if (ignoreDefaultNamespace)
47 | {
48 | string docstr = File.ReadAllText(file.FullName);
49 | docstr = Regex.Replace(docstr, @"xmlns\s*=\s*", "foobar=");
50 | xmlDoc.LoadXml(docstr);
51 | }
52 | else
53 | {
54 | xmlDoc.Load(file.FullName);
55 | }
56 | }
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperCore/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/ConditionNodeControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using FileSharperCore;
8 |
9 | namespace FileSharperUI
10 | {
11 | ///
12 | /// Interaction logic for ConditionNodeControl.xaml
13 | ///
14 | public partial class ConditionNodeControl : UserControl
15 | {
16 |
17 | public ConditionNodeControl()
18 | {
19 | InitializeComponent();
20 | ListCollectionView lcv = new ListCollectionView(ConditionCatalog.Instance.Conditions);
21 | lcv.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
22 | this.comboBox.ItemsSource = lcv;
23 | }
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/ConditionNodeListControl.xaml:
--------------------------------------------------------------------------------
1 |
6 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/ConditionNodeListControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharperUI
8 | {
9 | ///
10 | /// Interaction logic for ConditionNodeListControl.xaml
11 | ///
12 | public partial class ConditionNodeListControl : UserControl
13 | {
14 | public ConditionNodeListControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/ConditionNodeRowControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharperUI
8 | {
9 | ///
10 | /// Interaction logic for ConditionNodeRowControl.xaml
11 | ///
12 | public partial class ConditionNodeRowControl : UserControl
13 | {
14 | public ConditionNodeRowControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/FieldSourceNodeControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using FileSharperCore;
8 |
9 | namespace FileSharperUI
10 | {
11 | ///
12 | /// Interaction logic for FieldSourceNodeControl.xaml
13 | ///
14 | public partial class FieldSourceNodeControl : UserControl
15 | {
16 | public FieldSourceNodeControl()
17 | {
18 | InitializeComponent();
19 | ListCollectionView lcv = new ListCollectionView(FieldSourceCatalog.Instance.FieldSources);
20 | lcv.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
21 | this.comboBox.ItemsSource = lcv;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/FieldSourceNodeRowControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharperUI
8 | {
9 | ///
10 | /// Interaction logic for FieldSourceNodeRowControl.xaml
11 | ///
12 | public partial class FieldSourceNodeRowControl : UserControl
13 | {
14 | public FieldSourceNodeRowControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/FieldSourcesNodeControl.xaml:
--------------------------------------------------------------------------------
1 |
6 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/FieldSourcesNodeControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharperUI
8 | {
9 | ///
10 | /// Interaction logic for FieldSourcesNodeControl.xaml
11 | ///
12 | public partial class FieldSourcesNodeControl : UserControl
13 | {
14 | public FieldSourcesNodeControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/FileSourceNodeControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using FileSharperCore;
8 |
9 | namespace FileSharperUI
10 | {
11 | ///
12 | /// Interaction logic for FileSourceNodeControl.xaml
13 | ///
14 | public partial class FileSourceNodeControl : UserControl
15 | {
16 | public FileSourceNodeControl()
17 | {
18 | InitializeComponent();
19 | ListCollectionView lcv = new ListCollectionView(FileSourceCatalog.Instance.FileSources);
20 | lcv.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
21 | this.comboBox.ItemsSource = lcv;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/MatchLimitsControl.xaml:
--------------------------------------------------------------------------------
1 |
6 |
14 |
15 |
16 |
17 |
18 |
19 | Stop after
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/MatchLimitsControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Data;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Navigation;
18 | using System.Windows.Shapes;
19 |
20 | namespace FileSharperUI
21 | {
22 | ///
23 | /// Interaction logic for MatchLimitsControl.xaml
24 | ///
25 | public partial class MatchLimitsControl : UserControl
26 | {
27 | public MatchLimitsControl()
28 | {
29 | InitializeComponent();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/ProcessorNodeControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 | using System.Windows.Data;
7 | using FileSharperCore;
8 |
9 | namespace FileSharperUI
10 | {
11 | ///
12 | /// Interaction logic for ProcessorNodeControl.xaml
13 | ///
14 | public partial class ProcessorNodeControl : UserControl
15 | {
16 | public ProcessorNodeControl()
17 | {
18 | InitializeComponent();
19 | ListCollectionView lcv = new ListCollectionView(ProcessorCatalog.Instance.Processors);
20 | lcv.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
21 | this.comboBox.ItemsSource = lcv;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/ProcessorNodeRowControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharperUI
8 | {
9 | ///
10 | /// Interaction logic for ProcessorNodeRowControl.xaml
11 | ///
12 | public partial class ProcessorNodeRowControl : UserControl
13 | {
14 | public ProcessorNodeRowControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/ProcessorsNodeControl.xaml:
--------------------------------------------------------------------------------
1 |
6 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/ProcessorsNodeControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharperUI
8 | {
9 | ///
10 | /// Interaction logic for ProcessorsNodeControl.xaml
11 | ///
12 | public partial class ProcessorsNodeControl : UserControl
13 | {
14 | public ProcessorsNodeControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Reflection;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("FileSharperUI")]
13 | [assembly: AssemblyDescription("")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("")]
16 | [assembly: AssemblyProduct("FileSharperUI")]
17 | [assembly: AssemblyCopyright("Copyright © 2016")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("cec86db8-aaa7-4056-8741-d1280e2c72b5")]
28 |
29 | // Version information for an assembly consists of the following four values:
30 | //
31 | // Major Version
32 | // Minor Version
33 | // Build Number
34 | // Revision
35 | //
36 | // You can specify all the values or you can default the Build and Revision Numbers
37 | // by using the '*' as shown below:
38 | // [assembly: AssemblyVersion("1.0.*")]
39 | [assembly: AssemblyVersion("1.0.0.0")]
40 | [assembly: AssemblyFileVersion("1.0.0.0")]
41 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/SearchDocumentControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 |
7 | namespace FileSharperUI
8 | {
9 | ///
10 | /// Interaction logic for SearchDocumentControl.xaml
11 | ///
12 | public partial class SearchDocumentControl : UserControl
13 | {
14 | public SearchDocumentControl()
15 | {
16 | InitializeComponent();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/SearchDocumentSetupControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Data;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Navigation;
18 | using System.Windows.Shapes;
19 |
20 | namespace FileSharperUI
21 | {
22 | ///
23 | /// Interaction logic for SearchDocumentSetupControl.xaml
24 | ///
25 | public partial class SearchDocumentSetupControl : UserControl
26 | {
27 | public SearchDocumentSetupControl()
28 | {
29 | InitializeComponent();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/SearchViewModelControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Windows.Controls;
6 | using FileSharperCore;
7 |
8 | namespace FileSharperUI
9 | {
10 | ///
11 | /// Interaction logic for SearchViewModelControl.xaml
12 | ///
13 | public partial class SearchViewModelControl : UserControl
14 | {
15 | public SearchViewModelControl()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | private void ListView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
21 | {
22 | SearchDocument doc = DataContext as SearchDocument;
23 | if (doc != null)
24 | {
25 | doc.SearchViewModel?.OpenFileCommand?.Execute(resultsListView.SelectedItems);
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUI/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/BoolToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Globalization;
7 | using System.Windows;
8 | using System.Windows.Data;
9 |
10 | namespace FileSharperUIHelpers
11 | {
12 | public class BoolToVisibilityConverter : IValueConverter
13 | {
14 |
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | bool boolval = (value == null ? false : (bool)value);
18 | bool reverse = (parameter == null ? false : (bool)parameter);
19 | bool visible = reverse ? !boolval : boolval;
20 | if (visible)
21 | {
22 | return Visibility.Visible;
23 | }
24 | else
25 | {
26 | return Visibility.Collapsed;
27 | }
28 | }
29 |
30 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
31 | {
32 | throw new NotImplementedException();
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/CountToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Globalization;
7 | using System.Windows;
8 | using System.Windows.Data;
9 |
10 | namespace FileSharperUIHelpers
11 | {
12 | public class CountToVisibilityConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | if (value == null || (int)value < 2)
17 | {
18 | return Visibility.Collapsed;
19 | }
20 | else
21 | {
22 | return Visibility.Visible;
23 | }
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
27 | {
28 | throw new NotImplementedException();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/HowOftenToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Globalization;
7 | using System.Windows;
8 | using System.Windows.Data;
9 | using FileSharperCore;
10 |
11 | namespace FileSharperUIHelpers
12 | {
13 | public class HowOftenToVisibilityConverter : IValueConverter
14 | {
15 |
16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | HowOften howOften = (value == null ? HowOften.Never : (HowOften)value);
19 | bool reverse = (parameter == null ? false : (bool)parameter);
20 | bool visible = reverse ? howOften == HowOften.Never : howOften != HowOften.Never;
21 | if (visible)
22 | {
23 | return Visibility.Visible;
24 | }
25 | else
26 | {
27 | return Visibility.Collapsed;
28 | }
29 | }
30 |
31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
32 | {
33 | throw new NotImplementedException();
34 | }
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/InverseBooleanConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Windows.Data;
7 |
8 | namespace FileSharperUIHelpers
9 | {
10 | [ValueConversion(typeof(bool), typeof(bool))]
11 | public class InverseBooleanConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter,
14 | System.Globalization.CultureInfo culture)
15 | {
16 | if (targetType != typeof(bool))
17 | {
18 | throw new InvalidOperationException("Target must be a bool");
19 | }
20 |
21 | return !(bool)value;
22 | }
23 |
24 | public object ConvertBack(object value, Type targetType, object parameter,
25 | System.Globalization.CultureInfo culture)
26 | {
27 | throw new NotSupportedException();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/ObjectToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Globalization;
7 | using System.Reflection;
8 | using System.Windows;
9 | using System.Windows.Data;
10 |
11 | namespace FileSharperUIHelpers
12 | {
13 | public class ObjectToVisibilityConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value == null)
18 | {
19 | return Visibility.Collapsed;
20 | }
21 | else
22 | {
23 | Type t = value.GetType();
24 | if (t.GetProperties(BindingFlags.Public | BindingFlags.Instance).Length == 0)
25 | {
26 | return Visibility.Collapsed;
27 | }
28 | }
29 | return Visibility.Visible;
30 | }
31 |
32 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
33 | {
34 | throw new NotImplementedException();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System.Reflection;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("FileSharperUIHelpers")]
13 | [assembly: AssemblyDescription("")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("")]
16 | [assembly: AssemblyProduct("FileSharperUIHelpers")]
17 | [assembly: AssemblyCopyright("Copyright © 2016")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("a7bdc2eb-5010-47ce-a2eb-1825afd92ca7")]
28 |
29 | // Version information for an assembly consists of the following four values:
30 | //
31 | // Major Version
32 | // Minor Version
33 | // Build Number
34 | // Revision
35 | //
36 | // You can specify all the values or you can default the Build and Revision Numbers
37 | // by using the '*' as shown below:
38 | // [assembly: AssemblyVersion("1.0.*")]
39 | [assembly: AssemblyVersion("1.0.0.0")]
40 | [assembly: AssemblyFileVersion("1.0.0.0")]
41 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/SearchViewModelToDynamicGridViewConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Globalization;
8 | using System.Text.RegularExpressions;
9 | using System.Windows.Controls;
10 | using System.Windows.Data;
11 | using FileSharperCore;
12 |
13 | namespace FileSharperUIHelpers
14 | {
15 | public class SearchViewModelToDynamicGridViewConverter : IValueConverter
16 | {
17 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
18 | {
19 | var searchViewModel = value as SearchViewModel;
20 | if (searchViewModel != null)
21 | {
22 | var gridView = new GridView();
23 | string[] columnHeaders = searchViewModel.ColumnHeaders;
24 | int i = 0;
25 | foreach (string bindingHeaderName in searchViewModel.BindingColumnHeaders)
26 | {
27 | var binding = new Binding(bindingHeaderName);
28 | gridView.Columns.Add(new GridViewColumn { Header = columnHeaders[i++],
29 | DisplayMemberBinding = binding });
30 | }
31 | return gridView;
32 | }
33 | return Binding.DoNothing;
34 | }
35 |
36 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
37 | {
38 | throw new NotSupportedException();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/SubtractNumberConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Windows.Data;
7 |
8 | namespace FileSharperUIHelpers
9 | {
10 | public class SubtractNumberConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | if (value is double)
15 | {
16 | if (parameter is double)
17 | {
18 | return (double)value - (double)parameter;
19 | }
20 | return value;
21 | }
22 | return 0;
23 | }
24 |
25 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
26 | {
27 | throw new NotImplementedException();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/TypeNameToConditionConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Windows.Data;
9 | using FileSharperCore;
10 |
11 | namespace FileSharperUIHelpers
12 | {
13 | public class TypeNameToConditionConverter: IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value == null)
18 | return null;
19 | return ConditionCatalog.Instance.Conditions.Where(x => x.GetType().FullName == (string)value).FirstOrDefault();
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | return value?.GetType().FullName;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/TypeNameToFieldSourceConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Windows.Data;
9 | using FileSharperCore;
10 |
11 | namespace FileSharperUIHelpers
12 | {
13 | public class TypeNameToFieldSourceConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value == null)
18 | return null;
19 | return FieldSourceCatalog.Instance.FieldSources.Where(x => x.GetType().FullName == (string)value).FirstOrDefault();
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | return value?.GetType().FullName;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/TypeNameToFileSourceConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Windows.Data;
9 | using FileSharperCore;
10 |
11 | namespace FileSharperUIHelpers
12 | {
13 | public class TypeNameToFileSourceConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value == null)
18 | return null;
19 | return FileSourceCatalog.Instance.FileSources.Where(x => x.GetType().FullName == (string)value).FirstOrDefault();
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | return value?.GetType().FullName;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/TypeNameToProcessorConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017 Andrew Vardeman. Published under the MIT license.
2 | // See license.txt in the FileSharper distribution or repository for the
3 | // full text of the license.
4 |
5 | using System;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Windows.Data;
9 | using FileSharperCore;
10 |
11 | namespace FileSharperUIHelpers
12 | {
13 | public class TypeNameToProcessorConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value == null)
18 | return null;
19 | return ProcessorCatalog.Instance.Processors.Where(x => x.GetType().FullName == (string)value).FirstOrDefault();
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | return value?.GetType().FullName;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/FileSharper/FileSharperUIHelpers/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------