Skip to content

Commit a580bf4

Browse files
authored
Merge pull request #7 from plainerman/feature-genius-integration
Feature genius integration
2 parents 2484096 + f5577a6 commit a580bf4

20 files changed

+292
-114
lines changed

TicTacTube.sln.DotSettings

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
- <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOR/@EntryValue">Required</s:String>
3+
- <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String>
4+
- <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String>
5+
- <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/LOCAL_FUNCTION_BODY/@EntryValue">ExpressionBody</s:String>
6+
- <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/METHOD_OR_OPERATOR_BODY/@EntryValue">ExpressionBody</s:String>
7+
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_ARRAY_RANK_EMPTY_BRACKETS/@EntryValue">False</s:Boolean>
8+
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
9+
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForBuiltInTypes/@EntryValue">UseExplicitType</s:String>
10+
<s:String x:Key="/Default/Environment/Hierarchy/PsiConfigurationSettingsKey/CustomLocation/@EntryValue">C:\Users\plain\AppData\Local\JetBrains\Transient\ReSharperPlatformVs15\v09_cf031b4e\SolutionCaches</s:String></wpf:ResourceDictionary>

TicTacTubeCore/Processors/Filesystem/SourceMover.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ namespace TicTacTubeCore.Processors.Filesystem
1010
public class SourceMover : BaseDataProcessor
1111
{
1212
/// <summary>
13-
/// The destination path or folder.
13+
/// The destination path or folder.
1414
/// </summary>
1515
protected readonly string DestinationPath;
16+
1617
/// <summary>
17-
/// <c>True</c>, if an existing destination should be overriden.
18+
/// Whether the name should be kept (<see cref="DestinationPath" /> is a folder) or one is specified (
19+
/// <see cref="DestinationPath" /> is a file).
1820
/// </summary>
19-
protected readonly bool Override;
21+
protected readonly bool KeepName;
22+
2023
/// <summary>
21-
/// Whether the name should be kept (<see cref="DestinationPath"/> is a folder) or one is specified (<see cref="DestinationPath"/> is a file).
24+
/// <c>True</c>, if an existing destination should be overriden.
2225
/// </summary>
23-
protected readonly bool KeepName;
26+
protected readonly bool Override;
2427

2528
/// <summary>
2629
/// Create a source mover that moves a source to a complete path (also rename the file).
@@ -54,14 +57,10 @@ public override IFileSource Execute(IFileSource fileSoure)
5457

5558
string directory = Path.GetDirectoryName(dest);
5659
if (!Directory.Exists(directory))
57-
{
5860
Directory.CreateDirectory(directory);
59-
}
6061

6162
if (Override && File.Exists(dest))
62-
{
6363
File.Delete(dest);
64-
}
6564

6665
fileSoure.FileInfo.MoveTo(dest);
6766

TicTacTubeCore/Processors/Filesystem/SourceRenamer.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ namespace TicTacTubeCore.Processors.Filesystem
1111
public class SourceRenamer : BaseDataProcessor
1212
{
1313
/// <summary>
14-
/// Whether an existing file will be overriden or not.
14+
/// Whether an existing file will be overriden or not.
1515
/// </summary>
1616
protected readonly bool Override;
1717

18-
/// <summary>
19-
/// A function that is capable of producing a new file name (with file extension) for a given file source. May not be
20-
/// <c>null</c>.
21-
/// </summary>
22-
public Func<IFileSource, string> NameProducer { get; protected set; }
23-
2418
/// <summary>
2519
/// Create a new source renamer, that renames files with a given renamer.
2620
/// </summary>
@@ -46,6 +40,12 @@ protected SourceRenamer(bool @override = true)
4640
Override = @override;
4741
}
4842

43+
/// <summary>
44+
/// A function that is capable of producing a new file name (with file extension) for a given file source. May not be
45+
/// <c>null</c>.
46+
/// </summary>
47+
public Func<IFileSource, string> NameProducer { get; protected set; }
48+
4949
/// <inheritdoc />
5050
public override IFileSource Execute(IFileSource fileSoure)
5151
{
@@ -58,15 +58,11 @@ public override IFileSource Execute(IFileSource fileSoure)
5858
string newFolderFullPath = Path.Combine(Path.Combine(fileSoure.FileInfo.DirectoryName), newFolder);
5959

6060
if (!Directory.Exists(newFolderFullPath))
61-
{
6261
Directory.CreateDirectory(newFolderFullPath);
63-
}
6462
}
6563

6664
if (Override && File.Exists(fullPath))
67-
{
6865
File.Delete(fullPath);
69-
}
7066

7167
fileSoure.FileInfo.MoveTo(fullPath);
7268

TicTacTubeCore/Processors/Logical/DebugProcessor.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@
55
namespace TicTacTubeCore.Processors.Logical
66
{
77
/// <summary>
8-
/// A debug processor that wraps any given processor and may make debugging easier.
8+
/// A debug processor that wraps any given processor and may make debugging easier.
99
/// </summary>
10-
public class DebugProcessor : BaseDataProcessor
11-
{
10+
public class DebugProcessor : BaseDataProcessor
11+
{
1212
/// <summary>
13-
/// The internally wrapped data processor.
13+
/// Create a new debug processor that wraps the given data processor.
1414
/// </summary>
15-
public IDataProcessorOrBuilder DataProcessor { get; }
15+
/// <param name="dataProcessor">The data processor that will actually be executed.</param>
16+
public DebugProcessor(IDataProcessorOrBuilder dataProcessor)
17+
{
18+
DataProcessor = dataProcessor ?? throw new ArgumentNullException(nameof(dataProcessor));
19+
}
1620

17-
/// <summary>
18-
/// The amount of calls on execute.
21+
/// <summary>
22+
/// The internally wrapped data processor.
1923
/// </summary>
20-
public int ExecutionCount { get; protected set; }
24+
public IDataProcessorOrBuilder DataProcessor { get; }
2125

2226
/// <summary>
23-
/// Create a new debug processor that wraps the given data processor.
27+
/// The amount of calls on execute.
2428
/// </summary>
25-
/// <param name="dataProcessor">The data processor that will actually be executed.</param>
26-
public DebugProcessor(IDataProcessorOrBuilder dataProcessor)
27-
{
28-
DataProcessor = dataProcessor ?? throw new ArgumentNullException(nameof(dataProcessor));
29-
}
29+
public int ExecutionCount { get; protected set; }
3030

31-
/// <inheritdoc/>
32-
public override IFileSource Execute(IFileSource fileSoure)
31+
/// <inheritdoc />
32+
public override IFileSource Execute(IFileSource fileSoure)
3333
{
3434
var newFileSource = DataProcessor.Build().Execute(fileSoure);
3535
ExecutionCount++;
3636

3737
return newFileSource;
3838
}
39-
}
40-
}
39+
}
40+
}

