commit 554589a7dfe9c6047a9f6ae924fcc011543528c2 Author: cardidi Date: Tue Oct 15 00:12:12 2024 +0800 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..add57be --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +/packages/ +riderModule.iml +/_ReSharper.Caches/ \ No newline at end of file diff --git a/.idea/.idea.Flawless-Version-Control/.idea/.gitignore b/.idea/.idea.Flawless-Version-Control/.idea/.gitignore new file mode 100644 index 0000000..0939553 --- /dev/null +++ b/.idea/.idea.Flawless-Version-Control/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/.idea.Flawless-Version-Control.iml +/contentModel.xml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.Flawless-Version-Control/.idea/avalonia.xml b/.idea/.idea.Flawless-Version-Control/.idea/avalonia.xml new file mode 100644 index 0000000..caa4d57 --- /dev/null +++ b/.idea/.idea.Flawless-Version-Control/.idea/avalonia.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Flawless-Version-Control/.idea/encodings.xml b/.idea/.idea.Flawless-Version-Control/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.Flawless-Version-Control/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.Flawless-Version-Control/.idea/indexLayout.xml b/.idea/.idea.Flawless-Version-Control/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.Flawless-Version-Control/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Flawless-Version-Control/.idea/vcs.xml b/.idea/.idea.Flawless-Version-Control/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.Flawless-Version-Control/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Flawless-Version-Control.sln b/Flawless-Version-Control.sln new file mode 100644 index 0000000..e037c95 --- /dev/null +++ b/Flawless-Version-Control.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flawless.Shared", "Flawless.Shared\Flawless.Shared.csproj", "{825E512F-4283-4BE9-A88B-0316ED85796E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flawless.Client", "Flawless.Client\Flawless.Client.csproj", "{7F847931-55E5-4F00-93F6-81881BFC61FE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flawless.Client.Avanonia", "Flawless.Client.Avanonia\Flawless.Client.Avanonia.csproj", "{3901AE7A-27DA-4A43-9E22-6F64D812AC3E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flawless.Server", "Flawless.Server\Flawless.Server.csproj", "{17EA1F4E-7D4E-485D-BDB5-18BBC3FB8DF9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {825E512F-4283-4BE9-A88B-0316ED85796E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {825E512F-4283-4BE9-A88B-0316ED85796E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {825E512F-4283-4BE9-A88B-0316ED85796E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {825E512F-4283-4BE9-A88B-0316ED85796E}.Release|Any CPU.Build.0 = Release|Any CPU + {7F847931-55E5-4F00-93F6-81881BFC61FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F847931-55E5-4F00-93F6-81881BFC61FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F847931-55E5-4F00-93F6-81881BFC61FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F847931-55E5-4F00-93F6-81881BFC61FE}.Release|Any CPU.Build.0 = Release|Any CPU + {3901AE7A-27DA-4A43-9E22-6F64D812AC3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3901AE7A-27DA-4A43-9E22-6F64D812AC3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3901AE7A-27DA-4A43-9E22-6F64D812AC3E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3901AE7A-27DA-4A43-9E22-6F64D812AC3E}.Release|Any CPU.Build.0 = Release|Any CPU + {17EA1F4E-7D4E-485D-BDB5-18BBC3FB8DF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17EA1F4E-7D4E-485D-BDB5-18BBC3FB8DF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17EA1F4E-7D4E-485D-BDB5-18BBC3FB8DF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17EA1F4E-7D4E-485D-BDB5-18BBC3FB8DF9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Flawless.Client.Avanonia/App.axaml b/Flawless.Client.Avanonia/App.axaml new file mode 100644 index 0000000..c887737 --- /dev/null +++ b/Flawless.Client.Avanonia/App.axaml @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Flawless.Client.Avanonia/App.axaml.cs b/Flawless.Client.Avanonia/App.axaml.cs new file mode 100644 index 0000000..03f0f08 --- /dev/null +++ b/Flawless.Client.Avanonia/App.axaml.cs @@ -0,0 +1,33 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Data.Core; +using Avalonia.Data.Core.Plugins; +using Avalonia.Markup.Xaml; +using Flawless.Client.Avanonia.ViewModels; +using Flawless.Client.Avanonia.Views; + +namespace Flawless.Client.Avanonia; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + // Line below is needed to remove Avalonia data validation. + // Without this line you will get duplicate validations from both Avalonia and CT + BindingPlugins.DataValidators.RemoveAt(0); + desktop.MainWindow = new MainWindow + { + DataContext = new MainWindowViewModel(), + }; + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/Flawless.Client.Avanonia/Assets/avalonia-logo.ico b/Flawless.Client.Avanonia/Assets/avalonia-logo.ico new file mode 100644 index 0000000..da8d49f Binary files /dev/null and b/Flawless.Client.Avanonia/Assets/avalonia-logo.ico differ diff --git a/Flawless.Client.Avanonia/Flawless.Client.Avanonia.csproj b/Flawless.Client.Avanonia/Flawless.Client.Avanonia.csproj new file mode 100644 index 0000000..4616f60 --- /dev/null +++ b/Flawless.Client.Avanonia/Flawless.Client.Avanonia.csproj @@ -0,0 +1,25 @@ + + + WinExe + net8.0 + enable + true + app.manifest + true + + + + + + + + + + + + + + + + + diff --git a/Flawless.Client.Avanonia/Program.cs b/Flawless.Client.Avanonia/Program.cs new file mode 100644 index 0000000..1e9c4f5 --- /dev/null +++ b/Flawless.Client.Avanonia/Program.cs @@ -0,0 +1,21 @@ +using Avalonia; +using System; + +namespace Flawless.Client.Avanonia; + +sealed class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace(); +} \ No newline at end of file diff --git a/Flawless.Client.Avanonia/ViewLocator.cs b/Flawless.Client.Avanonia/ViewLocator.cs new file mode 100644 index 0000000..61549b2 --- /dev/null +++ b/Flawless.Client.Avanonia/ViewLocator.cs @@ -0,0 +1,32 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Flawless.Client.Avanonia.ViewModels; + +namespace Flawless.Client.Avanonia; + +public class ViewLocator : IDataTemplate +{ + public Control? Build(object? data) + { + if (data is null) + return null; + + var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); + var type = Type.GetType(name); + + if (type != null) + { + var control = (Control)Activator.CreateInstance(type)!; + control.DataContext = data; + return control; + } + + return new TextBlock { Text = "Not Found: " + name }; + } + + public bool Match(object? data) + { + return data is ViewModelBase; + } +} \ No newline at end of file diff --git a/Flawless.Client.Avanonia/ViewModels/MainWindowViewModel.cs b/Flawless.Client.Avanonia/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..08dc530 --- /dev/null +++ b/Flawless.Client.Avanonia/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,8 @@ +namespace Flawless.Client.Avanonia.ViewModels; + +public partial class MainWindowViewModel : ViewModelBase +{ +#pragma warning disable CA1822 // Mark members as static + public string Greeting => "Welcome to Avalonia!"; +#pragma warning restore CA1822 // Mark members as static +} \ No newline at end of file diff --git a/Flawless.Client.Avanonia/ViewModels/ViewModelBase.cs b/Flawless.Client.Avanonia/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..154c60b --- /dev/null +++ b/Flawless.Client.Avanonia/ViewModels/ViewModelBase.cs @@ -0,0 +1,7 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace Flawless.Client.Avanonia.ViewModels; + +public class ViewModelBase : ObservableObject +{ +} \ No newline at end of file diff --git a/Flawless.Client.Avanonia/Views/MainWindow.axaml b/Flawless.Client.Avanonia/Views/MainWindow.axaml new file mode 100644 index 0000000..ab1264d --- /dev/null +++ b/Flawless.Client.Avanonia/Views/MainWindow.axaml @@ -0,0 +1,20 @@ + + + + + + + + + + diff --git a/Flawless.Client.Avanonia/Views/MainWindow.axaml.cs b/Flawless.Client.Avanonia/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..9d1722d --- /dev/null +++ b/Flawless.Client.Avanonia/Views/MainWindow.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace Flawless.Client.Avanonia.Views; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Flawless.Client.Avanonia/app.manifest b/Flawless.Client.Avanonia/app.manifest new file mode 100644 index 0000000..ad7f15d --- /dev/null +++ b/Flawless.Client.Avanonia/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/Flawless.Client/Flawless.Client.csproj b/Flawless.Client/Flawless.Client.csproj new file mode 100644 index 0000000..bab7876 --- /dev/null +++ b/Flawless.Client/Flawless.Client.csproj @@ -0,0 +1,29 @@ + + + + net8.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + Server + Public + True + True + obj\Debug\net8.0\ + MSBuild:Compile + + + + diff --git a/Flawless.Client/Protos/greet.proto b/Flawless.Client/Protos/greet.proto new file mode 100644 index 0000000..78a1153 --- /dev/null +++ b/Flawless.Client/Protos/greet.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +option csharp_namespace = "Flawless.Server"; + +package greet; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply); +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings. +message HelloReply { + string message = 1; +} diff --git a/Flawless.Client/TestFlight.cs b/Flawless.Client/TestFlight.cs new file mode 100644 index 0000000..754543f --- /dev/null +++ b/Flawless.Client/TestFlight.cs @@ -0,0 +1,5 @@ +namespace Flawless.Client; + +public class TestFlight +{ +} \ No newline at end of file diff --git a/Flawless.Server/Flawless.Server.csproj b/Flawless.Server/Flawless.Server.csproj new file mode 100644 index 0000000..398a782 --- /dev/null +++ b/Flawless.Server/Flawless.Server.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + diff --git a/Flawless.Server/Program.cs b/Flawless.Server/Program.cs new file mode 100644 index 0000000..8ab227f --- /dev/null +++ b/Flawless.Server/Program.cs @@ -0,0 +1,16 @@ +using Flawless.Server.Services; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddGrpc(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +app.MapGrpcService(); +app.MapGet("/", + () => + "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"); + +app.Run(); \ No newline at end of file diff --git a/Flawless.Server/Properties/launchSettings.json b/Flawless.Server/Properties/launchSettings.json new file mode 100644 index 0000000..7a3f517 --- /dev/null +++ b/Flawless.Server/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5150", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7004;http://localhost:5150", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Flawless.Server/Protos/greet.proto b/Flawless.Server/Protos/greet.proto new file mode 100644 index 0000000..78a1153 --- /dev/null +++ b/Flawless.Server/Protos/greet.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +option csharp_namespace = "Flawless.Server"; + +package greet; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply); +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings. +message HelloReply { + string message = 1; +} diff --git a/Flawless.Server/Services/GreeterService.cs b/Flawless.Server/Services/GreeterService.cs new file mode 100644 index 0000000..9e7ab88 --- /dev/null +++ b/Flawless.Server/Services/GreeterService.cs @@ -0,0 +1,22 @@ +using Grpc.Core; +using Flawless.Server; + +namespace Flawless.Server.Services; + +public class GreeterService : Greeter.GreeterBase +{ + private readonly ILogger _logger; + + public GreeterService(ILogger logger) + { + _logger = logger; + } + + public override Task SayHello(HelloRequest request, ServerCallContext context) + { + return Task.FromResult(new HelloReply + { + Message = "Hello " + request.Name + }); + } +} \ No newline at end of file diff --git a/Flawless.Server/appsettings.Development.json b/Flawless.Server/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Flawless.Server/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Flawless.Server/appsettings.json b/Flawless.Server/appsettings.json new file mode 100644 index 0000000..1aef507 --- /dev/null +++ b/Flawless.Server/appsettings.json @@ -0,0 +1,14 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "Kestrel": { + "EndpointDefaults": { + "Protocols": "Http2" + } + } +} diff --git a/Flawless.Shared/Flawless.Shared.csproj b/Flawless.Shared/Flawless.Shared.csproj new file mode 100644 index 0000000..3a63532 --- /dev/null +++ b/Flawless.Shared/Flawless.Shared.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + +