thangchung / blog-core

Modular blog using Blazor with clean domain-driven design patterns
MIT License
407 stars 124 forks source link

Blazor for the project #21

Open thangchung opened 5 years ago

thangchung commented 5 years ago

The Blazor road map with a lot of features need to investigate https://github.com/aspnet/AspNetCore/issues/8177

And priority items to work on: https://github.com/aspnet/AspNetCore.Docs/projects/35#card-23892118

What news with Blazor: Docs and .NET Core 3.0 Preview 6 news

Microsoft samples:

Blazor features:

Blazor validation & FluentValidation:

UI:

Real projects:

thangchung commented 5 years ago

SQL Server with docker-compose guidance at https://docs.docker.com/compose/aspnet-mssql-compose/

thangchung commented 5 years ago

Authn & Authz https://gist.github.com/SteveSandersonMS/175a08dcdccb384a52ba760122cd2eda

thangchung commented 5 years ago

State management discussion and libs at https://github.com/aspnet/AspNetCore/issues/5467

thangchung commented 5 years ago

Support Rest actions for current HttpClient. The same at https://github.com/aspnet/AspNetCore/blob/a6bc6ce23dad5a9d02596cf2e91e3c4f965c61bc/src/Components/Components/src/HttpClientJsonExtensions.cs

thangchung commented 5 years ago

Trying with SSR with Blazor so that we can be easy to do debug and other stuffs

thangchung commented 5 years ago

State management (circuit) for blazor at https://gist.github.com/SteveSandersonMS/ba16f6bb6934842d78c89ab5314f4b56

thangchung commented 5 years ago

Staring at Grpc.Net.Client, tried it but still got an error when run with .NET Standard 2.1. Example at https://github.com/heikovetter/BlazorGrpcSample. With this coming lib, we can set up gRPC service on the server and use Grpc.Net.Client to call to the server through HttpContext integrated with gRPC, just like an example at https://github.com/grpc/grpc-dotnet/blob/master/examples/Clients/Ticketer/Program.cs

Cool thing for gRPC on DataContract at https://github.com/protobuf-net/protobuf-net.Grpc

thangchung commented 5 years ago
/// <summary>
/// Ref to https://github.com/GoogleCloudPlatform/dotnet-docs-samples/blob/8a942cae26/monitoring/api/AlertSample/Program.cs
/// </summary>
public class ProtoMessageConverter : JsonConverter
{
    public override bool CanConvert(Type objectType)
    {
        return typeof(IMessage).IsAssignableFrom(objectType);
    }

    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        var converter = new ExpandoObjectConverter();
        var o = converter.ReadJson(reader, objectType, existingValue, serializer);

        var text = JsonConvert.SerializeObject(o);

        var message = (IMessage)Activator.CreateInstance(objectType);
        return JsonParser.Default.Parse(text, message.Descriptor);
    }

    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
    {
        writer.WriteRawValue(JsonFormatter.Default.Format((IMessage)value));
    }
}

Usage:

JsonConvert.SerializeObject(data, new ProtoMessageConverter());
var data = JsonConvert.SerializeObject<TData>(data, new ProtoMessageConverter());