TicTacTubeCore/Processors/Logical/SourceSplitter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public SourceSplitter(IEnumerable<IDataProcessorOrBuilder> processors)
2929
public override IFileSource Execute(IFileSource fileSoure)
3030
{
3131
foreach (var dataProcessorOrBuilder in Processors)
32+
{
3233
dataProcessorOrBuilder.Build().Execute(fileSoure);
34+
}
3335

3436
return fileSoure;
3537
}

TicTacTubeCore/Processors/Media/IMediaInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
public interface IMediaInfo
77
{
88
/// <summary>
9-
/// Write the given media info as tags to the file. Previously stored information will be overriden.
10-
/// If the format does not support tags, throw an exception.
9+
/// Write the given media info as tags to the file. Previously stored information will be overriden.
10+
/// If the format does not support tags, throw an exception.
1111
/// </summary>
1212
/// <param name="path">The path to the file where the tags will be written to.</param>
1313
void WriteToFile(string path);
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
using TicTacTubeCore.Sources.Files;
1+
using System.Threading.Tasks;
2+
using TicTacTubeCore.Sources.Files;
23

34
namespace TicTacTubeCore.Processors.Media
45
{
56
/// <summary>
67
/// An extractor that is capable of generating MediaInfo from a given <see cref="IFileSource" />.
78
/// </summary>
8-
public interface IMediaInfoExtractor<out T> where T : IMediaInfo
9+
public interface IMediaInfoExtractor<T> where T : IMediaInfo
910
{
1011
/// <summary>
11-
/// Extract a given <see cref="IMediaInfo" /> from a given file source.
12+
/// Extract a given <see cref="IMediaInfo" /> from a given file source asynchronously..
1213
/// </summary>
1314
/// <param name="source">The file source that will be analyzed.</param>
1415
/// <returns>The newly created <see cref="IMediaInfo" />.</returns>
15-
T Extract(IFileSource source);
16+
Task<T> ExtractAsyncTask(IFileSource source);
1617
}
1718
}

TicTacTubeCore/Processors/Media/MediaRenamer.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public class MediaRenamer<T> : SourceRenamer where T : IMediaInfo
2727
/// <param name="nameGenerator">The name generator that generates the new file names.</param>
2828
/// <param name="extractor">The extractor that extracts a media info from the file source.</param>
2929
/// <param name="override"><c>True</c>, if an existing destination should be overriden.</param>
30-
public MediaRenamer(IMediaNameGenerator<T> nameGenerator, IMediaInfoExtractor<T> extractor, bool @override = true) : base(@override)
30+
public MediaRenamer(IMediaNameGenerator<T> nameGenerator, IMediaInfoExtractor<T> extractor, bool @override = true) :
31+
base(@override)
3132
{
3233
NameGenerator = nameGenerator ?? throw new ArgumentNullException(nameof(nameGenerator));
3334
MediaInfoExtractor = extractor ?? throw new ArgumentNullException(nameof(extractor));
@@ -57,7 +58,7 @@ public MediaRenamer(string pattern, IMediaInfoExtractor<T> extractor, bool @over
5758
/// </summary>
5859
/// <param name="source">The file source that will be parsed.</param>
5960
/// <returns>The new filename for the file source (with the file extension).</returns>
60-
protected virtual string ProduceName(IFileSource source) => NameGenerator.Parse(MediaInfoExtractor.Extract(source)) +
61-
source.FileExtension;
61+
protected virtual string ProduceName(IFileSource source) =>
62+
NameGenerator.Parse(MediaInfoExtractor.ExtractAsyncTask(source).GetAwaiter().GetResult()) + source.FileExtension;
6263
}
6364
}

TicTacTubeCore/Processors/Media/PatternMediaNameGenerator.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,9 @@ public string Parse(T info)
6161

6262
string currentAsString;
6363
if (current is Array)
64-
{
6564
currentAsString = string.Join(", ", ((IEnumerable) current).Cast<object>().Select(o => o.ToString()));
66-
}
6765
else
68-
{
69-
currentAsString = current.ToString();
70-
}
66+
currentAsString = current?.ToString();
7167
//= current is Array ? string.Join(", ", current) : current.ToString();
7268

7369
name = name.Replace($"{OpenBracket}{i}{CloseBracket}", currentAsString);
@@ -88,13 +84,9 @@ protected string PreparePattern(string pattern)
8884
int closeCount = pattern.Count(f => f == CloseBracket);
8985

9086
if (openCount > closeCount)
91-
{
9287
throw new FormatException($"Bad formatting - {OpenBracket} missing.");
93-
}
9488
if (openCount < closeCount)
95-
{
9689
throw new FormatException($"Bad formatting - {CloseBracket} missing.");
97-
}
9890

9991
var matches = CurlyBracketsMatcher.Matches(pattern);
10092
var variableNames = new List<string>();
@@ -114,9 +106,7 @@ protected string PreparePattern(string pattern)
114106
{
115107
variableNames.Add(currentVar);
116108
if (typeof(T).GetField(currentVar, BindingFlags.Public | BindingFlags.Instance) == null)
117-
{
118109
throw new FormatException($"Unknown parameter \"{currentVar}\"");
119-
}
120110
}
121111

122112
string replace = currentVarIndex.ToString();

0 commit comments

Comments
 (0)