Skip to content

Commit

Permalink
Add LiteDB
Browse files Browse the repository at this point in the history
  • Loading branch information
C1rdec committed Mar 19, 2020
1 parent 234ef05 commit dadcbbf
Show file tree
Hide file tree
Showing 70 changed files with 139 additions and 2,584 deletions.
6 changes: 3 additions & 3 deletions Lurker.Test/Events/TradeEventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Lurker.Test.Events
{
using Lurker.Events;
using Lurker.Models;
using Lurker.Patreon.Events;
using Lurker.Patreon.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

Expand Down Expand Up @@ -146,7 +146,7 @@ private void AssertLocation(Location expectedLocation, Location actualLocation)
/// <returns></returns>
private TradeEvent BuildExpectedTradeEvent(string line)
{
return new TradeEvent(line);
return TradeEvent.TryParse(line);
}
}
}
35 changes: 35 additions & 0 deletions Lurker.Test/Lurker.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="ConfOxide, Version=1.4.2.0, Culture=neutral, PublicKeyToken=934faed64f82030e, processorArchitecture=MSIL">
<HintPath>..\packages\ConfOxide.1.4.2.0\lib\net40\ConfOxide.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=5.0.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="Lurker.Patreon, Version=1.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lurker.Patreon.1.0.3\lib\net48\Lurker.Patreon.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Host.HttpListener.2.0.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Hosting, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
Expand All @@ -51,15 +69,32 @@
<Reference Include="Moq, Version=4.13.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.13.1\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http.Owin, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.2.7\lib\net45\System.Web.Http.Owin.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Events\TradeEventTest.cs" />
Expand Down
12 changes: 12 additions & 0 deletions Lurker.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.4.0" targetFramework="net48" />
<package id="ConfOxide" version="1.4.2.0" targetFramework="net48" />
<package id="LiteDB" version="5.0.4" targetFramework="net48" />
<package id="Lurker.Patreon" version="1.0.3" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.7" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.2.7" targetFramework="net48" />
<package id="Microsoft.Owin" version="2.0.2" targetFramework="net48" />
<package id="Microsoft.Owin.Host.HttpListener" version="2.0.2" targetFramework="net48" />
<package id="Microsoft.Owin.Hosting" version="2.0.2" targetFramework="net48" />
<package id="Moq" version="4.13.1" targetFramework="net48" />
<package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net48" />
<package id="MSTest.TestFramework" version="1.3.2" targetFramework="net48" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net48" />
<package id="Owin" version="1.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.1" targetFramework="net48" />
</packages>
9 changes: 7 additions & 2 deletions src/Lurker.Console/Lurker.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@
<Reference Include="ConfOxide, Version=1.4.2.0, Culture=neutral, PublicKeyToken=934faed64f82030e, processorArchitecture=MSIL">
<HintPath>..\..\packages\ConfOxide.1.4.2.0\lib\net40\ConfOxide.dll</HintPath>
</Reference>
<Reference Include="Lurker.Patreon, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Lurker.Patreon.1.0.1\lib\net48\Lurker.Patreon.dll</HintPath>
<Reference Include="LiteDB, Version=5.0.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="Lurker.Patreon, Version=1.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Lurker.Patreon.1.0.3\lib\net48\Lurker.Patreon.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
Expand Down Expand Up @@ -67,6 +71,7 @@
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Runtime" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Http, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll</HintPath>
Expand Down
12 changes: 6 additions & 6 deletions src/Lurker.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ static void Main(string[] args)
Console.Read();
}

private static void Lurker_NewOffer(object sender, Events.TradeEvent e)
private static void Lurker_NewOffer(object sender, Patreon.Events.TradeEvent e)
{
Console.WriteLine($"({e.Date})--[{e.GuildName}]{e.PlayerName} [item: {e.ItemName}] [price: {e.Price}] [position: {e.Location}] ");
}

private static void Watcher_Whispered(object sender, Events.WhisperEvent e)
private static void Watcher_Whispered(object sender, Patreon.Events.WhisperEvent e)
{
Console.WriteLine($"[{e.GuildName}]{e.PlayerName}: {e.WhisperMessage}");
}

private static void Watcher_PlayerLeft(object sender, Events.PlayerLeftEvent e)
private static void Watcher_PlayerLeft(object sender, Patreon.Events.PlayerLeftEvent e)
{
Console.WriteLine($"{e.PlayerName} left");
}

private static void Watcher_PlayerJoined(object sender, Events.PlayerJoinedEvent e)
private static void Watcher_PlayerJoined(object sender, Patreon.Events.PlayerJoinedEvent e)
{
Console.WriteLine($"{e.PlayerName} joined");
}

private static void Watcher_RemainingMonsters(object sender, Events.MonstersRemainEvent e)
private static void Watcher_RemainingMonsters(object sender, Patreon.Events.MonstersRemainEvent e)
{
Console.WriteLine($"Monster {e.MonsterCount}");
}

