This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
10,514 additions
and
9 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
Demos/angular-react-vue/ChromelyAngularCefGlue/angularapp/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,79 @@ | ||
using Chromely.CefGlue; | ||
using Chromely.CefGlue.Winapi; | ||
using Chromely.Core; | ||
using Chromely.Core.Host; | ||
using Chromely.Core.Infrastructure; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace ChromelyReactCefGlue | ||
{ | ||
public class App | ||
{ | ||
public int Run(string[] args) | ||
{ | ||
try | ||
{ | ||
HostHelpers.SetupDefaultExceptionHandlers(); | ||
|
||
string startUrl = "local://dist/index.html"; | ||
|
||
ChromelyConfiguration config = ChromelyConfiguration | ||
.Create() | ||
.UseDefaultSubprocess() | ||
.WithDebuggingMode(true) | ||
.WithAppArgs(args) | ||
.WithHostBounds(1200, 900) | ||
.WithHostMode(WindowState.Maximize) | ||
.WithHostTitle("ChromelyReactCefGlue") | ||
.WithHostIconFile("chromely.ico") | ||
.WithStartUrl(startUrl) | ||
.WithLogFile("logs\\ChromelyReactCefGlue.log") | ||
.WithLogSeverity(LogSeverity.Info) | ||
.UseDefaultLogger("logs\\ChromelyReactCefGlue.log") | ||
.UseDefaultResourceSchemeHandler("local", string.Empty); | ||
|
||
using (var window = ChromelyWindow.Create(config)) | ||
{ | ||
// Register external url schems | ||
window.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true)); | ||
|
||
// window.RegisterUrlScheme(new UrlScheme("https://google.com", true)); | ||
|
||
/* | ||
* Register service assemblies | ||
* Uncomment relevant part to register assemblies | ||
*/ | ||
|
||
// 1. Register current/local assembly: | ||
window.RegisterServiceAssembly(Assembly.GetExecutingAssembly()); | ||
|
||
// 2. Register external assembly with file name: | ||
// string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll"; | ||
// window.RegisterServiceAssembly(serviceAssemblyFile); | ||
|
||
// 3. Register external assemblies with list of filenames: | ||
// string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll"; | ||
// List<string> filenames = new List<string>(); | ||
// filenames.Add(serviceAssemblyFile1); | ||
// window.RegisterServiceAssemblies(filenames); | ||
|
||
// 4. Register external assemblies directory: | ||
// string serviceAssembliesFolder = @"C:\ChromelyDlls"; | ||
// window.RegisterServiceAssemblies(serviceAssembliesFolder); | ||
|
||
// Scan assemblies for Controller routes | ||
window.ScanAssemblies(); | ||
|
||
return window.Run(args); | ||
} | ||
} | ||
catch (Exception exception) | ||
{ | ||
Log.Error(exception); | ||
} | ||
|
||
return 0; | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
Demos/angular-react-vue/ChromelyReactCefGlue/ChromelyReactCefGlue.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,78 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> | ||
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion> | ||
<IsPackable>false</IsPackable> | ||
<Platforms>x64</Platforms> | ||
<ApplicationIcon>chromely.ico</ApplicationIcon> | ||
<AssemblyName>ChromelyReactCefGlue</AssemblyName> | ||
<StartupObject>ChromelyReactCefGlue.Program</StartupObject> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="reactapp\node_modules\**" /> | ||
<EmbeddedResource Remove="reactapp\node_modules\**" /> | ||
<None Remove="reactapp\node_modules\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="chromely.ico"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Chromely.CefGlue" Version="4.0.70.1" /> | ||
<PackageReference Include="Chromely.CefGlue.Winapi" Version="4.0.70.1" /> | ||
<PackageReference Include="Chromely.Core" Version="4.0.0.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.4" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" /> | ||
</ItemGroup> | ||
|
||
<Target Name="DependsOn" DependsOnTargets="ValidateChromelyApp"> | ||
<Message Text="Target : DependsOn" /> | ||
</Target> | ||
|
||
<Target Name="ValidateChromelyApp" BeforeTargets="Build"> | ||
<Message Importance="High" Text="Checking if Node.js is installed.." /> | ||
<Exec Command="node --version" ContinueOnError="false"> | ||
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> | ||
</Exec> | ||
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." /> | ||
<Message Condition="'$(ErrorCode)' == '0'" Importance="High" Text="Node.js is installed!" /> | ||
|
||
<Message Importance="High" Text="Checking if node_modules exists.." /> | ||
<Message Importance="High" Text="Running npm install, node_modules not found! (this could take a while)" Condition="!Exists('$(ProjectDir)reactapp\node_modules')" /> | ||
<Exec Command="npm install --silent" Condition="!Exists('$(ProjectDir)reactapp\node_modules')" WorkingDirectory="reactapp" ContinueOnError="false" /> | ||
</Target> | ||
|
||
<Target Name="DebugChromelyApp" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' "> | ||
<Message Importance="High" Text="Building React App.." /> | ||
<Exec Command="npm run build" WorkingDirectory="reactapp" ContinueOnError="false" ConsoleToMSBuild="true"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" /> | ||
</Exec> | ||
|
||
<Message Importance="High" Text="Copying React App to debug folder.." /> | ||
<Exec Command="xcopy "$(ProjectDir)reactapp\dist" "$(TargetDir)dist" /i /s /r /y /c" /> | ||
</Target> | ||
|
||
<Target Name="ReleaseChromelyApp" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Release' "> | ||
<Exec Command="npm run prod" WorkingDirectory="reactapp" ContinueOnError="true" ConsoleToMSBuild="false"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" /> | ||
</Exec> | ||
</Target> | ||
|
||
<Target Name="FilterCopyLocalItems" AfterTargets="ResolveLockFileCopyLocalProjectDeps"> | ||
<ItemGroup> | ||
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(Filename)' != 'Chromely.CefGlue' AND '%(Filename)' != 'Chromely.CefGlue.Winapi' AND '%(Filename)' != 'Chromely.Core' AND '%(Filename)' != 'Microsoft.Extensions.Configuration' AND '%(Filename)' != 'Microsoft.Extensions.Configuration.Binder' AND '%(Filename)' != 'Microsoft.Extensions.Configuration.Json' AND '%(Filename)' != 'Microsoft.Extensions.DependencyInjection'" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
</Project> |
140 changes: 140 additions & 0 deletions
140
Demos/angular-react-vue/ChromelyReactCefGlue/Controllers/DemoController.cs
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,140 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Chromely.Core.RestfulService; | ||
|
||
namespace ChromelyReactCefGlue.Controllers | ||
{ | ||
/// <summary> | ||
/// The demo controller. | ||
/// </summary> | ||
[ControllerProperty(Name = "DemoController", Route = "democontroller")] | ||
public class DemoController : ChromelyController | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DemoController"/> class. | ||
/// </summary> | ||
public DemoController() | ||
{ | ||
this.RegisterGetRequest("/democontroller/movies", this.GetMovies); | ||
this.RegisterPostRequest("/democontroller/movies", this.SaveMovies); | ||
} | ||
|
||
/// <summary> | ||
/// The get movies. | ||
/// </summary> | ||
/// <param name="request"> | ||
/// The request. | ||
/// </param> | ||
/// <returns> | ||
/// The <see cref="ChromelyResponse"/>. | ||
/// </returns> | ||
private ChromelyResponse GetMovies(ChromelyRequest request) | ||
{ | ||
List<MovieInfo> movieInfos = new List<MovieInfo>(); | ||
string assemblyName = typeof(MovieInfo).Assembly.GetName().Name; | ||
|
||
movieInfos.Add(new MovieInfo(id: 1, title: "The Shawshank Redemption", year: 1994, votes: 678790, rating: 9.2, assembly: assemblyName)); | ||
movieInfos.Add(new MovieInfo(id: 2, title: "The Godfather", year: 1972, votes: 511495, rating: 9.2, assembly: assemblyName)); | ||
movieInfos.Add(new MovieInfo(id: 3, title: "The Godfather: Part II", year: 1974, votes: 319352, rating: 9.0, assembly: assemblyName)); | ||
movieInfos.Add(new MovieInfo(id: 4, title: "The Good, the Bad and the Ugly", year: 1966, votes: 213030, rating: 8.9, assembly: assemblyName)); | ||
movieInfos.Add(new MovieInfo(id: 5, title: "My Fair Lady", year: 1964, votes: 533848, rating: 8.9, assembly: assemblyName)); | ||
movieInfos.Add(new MovieInfo(id: 6, title: "12 Angry Men", year: 1957, votes: 164558, rating: 8.9, assembly: assemblyName)); | ||
|
||
ChromelyResponse response = new ChromelyResponse(); | ||
response.Data = movieInfos; | ||
return response; | ||
} | ||
|
||
/// <summary> | ||
/// The save movies. | ||
/// </summary> | ||
/// <param name="request"> | ||
/// The request. | ||
/// </param> | ||
/// <returns> | ||
/// The <see cref="ChromelyResponse"/>. | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// ArgumentNullException - request is null exception. | ||
/// </exception> | ||
/// <exception cref="Exception"> | ||
/// Exception - post data is null exception. | ||
/// </exception> | ||
private ChromelyResponse SaveMovies(ChromelyRequest request) | ||
{ | ||
if (request == null) | ||
{ | ||
throw new ArgumentNullException(nameof(request)); | ||
} | ||
|
||
if (request.PostData == null) | ||
{ | ||
throw new Exception("Post data is null or invalid."); | ||
} | ||
|
||
ChromelyResponse response = new ChromelyResponse(); | ||
var postDataJson = request.PostData.EnsureJson(); | ||
int rowsReceived = postDataJson.ArrayCount(); | ||
|
||
response.Data = $"{rowsReceived} rows of data successfully saved."; | ||
|
||
return response; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The movie info. | ||
/// </summary> | ||
// ReSharper disable once StyleCop.SA1402 | ||
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Reviewed. Suppression is OK here.")] | ||
[SuppressMessage("ReSharper", "StyleCop.SA1600")] | ||
public class MovieInfo | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MovieInfo"/> class. | ||
/// </summary> | ||
/// <param name="id"> | ||
/// The id. | ||
/// </param> | ||
/// <param name="title"> | ||
/// The title. | ||
/// </param> | ||
/// <param name="year"> | ||
/// The year. | ||
/// </param> | ||
/// <param name="votes"> | ||
/// The votes. | ||
/// </param> | ||
/// <param name="rating"> | ||
/// The rating. | ||
/// </param> | ||
/// <param name="assembly"> | ||
/// The assembly. | ||
/// </param> | ||
public MovieInfo(int id, string title, int year, int votes, double rating, string assembly) | ||
{ | ||
this.Id = id; | ||
this.Title = title; | ||
this.Year = year; | ||
this.Votes = votes; | ||
this.Rating = rating; | ||
this.Date = DateTime.Now; | ||
this.RestfulAssembly = assembly; | ||
} | ||
|
||
public int Id { get; set; } | ||
|
||
public string Title { get; set; } | ||
|
||
public int Year { get; set; } | ||
|
||
public int Votes { get; set; } | ||
|
||
public double Rating { get; set; } | ||
|
||
public DateTime Date { get; set; } | ||
|
||
public string RestfulAssembly { 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,14 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ChromelyReactCefGlue | ||
{ | ||
class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
var services = new ServiceCollection(); | ||
Startup.ConfigureServices(services); | ||
return Startup.Start(services, args); | ||
} | ||
} | ||
} |
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,18 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ChromelyReactCefGlue | ||
{ | ||
public class Startup | ||
{ | ||
public static void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddTransient<App>(); | ||
} | ||
|
||
public static int Start(IServiceCollection services, string[] args) | ||
{ | ||
var provider = services.BuildServiceProvider(); | ||
return provider.GetService<App>().Run(args); | ||
} | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.