Skip to content

Commit

Permalink
Merge pull request #144 from Vasar007/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasar007 authored Aug 7, 2022
2 parents b392f79 + 58d5bd2 commit 8992b07
Show file tree
Hide file tree
Showing 274 changed files with 7,556 additions and 1,875 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ updates:
- package-ecosystem: "nuget"
# Look for NuGet dependency info from the solution directory.
directory: "/ProjectV"
# Check the nuget registry for updates every day (weekdays).
# Check the nuget registry for updates: daily/weekly/monthly.
schedule:
interval: "daily"
interval: "monthly"
open-pull-requests-limit: 5
# Specify additional information for NuGet pull requests.
labels:
Expand Down
Binary file added Media/ProjectV_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions ProjectV/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ root = true
# C# and F# files
[*.{cs,fs,fsi,fsx}]

# Files to exclude from foramtting because dotnet-format cannot process F# usages in C# code.

[Applications/ProjectV.ConsoleApp/Program.cs]
generated_code = true

[Applications/ProjectV.DesktopApp/Models/ContentDirectories/ContentDirectoryHelper.cs]
generated_code = true

[Applications/ProjectV.DesktopApp/Models/ContentDirectories/ContentFinderWrapper.cs]
generated_code = true

#### Core EditorConfig Options ####

# Indentation and spacing
Expand Down Expand Up @@ -241,3 +230,14 @@ dotnet_style_prefer_simplified_interpolation = false:suggestion

# IDE0079: Remove unnecessary suppression
dotnet_diagnostic.IDE0079.severity = error

# Files to exclude from formatting because dotnet-format cannot process F# usages in C# code.

[Applications/ProjectV.ConsoleApp/Program.cs]
generated_code = true

[Applications/ProjectV.DesktopApp/Models/ContentDirectories/ContentDirectoryHelper.cs]
generated_code = true

[Applications/ProjectV.DesktopApp/Models/ContentDirectories/ContentFinderWrapper.cs]
generated_code = true
4 changes: 2 additions & 2 deletions ProjectV/Applications/ProjectV.ConsoleApp/ExitCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum ExitCode

