Skip to content

Commit 4120007

Browse files
authored
Support for Blazor webassembly (#360)
* added linker config to make library work on mono project + added a webassembly blazor app whith some dynamic order by * correct codefactor issue correct codefactor issue
1 parent 9d5c560 commit 4120007

26 files changed

+1291
-0
lines changed

System.Linq.Dynamic.Core.sln

+21
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp_netcore2.1_Cosmo
7777
EndProject
7878
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp_net452_CosmosDb", "src-console\ConsoleApp_net452_CosmosDb\ConsoleApp_net452_CosmosDb.csproj", "{0034821E-740D-4553-821B-14CE9213C43C}"
7979
EndProject
80+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src-blazor", "src-blazor", "{122BC4FA-7563-4E35-9D17-077F16F1629F}"
81+
EndProject
82+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorAppTest", "src-blazor\BlazorAppTest\BlazorAppTest.csproj", "{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}"
83+
EndProject
8084
Global
8185
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8286
Debug|Any CPU = Debug|Any CPU
@@ -475,6 +479,22 @@ Global
475479
{0034821E-740D-4553-821B-14CE9213C43C}.Release|x64.Build.0 = Release|Any CPU
476480
{0034821E-740D-4553-821B-14CE9213C43C}.Release|x86.ActiveCfg = Release|Any CPU
477481
{0034821E-740D-4553-821B-14CE9213C43C}.Release|x86.Build.0 = Release|Any CPU
482+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
483+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
484+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Debug|ARM.ActiveCfg = Debug|Any CPU
485+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Debug|ARM.Build.0 = Debug|Any CPU
486+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Debug|x64.ActiveCfg = Debug|Any CPU
487+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Debug|x64.Build.0 = Debug|Any CPU
488+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Debug|x86.ActiveCfg = Debug|Any CPU
489+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Debug|x86.Build.0 = Debug|Any CPU
490+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
491+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Release|Any CPU.Build.0 = Release|Any CPU
492+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Release|ARM.ActiveCfg = Release|Any CPU
493+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Release|ARM.Build.0 = Release|Any CPU
494+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Release|x64.ActiveCfg = Release|Any CPU
495+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Release|x64.Build.0 = Release|Any CPU
496+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Release|x86.ActiveCfg = Release|Any CPU
497+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8}.Release|x86.Build.0 = Release|Any CPU
478498
EndGlobalSection
479499
GlobalSection(SolutionProperties) = preSolution
480500
HideSolutionNode = FALSE
@@ -504,6 +524,7 @@ Global
504524
{6D21EBF2-C92D-4AE0-9BC3-47C63928F88A} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
505525
{D160E2CF-A7E1-4DDE-9AB8-8CFB0087DCEB} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
506526
{0034821E-740D-4553-821B-14CE9213C43C} = {7971CAEB-B9F2-416B-966D-2D697C4C1E62}
527+
{CD80A3AC-B0E1-45ED-BE07-DE6A0F1D4CD8} = {122BC4FA-7563-4E35-9D17-077F16F1629F}
507528
EndGlobalSection
508529
GlobalSection(ExtensibilityGlobals) = postSolution
509530
SolutionGuid = {94C56722-194E-4B8B-BC23-B3F754E89A20}