private static void Lurker_ChangedLocation(object sender, Events.LocationChangedEvent e)
private static void Lurker_ChangedLocation(object sender, Patreon.Events.LocationChangedEvent e)
{
Console.WriteLine(e.Location);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Lurker.Console/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ConfOxide" version="1.4.2.0" targetFramework="net48" />
<package id="Lurker.Patreon" version="1.0.1" targetFramework="net48" />
<package id="LiteDB" version="5.0.4" targetFramework="net48" />
<package id="Lurker.Patreon" version="1.0.3" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net48" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.7" targetFramework="net48" />
Expand Down
2 changes: 1 addition & 1 deletion src/Lurker.UI/App.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Application x:Class="Lurker.UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Models="clr-namespace:Lurker.Models;assembly=Lurker"
xmlns:Models="clr-namespace:Lurker.Patreon.Models;assembly=Lurker.Patreon"
xmlns:Converters="clr-namespace:Lurker.UI.Converters"
xmlns:local="clr-namespace:Lurker.UI">
<Application.Resources>
Expand Down
2 changes: 1 addition & 1 deletion src/Lurker.UI/Converters/CurrencyTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Lurker.UI.Converters
{
using Lurker.Models;
using Lurker.Patreon.Models;
using System;
using System.Windows.Data;
using System.Windows.Markup;
Expand Down
9 changes: 7 additions & 2 deletions src/Lurker.UI/Lurker.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
</Reference>
<Reference Include="Lurker.Patreon, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Lurker.Patreon.1.0.1\lib\net48\Lurker.Patreon.dll</HintPath>
<Reference Include="LiteDB, Version=5.0.4.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="Lurker.Patreon, Version=1.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Lurker.Patreon.1.0.3\lib\net48\Lurker.Patreon.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MahApps.Metro, Version=1.6.5.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MahApps.Metro.1.6.5\lib\net47\MahApps.Metro.dll</HintPath>
Expand Down Expand Up @@ -142,6 +146,7 @@
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
Expand Down
2 changes: 1 addition & 1 deletion src/Lurker.UI/ViewModels/AffixViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Lurker.UI.ViewModels
{
using Lurker.Models;
using Lurker.Patreon.Models;

public class AffixViewModel
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lurker.UI/ViewModels/ItemOverlayViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Lurker.UI.ViewModels
{
using Lurker.Models;
using Lurker.Patreon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
4 changes: 2 additions & 2 deletions src/Lurker.UI/ViewModels/OfferViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace Lurker.UI.ViewModels
{
using Caliburn.Micro;
using Lurker.Events;
using Lurker.Helpers;
using Lurker.Models;
using Lurker.Patreon.Events;
using Lurker.Patreon.Models;
using Lurker.Services;
using Lurker.UI.Models;
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/Lurker.UI/ViewModels/OutgoingOfferViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace Lurker.UI.ViewModels
{
using Caliburn.Micro;
using Lurker.Events;
using Lurker.Helpers;
using Lurker.Patreon.Events;
using Lurker.UI.Models;
using System.Windows.Input;

Expand Down
18 changes: 16 additions & 2 deletions src/Lurker.UI/ViewModels/OutgoingbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Lurker.UI.ViewModels
{
using Caliburn.Micro;
using Lurker.Helpers;
using Lurker.Patreon.Events;
using Lurker.Services;
using Lurker.UI.Helpers;
using Lurker.UI.Models;
Expand Down Expand Up @@ -127,7 +128,7 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
private void Lurker_OutgoingOffer(object sender, Events.OutgoingTradeEvent e)
private void Lurker_OutgoingOffer(object sender, Patreon.Events.OutgoingTradeEvent e)
{
if (this.Offers.Any(o => o.Event.Equals(e)))
{
Expand All @@ -142,7 +143,7 @@ private void Lurker_OutgoingOffer(object sender, Events.OutgoingTradeEvent e)
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
private void Lurker_TradeAccepted(object sender, Events.TradeAcceptedEvent e)
private void Lurker_TradeAccepted(object sender, Patreon.Events.TradeAcceptedEvent e)
{
if (this._activeOffer == null)
{
Expand All @@ -154,11 +155,24 @@ private void Lurker_TradeAccepted(object sender, Events.TradeAcceptedEvent e)
this._keyboardHelper.Whisper(this._activeOffer.Event.PlayerName, this._settingsService.ThankYouMessage);
}

this.InsertEvent(this._activeOffer.Event);
this.RemoveOffer(this._activeOffer);
this._activeOffer = null;
this._removeActive = null;
}

/// <summary>
/// Inserts the event.
/// </summary>
/// <param name="tradeEvent">The trade event.</param>
private void InsertEvent(TradeEvent tradeEvent)
{
using (var service = new Patreon.DatabaseService())
{
service.Insert(tradeEvent);
}
}

/// <summary>
/// Removes the offer.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Lurker.UI/ViewModels/PositionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

namespace Lurker.UI.ViewModels
{
using Lurker.Events;
using Lurker.Models;
using Lurker.Parser;
using Lurker.Patreon.Events;
using Lurker.Patreon.Models;
using Lurker.Patreon.Parsers;

public class PositionViewModel : Caliburn.Micro.PropertyChangedBase
{
Expand Down
1 change: 1 addition & 0 deletions src/Lurker.UI/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Lurker.UI
using Caliburn.Micro;
using Lurker.Helpers;
using Lurker.Models;
using Lurker.Patreon.Models;
using Lurker.Services;
using Lurker.UI.Helpers;
using Lurker.UI.Models;
Expand Down
4 changes: 2 additions & 2 deletions src/Lurker.UI/ViewModels/TradeValueViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Lurker.UI.ViewModels
{
using Lurker.Events;
using Lurker.Models;
using Lurker.Patreon.Events;
using Lurker.Patreon.Models;

public class TradeValueViewModel: Caliburn.Micro.PropertyChangedBase
{
Expand Down
Loading

0 comments on commit dadcbbf

Please sign in to comment.