public static class ExitCodes
{
public const int Success = (int)ExitCode.Success;
public const int Fail = (int)ExitCode.Fail;
public const int Success = (int) ExitCode.Success;
public const int Fail = (int) ExitCode.Fail;
}
}
17 changes: 9 additions & 8 deletions ProjectV/Applications/ProjectV.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using ProjectV.ContentDirectories;
using ProjectV.Core;
using ProjectV.DataAccessLayer;
using ProjectV.DataAccessLayer.Services.Jobs;
using ProjectV.DataAccessLayer.Services.Jobs.Models;
using ProjectV.Logging;
using ProjectV.Models.Internal;
using ProjectV.Models.Internal.Jobs;
Expand All @@ -29,6 +29,7 @@ internal static class Program
/// Main method of the Console Application which using config to manipulate Shell.
/// </summary>
/// <param name="args">Represents the command-line arguments.</param>
/// <returns>Asynchronous result without value.</returns>
private static async Task MainXDocument(IReadOnlyList<string> args)
{
// Show the case when we have a movies to appraise.
Expand All @@ -45,6 +46,7 @@ private static async Task MainXDocument(IReadOnlyList<string> args)
/// </summary>
/// <param name="args">Represents the command-line arguments.</param>
/// <param name="shell">Represents the main manager of the library.</param>
/// <returns>Asynchronous result without value.</returns>
private static async Task Run(IReadOnlyList<string> args, Shell shell)
{
ServiceStatus status;
Expand All @@ -54,9 +56,7 @@ private static async Task Run(IReadOnlyList<string> args, Shell shell)
}
else
{
GlobalMessageHandler.OutputMessage(
"Enter filename which contains the Things: "
);
GlobalMessageHandler.OutputMessage("Enter filename which contains the Things: ");
status = await shell.Run(GlobalMessageHandler.GetMessage());
}

Expand All @@ -75,6 +75,7 @@ private static async Task Run(IReadOnlyList<string> args, Shell shell)
/// Console application start point.
/// </summary>
/// <param name="args">Represents the command-line arguments.</param>
/// <returns>Asynchronous result with exit code.</returns>
private static async Task<int> Main(string[] args)
{
try
Expand Down Expand Up @@ -132,7 +133,7 @@ private static void TestDbOrmEf()
foreach (JobDbInfo jobDbInfo in context.GetJobDbSet())
{
string message =
$"Job DB info: {jobDbInfo.Id.ToString()}, {jobDbInfo.Name}, " +
$"Job DB info: {jobDbInfo.WrappedId}, {jobDbInfo.Name}, " +
$"{jobDbInfo.State.ToString()}, {jobDbInfo.Result.ToString()}, " +
$"{jobDbInfo.Config.ToString()}";

Expand Down Expand Up @@ -165,7 +166,7 @@ private static void TestAutomapper()
config: "TaskConfig"
);
string message =
$"Job DB info: {jobDbInfo.Id.ToString()}, {jobDbInfo.Name}, " +
$"Job DB info: {jobDbInfo.WrappedId}, {jobDbInfo.Name}, " +
$"{jobDbInfo.State.ToString()}, {jobDbInfo.Result.ToString()}, " +
$"{jobDbInfo.Config.ToString()}";

Expand All @@ -181,7 +182,7 @@ private static void TestAutomapper()

jobDbInfo = mapper.Map<JobDbInfo>(jobInfo);
message =
$"Job DB info: {jobDbInfo.Id.ToString()}, {jobDbInfo.Name}, " +
$"Job DB info: {jobDbInfo.WrappedId}, {jobDbInfo.Name}, " +
$"{jobDbInfo.State.ToString()}, {jobDbInfo.Result.ToString()}, " +
$"{jobDbInfo.Config.ToString()}";

Expand All @@ -192,7 +193,7 @@ private static async Task TestConentDirectories()
{
IReadOnlyDictionary<string, IReadOnlyList<string>> result =
await ContentFinder.FindContentForDirAsync(
@"C:\Users\vasar\Documents\GitHub",
@"%USERPROFILE%\Documents\GitHub",
ContentModels.ContentType.Text
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
<TargetFramework>$(AppTargetFramework)</TargetFramework>
<LangVersion>$(CSharpLangVersion)</LangVersion>
<Nullable>enable</Nullable>
<Deterministic>true</Deterministic>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RootNamespace>ProjectV.ConsoleApp</RootNamespace>
<IncludeSymbols>false</IncludeSymbols>
<IsPackable>false</IsPackable>
<ApplicationIcon>ta_thumb.ico</ApplicationIcon>
<ApplicationIcon>..\..\Resources\ProjectV_logo.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
Expand All @@ -21,12 +22,8 @@
</ItemGroup>

<ItemGroup>
<None Update="games.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="thing_names.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="..\..\Resources\games.csv" CopyToOutputDirectory="PreserveNewest" />
<None Update="..\..\Resources\thing_names.csv" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Binary file not shown.
37 changes: 36 additions & 1 deletion ProjectV/Applications/ProjectV.DesktopApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
using System.Globalization;
using System;
using System.Globalization;
using System.Net.Http;
using System.Threading;
using System.Windows;
using System.Windows.Markup;
using Acolyte.Exceptions;
using Acolyte.Exceptions.Handlers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Regions;
using Prism.Unity;
using ProjectV.Configuration;
using ProjectV.Core.DependencyInjection;
using ProjectV.DesktopApp.Domain;
using ProjectV.DesktopApp.Views;
using ProjectV.Logging;
Expand All @@ -32,6 +40,10 @@ public App()
)
);

AppDomainUnhandledExceptionManager.SetHandler(
new UnhandledExceptionHandlerWrapper(Application_OnUnhandledException)
);

_logger.PrintHeader("Desktop client application started.");
}

Expand Down Expand Up @@ -62,9 +74,26 @@ protected override Window CreateShell()
return Container.Resolve<MainWindow>();
}

private static void ConfigureServices(IServiceCollection services)
{
services.AddHttpClientWithOptions(ConfigOptions.ProjectVService.HttpClient);
}

private static IServiceProvider CreateServices()
{
var host = new HostBuilder()
.ConfigureServices(services => ConfigureServices(services))
.Build();

return host.Services;
}

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
var services = CreateServices();

