Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkol committed Nov 28, 2019
1 parent 75496b7 commit 22731b4
Show file tree
Hide file tree
Showing 33 changed files with 10,514 additions and 9 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions Demos/angular-react-vue/ChromelyAppsSolution.sln
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2020
# Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChromelyAngularCefGlue", "ChromelyAngularCefGlue\ChromelyAngularCefGlue.csproj", "{81C6D3ED-B62E-49EC-886D-0140D6ACD0EF}"
EndProject
Project("{12f1ae00-4102-4b7c-84a5-6f63533433b5}") = "ChromelyAngularCefSharp", "ChromelyAngularCefSharp\ChromelyAngularCefSharp.csproj", "{15DCA414-80C7-415C-8DD7-D032054EB7BE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChromelyAngularCefSharp", "ChromelyAngularCefSharp\ChromelyAngularCefSharp.csproj", "{15DCA414-80C7-415C-8DD7-D032054EB7BE}"
EndProject
Project("{31f46184-da16-4acd-81bc-73aee672c45d}") = "ChromelyReactCefSharp", "ChromelyReactCefSharp\ChromelyReactCefSharp.csproj", "{A7012FC4-A631-4B62-957C-22E4668757D7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChromelyReactCefSharp", "ChromelyReactCefSharp\ChromelyReactCefSharp.csproj", "{A7012FC4-A631-4B62-957C-22E4668757D7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChromelyVueCefSharp", "ChromelyVueCefSharp\ChromelyVueCefSharp.csproj", "{A89DA9AB-D47A-41CF-BB8F-86776B85E32F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChromelyVueCefSharp", "ChromelyVueCefSharp\ChromelyVueCefSharp.csproj", "{A89DA9AB-D47A-41CF-BB8F-86776B85E32F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChromelyReactCefGlue", "ChromelyReactCefGlue\ChromelyReactCefGlue.csproj", "{762ADC29-1AED-4A6E-86D5-69B8ACC1FCB9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -43,6 +45,12 @@ Global
{A89DA9AB-D47A-41CF-BB8F-86776B85E32F}.Release|Any CPU.ActiveCfg = Release|x64
{A89DA9AB-D47A-41CF-BB8F-86776B85E32F}.Release|x64.ActiveCfg = Release|x64
{A89DA9AB-D47A-41CF-BB8F-86776B85E32F}.Release|x64.Build.0 = Release|x64
{762ADC29-1AED-4A6E-86D5-69B8ACC1FCB9}.Debug|Any CPU.ActiveCfg = Debug|x64
{762ADC29-1AED-4A6E-86D5-69B8ACC1FCB9}.Debug|x64.ActiveCfg = Debug|x64
{762ADC29-1AED-4A6E-86D5-69B8ACC1FCB9}.Debug|x64.Build.0 = Debug|x64
{762ADC29-1AED-4A6E-86D5-69B8ACC1FCB9}.Release|Any CPU.ActiveCfg = Release|x64
{762ADC29-1AED-4A6E-86D5-69B8ACC1FCB9}.Release|x64.ActiveCfg = Release|x64
{762ADC29-1AED-4A6E-86D5-69B8ACC1FCB9}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
79 changes: 79 additions & 0 deletions Demos/angular-react-vue/ChromelyReactCefGlue/App.cs
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;
}
}
}
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 &quot;$(ProjectDir)reactapp\dist&quot; &quot;$(TargetDir)dist&quot; /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>
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; }
}
}
14 changes: 14 additions & 0 deletions Demos/angular-react-vue/ChromelyReactCefGlue/Program.cs
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);
}
}
}
18 changes: 18 additions & 0 deletions Demos/angular-react-vue/ChromelyReactCefGlue/Startup.cs
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.
Loading

0 comments on commit 22731b4

Please sign in to comment.