Skip to content
This repository was archived by the owner on Jun 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Samples/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ packages/

# User-specific files
.vs/
.vscode/
*.suo
*.user
9 changes: 1 addition & 8 deletions Samples/BeanTrader/NetCore/BeanTrader.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28407.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeanTraderServer", "BeanTraderServer\BeanTraderServer.csproj", "{C7FE70DF-EF5A-4FED-91BE-9F6488C17135}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeanTraderClient", "BeanTraderClient\BeanTraderClient.csproj", "{995E758F-D656-4D2C-B679-69B81E58672F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeanTraderCommon", "BeanTraderInterfaces\BeanTraderCommon.csproj", "{41C7E011-840E-44AB-9B5B-CAF6E7B7DE65}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeanTraderClient.Core", "BeanTraderClient\BeanTraderClient.Core.csproj", "{2AECFB26-B510-46D0-91BC-790A9215767E}"
Expand All @@ -26,10 +23,6 @@ Global
{C7FE70DF-EF5A-4FED-91BE-9F6488C17135}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7FE70DF-EF5A-4FED-91BE-9F6488C17135}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7FE70DF-EF5A-4FED-91BE-9F6488C17135}.Release|Any CPU.Build.0 = Release|Any CPU
{995E758F-D656-4D2C-B679-69B81E58672F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{995E758F-D656-4D2C-B679-69B81E58672F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{995E758F-D656-4D2C-B679-69B81E58672F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{995E758F-D656-4D2C-B679-69B81E58672F}.Release|Any CPU.Build.0 = Release|Any CPU
{41C7E011-840E-44AB-9B5B-CAF6E7B7DE65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41C7E011-840E-44AB-9B5B-CAF6E7B7DE65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41C7E011-840E-44AB-9B5B-CAF6E7B7DE65}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task LoadAsync()
TradingService.Connected += LoadDataAsync;

// Get initial trader info and trade offers
await LoadDataAsync().ConfigureAwait(false);
await LoadDataAsync().ConfigureAwait(true);

// Register for service callbacks
CallbackHandler.AddNewTradeOfferHandler += AddTradeOffer;
Expand All @@ -60,8 +60,8 @@ public async Task LoadAsync()
public async Task UnloadAsync()
{
// Stop listening
await TradingService.StopListeningAsync().ConfigureAwait(false);
await TradingService.LogoutAsync().ConfigureAwait(false);
await TradingService.StopListeningAsync().ConfigureAwait(true);
await TradingService.LogoutAsync().ConfigureAwait(true);

// Unregister for service callbacks
CallbackHandler.AddNewTradeOfferHandler -= AddTradeOffer;
Expand Down Expand Up @@ -111,7 +111,7 @@ public async Task<string> GetTraderNameAsync(Guid sellerId)

if (!traderNames.TryGetValue(sellerId, out string traderName))
{
var names = await TradingService.GetTraderNamesAsync(new Guid[] { sellerId }).ConfigureAwait(false);
var names = await TradingService.GetTraderNamesAsync(new Guid[] { sellerId }).ConfigureAwait(true);

traderName = names.ContainsKey(sellerId) ?
traderNames.AddOrUpdate(sellerId, names[sellerId], (g, s) => names[sellerId]) :
Expand Down Expand Up @@ -170,14 +170,14 @@ private void OnPropertyChanged(string propertyName)

private async Task UpdateTraderInfoAsync()
{
CurrentTrader = await TradingService.GetCurrentTraderInfoAsync().ConfigureAwait(false);
CurrentTrader = await TradingService.GetCurrentTraderInfoAsync().ConfigureAwait(true);
}

private async Task LoadDataAsync()
{
await LoginAsync().ConfigureAwait(false);
await UpdateTraderInfoAsync().ConfigureAwait(false);
await ListenForTradeOffersAsync().ConfigureAwait(false);
await LoginAsync().ConfigureAwait(true);
await UpdateTraderInfoAsync().ConfigureAwait(true);
await ListenForTradeOffersAsync().ConfigureAwait(true);
}

private Task LoginAsync()
Expand Down Expand Up @@ -219,22 +219,22 @@ private async void TradeAccepted(TradeOffer offer, Guid buyerId)
{
if (offer.SellerId == CurrentTrader.Id)
{
SetStatus($"Trade ({offer}) accepted by {await GetTraderNameAsync(buyerId).ConfigureAwait(false) ?? buyerId.ToString()}");
await UpdateTraderInfoAsync().ConfigureAwait(false);
SetStatus($"Trade ({offer}) accepted by {await GetTraderNameAsync(buyerId).ConfigureAwait(true) ?? buyerId.ToString()}");
await UpdateTraderInfoAsync().ConfigureAwait(true);
}
}

public async Task<bool> CompleteTrade(TradeOffer tradeOffer)
{
var ownTrade = tradeOffer.SellerId == CurrentTrader.Id;
var success = ownTrade ?
await TradingService.CancelTradeOfferAsync(tradeOffer.Id).ConfigureAwait(false) :
await TradingService.AcceptTradeAsync(tradeOffer.Id).ConfigureAwait(false);
await TradingService.CancelTradeOfferAsync(tradeOffer.Id).ConfigureAwait(true) :
await TradingService.AcceptTradeAsync(tradeOffer.Id).ConfigureAwait(true);

if (success)
{
SetStatus($"{(ownTrade ? "Canceled" : "Accepted")} trade ({tradeOffer})");
await UpdateTraderInfoAsync().ConfigureAwait(false);
await UpdateTraderInfoAsync().ConfigureAwait(true);
}
else
{
Expand All @@ -261,12 +261,12 @@ public async Task ShowNewTradeOfferDialog()
DataContext = newTradeOfferViewModel
};

await DialogCoordinator.ShowMetroDialogAsync(this, newTradeDialog).ConfigureAwait(false);
await DialogCoordinator.ShowMetroDialogAsync(this, newTradeDialog).ConfigureAwait(true);
}

private async Task CreateTradeOfferAsync(TradeOffer tradeOffer)
{
if (await TradingService.OfferTradeAsync(tradeOffer).ConfigureAwait(false) != Guid.Empty)
if (await TradingService.OfferTradeAsync(tradeOffer).ConfigureAwait(true) != Guid.Empty)
{
SetStatus("New trade offer created");
}
Expand All @@ -275,7 +275,7 @@ private async Task CreateTradeOfferAsync(TradeOffer tradeOffer)
SetStatus("ERROR: Trade offer could not be created. Do you have enough beans?", Application.Current.FindResource("ErrorBrush") as Brush);
}

await UpdateTraderInfoAsync().ConfigureAwait(false);
await UpdateTraderInfoAsync().ConfigureAwait(true);
}

private void SetStatus(string message) => SetStatus(message, Application.Current.FindResource("IdealForegroundColorBrush") as Brush);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{41C7E011-840E-44AB-9B5B-CAF6E7B7DE65}</ProjectGuid>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BeanTraderInterfaces</RootNamespace>
<AssemblyName>BeanTraderInterfaces</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IBeanTrader.cs" />
<Compile Include="IBeanTraderCallback.cs" />
<Compile Include="Models\Beans.cs" />
<Compile Include="Models\TradeOffer.cs" />
<Compile Include="Models\Trader.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.Federation" Version="4.8.1" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.310801">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
37 changes: 1 addition & 36 deletions Samples/BeanTrader/NetCore/BeanTraderServer/App.config
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="beanTraderBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="BeanTraderServer.BeanTrader" behaviorConfiguration="beanTraderBehaviour">
<endpoint address="BeanTraderService" binding="netTcpBinding" bindingConfiguration="WindowsClient" contract="BeanTrader.IBeanTrader">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<!-- Requires: netsh http add urlacl url=http://+:8080/ user=REDMOND\mikerou -->
<add baseAddress="http://localhost:8080/" />
<add baseAddress="net.tcp://localhost:8090" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="WindowsClient">
<!-- Was going to use TransportWithMessageCredential security, but
that is not yet supported on .NET Core. https://github.com/dotnet/wcf/issues/8 -->
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
2 changes: 1 addition & 1 deletion Samples/BeanTrader/NetCore/BeanTraderServer/BeanTrader.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using BeanTrader;
using BeanTrader.Models;
using CoreWCF;
using Serilog;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.ServiceModel;
using System.Text;
using System.Threading;

Expand Down
81 changes: 19 additions & 62 deletions Samples/BeanTrader/NetCore/BeanTraderServer/BeanTraderServer.csproj
Original file line number Diff line number Diff line change
@@ -1,72 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C7FE70DF-EF5A-4FED-91BE-9F6488C17135}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>BeanTraderServer</RootNamespace>
<AssemblyName>BeanTraderServer</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.2.8.0\lib\net46\Serilog.dll</HintPath>
</Reference>
<Reference Include="Serilog.Sinks.Console, Version=3.1.1.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.Sinks.Console.3.1.1\lib\net45\Serilog.Sinks.Console.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BeanTrader.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="BeanTrader.pfx">
<None Update="BeanTrader.pfx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BeanTraderInterfaces\BeanTraderCommon.csproj">
<Project>{41C7E011-840E-44AB-9B5B-CAF6E7B7DE65}</Project>
<Name>BeanTraderCommon</Name>
</ProjectReference>
<ProjectReference Include="..\BeanTraderInterfaces\BeanTraderCommon.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreWCF.ConfigurationManager" Version="1.0.0" />
<PackageReference Include="CoreWCF.NetTcp" Version="1.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Serilog" Version="2.8.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.Federation" Version="4.8.1" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.310801">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Loading