-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Serverside Blazor Sample using RX.Net and DynamicData.
- Loading branch information
Showing
55 changed files
with
3,036 additions
and
554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Router AppAssembly="@typeof(Program).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
</Found> | ||
<NotFound> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
13 changes: 13 additions & 0 deletions
13
samples/Cortex.Net.BitcoinTicker/Components/ExchangeRateRow.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@using Cortex.Net.BitcoinTicker.Models | ||
|
||
<tr> | ||
<td>@ExchangeRate.Name (@ExchangeRate.Symbol)</td> | ||
<td>@($"{ExchangeRate.Value:N}")</td> | ||
<td>@($"{ExchangeRate.Min:N}")</td> | ||
<td>@($"{ExchangeRate.Max:N}")</td> | ||
</tr> | ||
|
||
@code { | ||
[Parameter] | ||
public ExchangeRate ExchangeRate { get; set; } | ||
} |
36 changes: 36 additions & 0 deletions
36
samples/Cortex.Net.BitcoinTicker/Cortex.Net.BitcoinTicker.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<OutputPath>bin\Debug</OutputPath> | ||
<DocumentationFile>bin\Debug\netcoreapp3.1\BitcoinTicker.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Remove="stylecop.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AdditionalFiles Include="stylecop.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview1.20073.1" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="System.Reactive" Version="4.3.2" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Cortex.Net.Blazor\Cortex.Net.Blazor.csproj" /> | ||
<ProjectReference Include="..\..\src\Cortex.Net.DynamicData\Cortex.Net.DynamicData.csproj" /> | ||
<ProjectReference Include="..\..\src\Cortex.Net\Cortex.Net.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<WeaverFiles Include="$(SolutionDir)src\Cortex.Net.Fody\bin\$(Configuration)\netstandard2.0\Cortex.Net.Fody.dll" WeaverClassNames="ModuleWeaver" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<ModuleWeaver /> | ||
</Weavers> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> | ||
<xs:element name="Weavers"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element name="ModuleWeaver" minOccurs="0" maxOccurs="1" type="xs:anyType" /> | ||
</xs:all> | ||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="GenerateXsd" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// <copyright file="ExchangeRate.cs" company="Jan-Willem Spuij"> | ||
// Copyright 2019 Jan-Willem Spuij | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | ||
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom | ||
// the Software is furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// </copyright> | ||
|
||
namespace Cortex.Net.BitcoinTicker.Models | ||
{ | ||
using Cortex.Net.Api; | ||
|
||
/// <summary> | ||
/// Observable Ticker item. | ||
/// </summary> | ||
[Observable] | ||
public class ExchangeRate | ||
{ | ||
/// <summary> | ||
/// Gets or sets the name of the exchange rate. | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the symbol of the exchange rate. | ||
/// </summary> | ||
public string Symbol { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the value of the echange rate. | ||
/// </summary> | ||
public decimal Value { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the min value of the exchange rate. | ||
/// </summary> | ||
public decimal Min { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the max value of the exchange rate. | ||
/// </summary> | ||
public decimal Max { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// <copyright file="Transaction.cs" company="Jan-Willem Spuij"> | ||
// Copyright 2019 Jan-Willem Spuij | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | ||
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom | ||
// the Software is furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// </copyright> | ||
|
||
namespace Cortex.Net.BitcoinTicker.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Cortex.Net.Api; | ||
|
||
/// <summary> | ||
/// A bitcoin transaction. | ||
/// </summary> | ||
[Observable] | ||
public class Transaction | ||
{ | ||
/// <summary> | ||
/// Gets or sets the Hash. | ||
/// </summary> | ||
public string Hash { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the time of the transaction. | ||
/// </summary> | ||
public DateTime Time { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the amount in BTC. | ||
/// </summary> | ||
public decimal Amount { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@page "/" | ||
@using BitcoinTicker.Store | ||
@using Cortex.Net.Api | ||
@using Cortex.Net.Blazor | ||
|
||
@attribute [Observer] | ||
@inject TickerStore TickerStore | ||
|
||
<h1>Bitcoin.info exchange rates.</h1> | ||
|
||
@if (this.FilteredRates.Any()) | ||
{ | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<td>Currency</td> | ||
<td>Last</td> | ||
<td>Min</td> | ||
<td>Max</td> | ||
</tr> | ||
<tr> | ||
<td><input @bind-value="FilterText" @bind-value:event="oninput" /></td> | ||
<td> </td> | ||
<td> </td> | ||
<td> </td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var keyValuePair in this.FilteredRates) | ||
{ | ||
<ExchangeRateRow @key="keyValuePair.Key" ExchangeRate="keyValuePair.Value" /> | ||
} | ||
</tbody> | ||
<tfoot> | ||
<tr> | ||
<td colspan="4">Number of exchange rates: @this.FilteredRates.Count()</td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
} | ||
else | ||
{ | ||
<p>There are no exchange rates.</p> | ||
<p>@TickerStore.ErrorMessage</p> | ||
} | ||
|
||
|
||
@code | ||
{ | ||
[Computed] | ||
public IEnumerable<KeyValuePair<string, Models.ExchangeRate>> FilteredRates => this.TickerStore.ExchangeRates.Where(x => FilterText == null || x.Key.StartsWith(FilterText)); | ||
|
||
[Observable] | ||
public string FilterText { get; set; } | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
@page "/transactions" | ||
@page "/transactions/{PageIndex:int}" | ||
@using BitcoinTicker.Store | ||
@using BitcoinTicker.Models | ||
@using Cortex.Net.Api | ||
@using Cortex.Net.Blazor | ||
|
||
@attribute [Observer] | ||
@inject TransactionStore TransactionStore | ||
|
||
<h1>Bitcoin.info unconfirmed transactions.</h1> | ||
|
||
|
||
@if (this.TransactionStore.Transactions.Any()) | ||
{ | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<td>Hash</td> | ||
<td>Time</td> | ||
<td>Amount (BTC)</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var transaction in this.PagedTransactions) | ||
{ | ||
<tr> | ||
<td @key="transaction.Hash">@transaction.Hash</td> | ||
<td>@($"{transaction.Time:t}")</td> | ||
<td>@($"{transaction.Amount:N8}")</td> | ||
</tr> | ||
} | ||
</tbody> | ||
<tfoot> | ||
<tr> | ||
<td> | ||
@foreach (int pagenr in Pages) | ||
{ | ||
<NavLink href="@($"/transactions/{pagenr}")">@pagenr</NavLink> | ||
} | ||
</td> | ||
<td>Number of transactions: @this.TransactionStore.Transactions.Count()</td> | ||
<td>PageSize: <input type="number" @bind-value="PageSize" /></td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
} | ||
else | ||
{ | ||
<p>There are no transactions.</p> | ||
<p>@TransactionStore.ErrorMessage</p> | ||
} | ||
|
||
@code | ||
{ | ||
[Computed] | ||
public IEnumerable<Transaction> PagedTransactions => this.TransactionStore.Transactions.Skip((PageIndex - 1) * PageSize).Take(PageSize); | ||
|
||
[Observable] | ||
[Parameter] | ||
public int PageIndex { get; set; } | ||
|
||
[Observable] | ||
public int PageSize { get; set; } | ||
|
||
[Computed] | ||
public IEnumerable<int> Pages => Enumerable.Range(1, this.TransactionStore.Transactions.Count > 0 ? this.TransactionStore.Transactions.Count / PageSize : 1); | ||
|
||
protected override void OnInitialized() | ||
{ | ||
base.OnInitialized(); | ||
PageSize = 20; | ||
PageIndex = 1; | ||
} | ||
} |
Oops, something went wrong.