Skip to content

Commit

Permalink
Merge pull request #3 from ajmcateer/experimental
Browse files Browse the repository at this point in the history
Experimental
  • Loading branch information
ajmcateer authored Mar 7, 2020
2 parents c7f797d + 0b7adaf commit b3cd989
Show file tree
Hide file tree
Showing 26 changed files with 964 additions and 604 deletions.
11 changes: 9 additions & 2 deletions GotifyDesktop/Build.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
dotnet publish -f netcoreapp3.0 -r win-x64 -c Release /p:PublishSingleFile=true
$path = Split-Path -parent $MyInvocation.MyCommand.Definition
$folderToDelete = $path + '\bin\Release\netcoreapp3.0'

Remove-Item $folderToDelete -Recurse -Force

Set-Location -Path $path

dotnet publish -f netcoreapp3.0 -r win-x64 -c Release /p:PublishSingleFile=true
dotnet publish -f netcoreapp3.0 -r linux-x64 -c Release
dotnet publish -f netcoreapp3.0 -r osx-x64 -c Release /p:PublishSingleFile=true
dotnet publish -f netcoreapp3.0 -r osx-x64 -c Release
34 changes: 34 additions & 0 deletions GotifyDesktop/Comparer/ApplicationComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using gotifySharp.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;

namespace GotifyDesktop.Comparer
{
public class ApplicationComparer : IEqualityComparer<ApplicationModel>
{
public bool Equals([AllowNull] ApplicationModel x, [AllowNull] ApplicationModel y)
{
if (object.ReferenceEquals(x, y))
{
return true;
}
if (object.ReferenceEquals(x, null) ||
object.ReferenceEquals(y, null))
{
return false;
}
return x.id == y.id;
}

public int GetHashCode([DisallowNull] ApplicationModel obj)
{
if (obj == null)
{
return 0;
}
return obj.id.GetHashCode();
}
}
}
34 changes: 34 additions & 0 deletions GotifyDesktop/Comparer/MessageComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using gotifySharp.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;

namespace GotifyDesktop.Comparer
{
public class MessageComparer : IEqualityComparer<MessageModel>
{
public bool Equals([AllowNull] MessageModel x, [AllowNull] MessageModel y)
{
if (object.ReferenceEquals(x, y))
{
return true;
}
if (object.ReferenceEquals(x, null) ||
object.ReferenceEquals(y, null))
{
return false;
}
return x.id == y.id;
}

public int GetHashCode([DisallowNull] MessageModel obj)
{
if (obj == null)
{
return 0;
}
return obj.id.GetHashCode();
}
}
}
24 changes: 11 additions & 13 deletions GotifyDesktop/GotifyDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
<AvaloniaResource Remove="Views\AddServerView.xaml" />
<AvaloniaResource Remove="Views\AlertMessageView.xaml" />
<AvaloniaResource Remove="Views\ApplicationView.xaml" />
<AvaloniaResource Remove="Views\MainControlv2View.xaml" />
<AvaloniaResource Remove="Views\MainControlView.xaml" />
<AvaloniaResource Remove="Views\BusyView.xaml" />
</ItemGroup>
<ItemGroup>
<None Remove="README.md" />
<None Remove="Views\AddServerView.xaml" />
<None Remove="Views\AlertMessageView.xaml" />
<None Remove="Views\ApplicationView.xaml" />
<None Remove="Views\MainControlv2View.xaml" />
<None Remove="Views\MainControlView.xaml" />
<None Remove="Views\BusyView.xaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand All @@ -44,27 +42,22 @@
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\MainControlView.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\AddServerView.xaml">
<EmbeddedResource Include="Views\ApplicationView.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\ApplicationView.xaml">
<EmbeddedResource Include="Views\AlertMessageView.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\MainControlv2View.xaml">
<EmbeddedResource Include="Views\AddServerView.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\AlertMessageView.xaml">
<EmbeddedResource Include="Views\BusyView.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
Expand All @@ -73,4 +66,9 @@
<HintPath>..\..\gotifySharp\gotifySharp\bin\Release\netcoreapp3.0\gotifySharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="Views\AddServerView.xaml.cs">
<DependentUpon>AddServerView.xaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
5 changes: 4 additions & 1 deletion GotifyDesktop/Infrastructure/DatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public DatabaseContext()
}

protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite("Data Source=gotifyDesktop.db");
{
options.UseSqlite("Data Source=gotifyDesktop.db");
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
}
}
}
16 changes: 16 additions & 0 deletions GotifyDesktop/Infrastructure/DatabaseContextFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;

namespace GotifyDesktop.Infrastructure
{
public class DatabaseContextFactory
{
public DatabaseContext CreateContext()
{
DatabaseContext context = new DatabaseContext();
return context;
}
}
}
23 changes: 23 additions & 0 deletions GotifyDesktop/Infrastructure/GotifyServiceFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using GotifyDesktop.Service;
using Serilog;
using System;
using System.Collections.Generic;
using System.Text;

namespace GotifyDesktop.Infrastructure
{
public class GotifyServiceFactory
{
ILogger _ilogger;

public GotifyServiceFactory(ILogger ilogger)
{
_ilogger = ilogger;
}

public GotifyService CreateNewGotifyService()
{
return new GotifyService(_ilogger);
}
}
}
11 changes: 9 additions & 2 deletions GotifyDesktop/Infrastructure/MessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ public static async Task ShowMessageAsync(ButtonEnum buttonEnum, string title, s
await msBoxStandardWindow.Show();
}

public static async Task DropDownMessage()
public static async Task<ButtonResult> ShowDialogAsync(ButtonEnum buttonEnum, string title, string message, Icon icon)
{

var msBoxStandardWindow = MessageBox.Avalonia.MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
{
ButtonDefinitions = buttonEnum,
ContentTitle = title,
ContentMessage = message,
Icon = icon
});
return await msBoxStandardWindow.Show();
}
}
}
2 changes: 1 addition & 1 deletion GotifyDesktop/Models/ServerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ public ServerInfo(int ID, string Url, int Port, string Username, string Password
this.ClientName = ClientName;
}
}
}
}
9 changes: 6 additions & 3 deletions GotifyDesktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Program
{
public static LoggingLevelSwitch loggingLevelSwitch;

public static MainWindow window;

// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
Expand Down Expand Up @@ -50,16 +52,17 @@ private static void AppMain(Application app, string[] args)
.CreateLogger();

// Register individual components
builder.RegisterType<DatabaseContext>();
builder.RegisterType<DatabaseContextFactory>();
builder.RegisterType<GotifyServiceFactory>();
builder.RegisterLogger();
builder.RegisterType<GotifySharp>();
builder.RegisterType<GotifyService>().SingleInstance();
builder.RegisterType<GotifyService>();
builder.RegisterType<GotifyService>().Named<GotifyService>("TestService");
builder.RegisterType<DatabaseService>();
builder.RegisterType<SyncService>().SingleInstance();
var container = builder.Build();

var window = new MainWindow
window = new MainWindow
{
DataContext = new MainWindowViewModel(container),
};
Expand Down
Loading

0 comments on commit b3cd989

Please sign in to comment.