This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project Sdk="Microsoft.NET.Sdk.Web"> | |
| <PropertyGroup> | |
| <TargetFramework>net5.0</TargetFramework> | |
| </PropertyGroup> | |
| <PropertyGroup> | |
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | |
| <NoWarn>$(NoWarn);1591</NoWarn> | |
| </PropertyGroup> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static IServiceCollection AddTokensServices(this IServiceCollection services, IConfiguration configuration) | |
| { | |
| var tokenConfig = new TokenConfiguration(); | |
| new ConfigureFromConfigurationOptions<TokenConfiguration>(configuration | |
| .GetSection("TokenConfiguration")) | |
| .Configure(tokenConfig); | |
| services.AddSingleton(tokenConfig); | |
| services.AddAuthentication(x => | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class RandomStringHelper | |
| { | |
| public static string RandomString(int length) | |
| { | |
| const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | |
| var res = new StringBuilder(); | |
| using (var rng = new RNGCryptoServiceProvider()) | |
| { | |
| byte[] uintBuffer = new byte[sizeof(uint)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<TResponse> GetAsJsonAsync<TResponse>(string uri) | |
| { | |
| var httpClient = new HttpClient(); | |
| var response = await httpClient.GetAsync(uri); | |
| if (!response.IsSuccessStatusCode) | |
| { | |
| throw new Exception(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public bool IsPointInPolygon(List<Location> poly, Location point) | |
| { | |
| int i, j; | |
| var c = false; | |
| for (i = 0, j = poly.Count - 1; i < poly.Count; j = i++) | |
| { | |
| if ((poly[i].Lt <= point.Lt && point.Lt < poly[j].Lt | |
| || poly[j].Lt <= point.Lt && point.Lt < poly[i].Lt) | |
| && point.Lg < (poly[j].Lg - poly[i].Lg) * (point.Lt - poly[i].Lt) | |
| / (poly[j].Lt - poly[i].Lt) + poly[i].Lg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public int GetDistanceStraightLine(double latOrg, double lngOrg, double latDest, double lngDest) | |
| { | |
| const double radius = 6378.137; | |
| var dLat = latDest * Math.PI / 180 - latOrg * Math.PI / 180; | |
| var dLng = lngDest * Math.PI / 180 - lngOrg * Math.PI / 180; | |
| var a = Math.Sin(dLat / 2) * | |
| Math.Sin(dLat / 2) + | |
| Math.Cos(latOrg * Math.PI / 180) * | |
| Math.Cos(latDest * Math.PI / 180) * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<Location> GetGeocoding(Address address) | |
| { | |
| var apiClient = new HttpClient(); | |
| var key = Environment.GetEnvironmentVariable("GOOGLE_KEY"); | |
| var addressToUse = BindAddress(address); | |
| var url = "https://maps.googleapis.com/maps/api/geocode/json?" + | |
| $"address={addressToUse}" + | |
| $"&language=pt-BR" + | |
| $"&key={key}"; |