// TODO: register common domain and models classes here.
containerRegistry.Register<IHttpClientFactory>(() => services.GetRequiredService<IHttpClientFactory>());
}

protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
Expand All @@ -76,5 +105,11 @@ private void Application_Exit(object sender, ExitEventArgs e)
{
_logger.PrintFooter("Desktop client application stopped.");
}

private void Application_OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var ex = (Exception) e.ExceptionObject;
_logger.Error(ex, "Unhandled exception has been occurred.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal static class ApplicationCloseCommand
{
public static bool CanExecute()
{
return !(Application.Current is null) && !(Application.Current.MainWindow is null);
return Application.Current is not null && Application.Current.MainWindow is not null;
}

public static void Execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool ICommand.CanExecute(object? parameter)
throw GetParameterNullException(nameof(parameter));
}

return CanExecute((T)parameter);
return CanExecute((T) parameter);
}

void ICommand.Execute(object? parameter)
Expand All @@ -92,7 +92,7 @@ void ICommand.Execute(object? parameter)
throw GetParameterNullException(nameof(parameter));
}

ExecuteAsync((T)parameter).FireAndForgetSafeAsync(_errorHandler);
ExecuteAsync((T) parameter).FireAndForgetSafeAsync(_errorHandler);
}

private static ArgumentNullException GetParameterNullException(string parameterName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static bool IsValid(object? value)
// booleanValue may be Validation.HasError.
if (value is bool booleanValue) return !booleanValue;

return !(value is null);
return value is not null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace ProjectV.DesktopApp.Domain
{
internal static class DesktopOptions
{
public static string Title { get; } = "The Thing Appraiser";
public static string Title { get; } = "Project V";

/// <summary>
/// Page names of all views in main menu.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static T Evaluate<T>(this BindingExpression bindingExpression)
if (resolvedSource is null)
{
throw new ArgumentException(
"Failed to evalute binding expression. Source is not resolved.",
"Failed to evaluate binding expression. Source is not resolved.",
nameof(bindingExpression)
);
}
Expand All @@ -30,7 +30,7 @@ public static T Evaluate<T>(this BindingExpression bindingExpression)
if (prop is null)
{
throw new ArgumentException(
"Failed to evalute binding expression.", nameof(bindingExpression)
"Failed to evaluate binding expression.", nameof(bindingExpression)
);
}

Expand All @@ -57,9 +57,9 @@ public static bool TryEvaluate<T>(this BindingExpression bindingExpression,
bindingExpression.ResolvedSourcePropertyName
);

if (!(prop is null) &&
if (prop is not null &&
prop.GetValue(bindingExpression.ResolvedSource) is T value &&
!(value is null))
value is not null)
{
result = value;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task<ContentDirectoryInfo> PerformAsync(

ContentDirectoryInfo result = await _contentFinder
.GetAllDirectoryContentAsync(parameters.DirectoryPath, parameters.ContentType)
.ConfigureAwait(continueOnCapturedContext: false);
.ConfigureAwait(false);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task<ContentDirectoryInfo> GetAllDirectoryContentAsync(
contentType: contentType.ConvertToLibraryEnum(),
pagingInfo: FSharpHelper.CreateOption(new ContentModels.PagingInfo(0, 10))
)
.ConfigureAwait(continueOnCapturedContext: false);
.ConfigureAwait(false);

return new ContentDirectoryInfo(directoryPath, contentType, result);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System.Collections.Generic;
using ProjectV.DesktopApp.Models.Things;
using ProjectV.Models.Internal;
using ProjectV.Models.WebService;
using ProjectV.Models.WebServices.Responses;

namespace ProjectV.DesktopApp.Models.DataSuppliers
{
internal interface IThingGrader
{
IReadOnlyList<Thing> ProcessRatings(IReadOnlyList<RatingDataContainer> rating);

void ProcessMetadata(ResponseMetadata metadata);
void ProcessMetadata(ProcessingResponseMetadata metadata);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using ProjectV.DesktopApp.Models.Things;
using ProjectV.Models.WebService;
using ProjectV.Models.WebServices.Responses;

namespace ProjectV.DesktopApp.Models.DataSuppliers
{
Expand Down
Loading

0 comments on commit 8992b07

Please sign in to comment.