src-blazor/BlazorAppTest/App.razor

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView Layout="@typeof(MainLayout)">
7+
<p>Sorry, there's nothing at this address.</p>
8+
</LayoutView>
9+
</NotFound>
10+
</Router>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<RazorLangVersion>3.0</RazorLangVersion>
6+
</PropertyGroup>
7+
8+
<PropertyGroup>
9+
<BlazorWebAssemblyEnableLinking>true</BlazorWebAssemblyEnableLinking>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview2.20160.5" />
14+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
15+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
16+
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview2.20160.5" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\src\System.Linq.Dynamic.Core\System.Linq.Dynamic.Core.csproj" />
21+
</ItemGroup>
22+
</Project>
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
@page "/"
2+
@inject HttpClient Http
3+
@using System.Linq.Dynamic.Core
4+
<h1>Weather forecast</h1>
5+
6+
<p>This component demonstrates fetching data from the server.</p>
7+
8+
@if (forecasts == null)
9+
{
10+
<p><em>Loading...</em></p>
11+
}
12+
else
13+
{
14+
<div class="d-flex">
15+
<h3>Order by</h3>
16+
<div class="form-inline ml-4">
17+
<div class="form-check form-check-inline">
18+
<input class="form-check-input" type="checkbox" name="rbOrder" id="cbOrder" checked="@isDescending" @onclick="@SetOrderingDirection">
19+
<label class="form-check-label" for="cbOrder">descending</label>
20+
</div>
21+
</div>
22+
</div>
23+
<div class="form-inline">
24+
@foreach (var member in typeof(WeatherForecast).GetProperties().Select(p => p.Name))
25+
{
26+
<div class="form-check form-check-inline">
27+
<input class="form-check-input" type="radio" name="rbOrder" id="@("rbOrder" + member)" checked="@(currentOrder == member)" @onchange="@((args) => SetOrder(member))">
28+
<label class="form-check-label" for="@("rbOrder" + member)">@member</label>
29+
</div>
30+
}
31+
</div>
32+
<table class="table">
33+
<thead>
34+
<tr>
35+
<th>Date</th>
36+
<th>Temp. (C)</th>
37+
<th>Temp. (F)</th>
38+
<th>Summary</th>
39+
</tr>
40+
</thead>
41+
<tbody>
42+
@foreach (var forecast in forecasts)
43+
{
44+
<tr>
45+
<td>@forecast.Date.ToShortDateString()</td>
46+
<td>@forecast.TemperatureC</td>
47+
<td>@forecast.TemperatureF</td>
48+
<td>@forecast.Summary</td>
49+
</tr>
50+
}
51+
</tbody>
52+
</table>
53+
}
54+
55+
@code {
56+
private WeatherForecast[] forecasts;
57+
private string currentOrder;
58+
private bool isDescending;
59+
60+
protected override async Task OnInitializedAsync()
61+
{
62+
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
63+
}
64+
65+
protected void SetOrder(string propertyName)
66+
{
67+
currentOrder = propertyName;
68+
Order();
69+
}
70+
71+
protected void SetOrderingDirection()
72+
{
73+
isDescending = !isDescending;
74+
Order();
75+
}
76+
77+
private void Order()
78+
{
79+
if (!string.IsNullOrEmpty(currentOrder))
80+
{
81+
forecasts = forecasts.AsQueryable().OrderBy($"{currentOrder} {(isDescending ? "descending" : "ascending")}").ToArray();
82+
}
83+
84+
}
85+
86+
87+
public class WeatherForecast
88+
{
89+
public DateTime Date { get; set; }
90+
91+
public int TemperatureC { get; set; }
92+
93+
public string Summary { get; set; }
94+
95+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
96+
}
97+
}

