From 88f7c7b646c289d96d79a93a4de11d8ce58a3b62 Mon Sep 17 00:00:00 2001 From: Gian Luca Da Silva Figueiredo Date: Tue, 15 Oct 2024 10:17:02 -0300 Subject: [PATCH] =?UTF-8?q?[GMH]=20Melhorias=20de=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iso.gmh.desktop/ViewModel/AboutViewModel.cs | 15 +- iso.gmh.dropbox/DropboxConnection.cs | 13 +- .../Properties/Resources.Designer.cs | 99 +++++++++++++ iso.gmh.dropbox/Properties/Resources.resx | 132 ++++++++++++++++++ iso.gmh.dropbox/iso.gmh.dropbox.csproj | 13 ++ 5 files changed, 257 insertions(+), 15 deletions(-) create mode 100644 iso.gmh.dropbox/Properties/Resources.Designer.cs create mode 100644 iso.gmh.dropbox/Properties/Resources.resx diff --git a/iso.gmh.desktop/ViewModel/AboutViewModel.cs b/iso.gmh.desktop/ViewModel/AboutViewModel.cs index dc4323f..ff05c52 100644 --- a/iso.gmh.desktop/ViewModel/AboutViewModel.cs +++ b/iso.gmh.desktop/ViewModel/AboutViewModel.cs @@ -9,17 +9,14 @@ public partial class AboutViewModel : BaseViewModel { public string Desenvolvedor { get; } = Resources.EMPRESA; - public ICommand GitHubCommand { get; set; } = new RelayCommand(_ => OpenWebsite(Resources.GITHUB)); - public ICommand LinkedInCommand { get; set; } = new RelayCommand(_ => OpenWebsite(Resources.LINKEDIN)); + public ICommand GitHubCommand { get; } = new RelayCommand(static _ => OpenWebsite(Resources.GITHUB)); + public ICommand LinkedInCommand { get; } = new RelayCommand(static _ => OpenWebsite(Resources.LINKEDIN)); private static void OpenWebsite( string url - ) + ) => Process.Start(new ProcessStartInfo { - _ = Process.Start(new ProcessStartInfo - { - FileName = url, - UseShellExecute = true - }); - } + FileName = url, + UseShellExecute = true + }); } \ No newline at end of file diff --git a/iso.gmh.dropbox/DropboxConnection.cs b/iso.gmh.dropbox/DropboxConnection.cs index 206d1c1..3ef5f22 100644 --- a/iso.gmh.dropbox/DropboxConnection.cs +++ b/iso.gmh.dropbox/DropboxConnection.cs @@ -12,19 +12,20 @@ using iso.gmh.Core.Interfaces; using iso.gmh.Core.Models; +using iso.gmh.dropbox.Properties; public class DropboxConnection : IConnection { - private const string LoopbackHostPrefix = "http://127.0.0.1:52475/"; - private readonly Uri JSRedirectUri = new(LoopbackHostPrefix + "token"); - private readonly Uri RedirectUri = new(LoopbackHostPrefix + "authorize"); + private const string Format = "N"; + private readonly Uri JSRedirectUri = new(Resources.LOOPBACK_HOST + Resources.TOKEN); + private readonly Uri RedirectUri = new(Resources.LOOPBACK_HOST + Resources.AUTHORIZE); private async Task GetAccessToken( string appKey ) { var OAuthFlow = new PKCEOAuthFlow(); - string state = Guid.NewGuid().ToString("N"); + string state = Guid.NewGuid().ToString(Format); Uri authorizeUri = OAuthFlow.GetAuthorizeUri( OAuthResponseType.Code, @@ -37,7 +38,7 @@ string appKey ); using var listener = new HttpListener(); - listener.Prefixes.Add(LoopbackHostPrefix); + listener.Prefixes.Add(Resources.LOOPBACK_HOST); listener.Start(); @@ -104,7 +105,7 @@ Secrets secrets secrets.AppKey, secrets.AppSecret, new DropboxClientConfig( - "Game Management Helper", + Resources.APP_NAME, 5 ) { HttpClient = new HttpClient { Timeout = TimeSpan.FromMinutes(20) } } diff --git a/iso.gmh.dropbox/Properties/Resources.Designer.cs b/iso.gmh.dropbox/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b15d6b5 --- /dev/null +++ b/iso.gmh.dropbox/Properties/Resources.Designer.cs @@ -0,0 +1,99 @@ +//------------------------------------------------------------------------------ +// +// O código foi gerado por uma ferramenta. +// Versão de Tempo de Execução:4.0.30319.42000 +// +// As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se +// o código for gerado novamente. +// +//------------------------------------------------------------------------------ + +namespace iso.gmh.dropbox.Properties { + using System; + + + /// + /// Uma classe de recurso de tipo de alta segurança, para pesquisar cadeias de caracteres localizadas etc. + /// + // Essa classe foi gerada automaticamente pela classe StronglyTypedResourceBuilder + // através de uma ferramenta como ResGen ou Visual Studio. + // Para adicionar ou remover um associado, edite o arquivo .ResX e execute ResGen novamente + // com a opção /str, ou recrie o projeto do VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Retorna a instância de ResourceManager armazenada em cache usada por essa classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("iso.gmh.dropbox.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Substitui a propriedade CurrentUICulture do thread atual para todas as + /// pesquisas de recursos que usam essa classe de recurso de tipo de alta segurança. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a Game Management Helper. + /// + internal static string APP_NAME { + get { + return ResourceManager.GetString("APP_NAME", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a authorize. + /// + internal static string AUTHORIZE { + get { + return ResourceManager.GetString("AUTHORIZE", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a http://127.0.0.1:52475/. + /// + internal static string LOOPBACK_HOST { + get { + return ResourceManager.GetString("LOOPBACK_HOST", resourceCulture); + } + } + + /// + /// Consulta uma cadeia de caracteres localizada semelhante a token. + /// + internal static string TOKEN { + get { + return ResourceManager.GetString("TOKEN", resourceCulture); + } + } + } +} diff --git a/iso.gmh.dropbox/Properties/Resources.resx b/iso.gmh.dropbox/Properties/Resources.resx new file mode 100644 index 0000000..ab82746 --- /dev/null +++ b/iso.gmh.dropbox/Properties/Resources.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + token + + + http://127.0.0.1:52475/ + + + authorize + + + Game Management Helper + + \ No newline at end of file diff --git a/iso.gmh.dropbox/iso.gmh.dropbox.csproj b/iso.gmh.dropbox/iso.gmh.dropbox.csproj index 68cbf18..debf0e7 100644 --- a/iso.gmh.dropbox/iso.gmh.dropbox.csproj +++ b/iso.gmh.dropbox/iso.gmh.dropbox.csproj @@ -46,4 +46,17 @@ ..\resources\KapiCoreLib.Desktop.dll + + + True + True + Resources.resx + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + \ No newline at end of file