Begin on Microsoft.Blazor.Browser project

This commit is contained in:
Steve Sanderson 2017-12-15 11:31:05 +00:00
parent 809528676b
commit d1069e2d1e
7 changed files with 74 additions and 6 deletions

View File

@ -52,6 +52,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Build", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Browser.JS", "src\Microsoft.Blazor.Browser.JS\Microsoft.Blazor.Browser.JS.csproj", "{8A19B1CE-9B62-4440-93B3-152DDBB39D0A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Blazor.Browser", "src\Microsoft.Blazor.Browser\Microsoft.Blazor.Browser.csproj", "{4874AFF4-335D-4037-8858-BBBB987C124B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -126,6 +128,10 @@ Global
{8A19B1CE-9B62-4440-93B3-152DDBB39D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A19B1CE-9B62-4440-93B3-152DDBB39D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A19B1CE-9B62-4440-93B3-152DDBB39D0A}.Release|Any CPU.Build.0 = Release|Any CPU
{4874AFF4-335D-4037-8858-BBBB987C124B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4874AFF4-335D-4037-8858-BBBB987C124B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4874AFF4-335D-4037-8858-BBBB987C124B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4874AFF4-335D-4037-8858-BBBB987C124B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -151,6 +157,7 @@ Global
{709C7EBE-EB93-4F6D-9491-D714B0D2E898} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
{8B3D0F1C-0E38-4E6D-BFF1-C4FDA0CD9815} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
{8A19B1CE-9B62-4440-93B3-152DDBB39D0A} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
{4874AFF4-335D-4037-8858-BBBB987C124B} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}

View File

@ -4,11 +4,10 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Blazor\Microsoft.Blazor.csproj" />
</ItemGroup>
<!-- Local alternative to <PackageReference Include="Microsoft.Blazor.Build" /> -->
<Import Project="..\..\src\Microsoft.Blazor.Build\ReferenceFromSource.props" />
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Blazor.Browser\Microsoft.Blazor.Browser.csproj" />
</ItemGroup>
</Project>

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.Blazor.Browser;
namespace HostedInAspNet.Client
{
@ -9,7 +9,7 @@ namespace HostedInAspNet.Client
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
new Renderer();
}
}
}

View File

@ -0,0 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.Blazor.Browser.Interop
{
public class JavaScriptException : Exception
{
internal JavaScriptException(string message) : base(message)
{
}
}
}

View File

@ -0,0 +1,28 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Blazor.Browser.Interop;
using System.Runtime.CompilerServices;
namespace WebAssembly
{
internal static class Runtime
{
public static string EvaluateJavaScript(string expression)
{
var result = InvokeJS(expression, out var resultIsException);
if (resultIsException != 0)
{
throw new JavaScriptException(result);
}
return result;
}
// The exact namespace, type, and method name must match the corresponding entry in
// driver.c in the Mono distribution
[MethodImpl(MethodImplOptions.InternalCall)]
static extern string InvokeJS(string str, out int resultIsException);
}
}

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Blazor.Browser
{
public class Renderer
{
public Renderer()
{
WebAssembly.Runtime.EvaluateJavaScript("console.log('Renderer'), 'done'");
}
}
}