src-blazor/BlazorAppTest/Program.cs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using System.Text;
5+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
6+
using Microsoft.Extensions.DependencyInjection;
7+
8+
namespace BlazorAppTest
9+
{
10+
public class Program
11+
{
12+
public static async Task Main(string[] args)
13+
{
14+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
15+
builder.RootComponents.Add<App>("app");
16+
17+
builder.Services.AddBaseAddressHttpClient();
18+
19+
await builder.Build().RunAsync();
20+
}
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:7725",
7+
"sslPort": 44317
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"BlazorAppTest": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
}
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="sidebar">
4+
<NavMenu />
5+
</div>
6+
7+
<div class="main">
8+
<div class="top-row px-4">
9+
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
10+
</div>
11+
12+
<div class="content px-4">
13+
@Body
14+
</div>
15+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<div class="top-row pl-4 navbar navbar-dark">
2+
<a class="navbar-brand" href="">BlazorAppTest</a>
3+
<button class="navbar-toggler" @onclick="ToggleNavMenu">
4+
<span class="navbar-toggler-icon"></span>
5+
</button>
6+
</div>
7+
8+
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
9+
<ul class="nav flex-column">
10+
<li class="nav-item px-3">
11+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
12+
<span class="oi oi-home" aria-hidden="true"></span> Home
13+
</NavLink>
14+
</li>
15+
@*<li class="nav-item px-3">
16+
<NavLink class="nav-link" href="counter">
17+
<span class="oi oi-plus" aria-hidden="true"></span> Counter
18+
</NavLink>
19+
</li>
20+
<li class="nav-item px-3">
21+
<NavLink class="nav-link" href="fetchdata">
22+
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
23+
</NavLink>
24+
</li>*@
25+
</ul>
26+
</div>
27+
28+
@code {
29+
private bool collapseNavMenu = true;
30+
31+
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
32+
33+
private void ToggleNavMenu()
34+
{
35+
collapseNavMenu = !collapseNavMenu;
36+
}
37+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@using System.Net.Http
2+
@using Microsoft.AspNetCore.Components.Forms
3+
@using Microsoft.AspNetCore.Components.Routing
4+
@using Microsoft.AspNetCore.Components.Web
5+
@using Microsoft.JSInterop
6+
@using BlazorAppTest
7+
@using BlazorAppTest.Shared

src-blazor/BlazorAppTest/wwwroot/css/bootstrap/bootstrap.min.css

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-blazor/BlazorAppTest/wwwroot/css/bootstrap/bootstrap.min.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
SIL OPEN FONT LICENSE Version 1.1
2+
3+
Copyright (c) 2014 Waybury
4+
5+
PREAMBLE
6+
The goals of the Open Font License (OFL) are to stimulate worldwide
7+
development of collaborative font projects, to support the font creation
8+
efforts of academic and linguistic communities, and to provide a free and
9+
open framework in which fonts may be shared and improved in partnership
10+
with others.
11+
12+
The OFL allows the licensed fonts to be used, studied, modified and
13+
redistributed freely as long as they are not sold by themselves. The
14+
fonts, including any derivative works, can be bundled, embedded,
15+
redistributed and/or sold with any software provided that any reserved
16+
names are not used by derivative works. The fonts and derivatives,
17+
however, cannot be released under any other type of license. The
18+
requirement for fonts to remain under this license does not apply
19+
to any document created using the fonts or their derivatives.
20+
21+
DEFINITIONS
22+
"Font Software" refers to the set of files released by the Copyright
23+
Holder(s) under this license and clearly marked as such. This may
24+
include source files, build scripts and documentation.
25+
26+
"Reserved Font Name" refers to any names specified as such after the
27+
copyright statement(s).
28+
29+
"Original Version" refers to the collection of Font Software components as
30+
distributed by the Copyright Holder(s).
31+
32+
"Modified Version" refers to any derivative made by adding to, deleting,
33+
or substituting -- in part or in whole -- any of the components of the
34+
Original Version, by changing formats or by porting the Font Software to a
35+
new environment.
36+
37+
"Author" refers to any designer, engineer, programmer, technical
38+
writer or other person who contributed to the Font Software.
39+
40+
PERMISSION & CONDITIONS
41+
Permission is hereby granted, free of charge, to any person obtaining
42+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
43+
redistribute, and sell modified and unmodified copies of the Font
44+
Software, subject to the following conditions:
45+
46+
1) Neither the Font Software nor any of its individual components,
47+
in Original or Modified Versions, may be sold by itself.
48+
49+
2) Original or Modified Versions of the Font Software may be bundled,
50+
redistributed and/or sold with any software, provided that each copy
51+
contains the above copyright notice and this license. These can be
52+
included either as stand-alone text files, human-readable headers or
53+
in the appropriate machine-readable metadata fields within text or
54+
binary files as long as those fields can be easily viewed by the user.
55+
56+
3) No Modified Version of the Font Software may use the Reserved Font
57+
Name(s) unless explicit written permission is granted by the corresponding
58+
Copyright Holder. This restriction only applies to the primary font name as
59+
presented to the users.
60+
61+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
62+
Software shall not be used to promote, endorse or advertise any
63+
Modified Version, except to acknowledge the contribution(s) of the
64+
Copyright Holder(s) and the Author(s) or with their explicit written
65+
permission.
66+
67+
5) The Font Software, modified or unmodified, in part or in whole,
68+
must be distributed entirely under this license, and must not be
69+
distributed under any other license. The requirement for fonts to
70+
remain under this license does not apply to any document created
71+
using the Font Software.
72+
73+
TERMINATION
74+
This license becomes null and void if any of the above conditions are
75+
not met.
76+
77+
DISCLAIMER
78+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
79+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
80+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
81+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
82+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
83+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
84+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
85+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
86+
OTHER DEALINGS IN THE FONT SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Waybury
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

0 commit comments

Comments
 (0)