Skip to content

Instantly share code, notes, and snippets.

View diegodfsd's full-sized avatar
🎯
Focusing

Diego Dias diegodfsd

🎯
Focusing
View GitHub Profile
public class CreateTenantCommand : ICommand
{
public string Name { get; }
public string Description { get; }
public Status Status { get; }
public string Hostname { get; }
public CreateTenantCommand(string hostname, string name, string description, Status status)
{
Hostname = hostname;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Xgen.Common.Extensions;
using Xgen.Common.Utils;
using Xgen.Domain.Common;
using Xgen.Domain.Common.Exceptions;
using Xgen.Domain.Model.Social.Events;
using Xgen.Domain.Model.Social.Exceptions;
@diegodfsd
diegodfsd / rule_request_one.json
Last active October 26, 2018 23:58
Exemplos de request para criar rule
{
"name": "Rule four",
"description": "description",
"conditions": [
{
"operator": "LessOrEqualsThan",
"type": "Weight",
"value": 1000
},
{
public class AuthClient {
private readonly IAppLogger<StandardHttpClient> _logger = new Logger<StandardHttpClient>();
private readonly IHttpClient _httpClient = new StandardHttpClient(_logger);
public async Task<dynamic> Authenticate(string clientId, string clientSecret)
{
var baseAddress = "http://api.logstore.com.br";
var body = new { client_id = clientId, client_secret = clientSecret, grant_typpe = "client_credentials" };
var data = await _httpClient.PostAsync("/sessions",
/*
* Exemplo de paginação usado na plataforma
*/
SELECT *
FROM (SELECT Row_number() OVER (ORDER BY NAME ASC) peta_rn,
i.[id],
i.[uniqueid],
i.[name]
FROM [core].[instances] i
@diegodfsd
diegodfsd / gist:234318391beca9804d59ef7dd6613b94
Created September 17, 2018 22:14
Exemplo extensão AuthorizerQueryBuilder
using System.Text.RegularExpressions;
using Xgen.Common.Extensions;
namespace Xgen.QueryProcessor.Query
{
public class AuthorizerQueryBuilder
{
#region Private Members
private static readonly Regex WhereRegex = new Regex(@"where\s+(?=\()(?=((?:(?=.*?\((?!.*?\2)(.*\)(?!.*\3).*))(?=.*?\)(?!.*?\3)(.*)).)+?.*?(?=\2)[^(]*(?=\3$)))", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase);
#endregion
public class InterfaceContractResolver : DefaultContractResolver
{
private readonly Type[] _interfaceTypes;
private readonly ConcurrentDictionary<Type, Type> _typeToSerializeMap;
public InterfaceContractResolver(params Type[] interfaceTypes)
{
_interfaceTypes = interfaceTypes;
Os dois desafios abaixo pretendem avaliar a capacidade do desenvolver de resolver problemas lógicos, por favor, leiam atentamente as instruções abaixo:
1. Você deve escolher ao menos um dos desafios.
2. O desafio deve ser resolvido individualmente.
3. É importante que os métodos criados tenham algum comentário que descreva sua finalidade.
4. Os desafios devem ser resolvidos, preferencialmente com C# ou Javascript
5. Não é obrigatório, mas vamos considerar um diferencial se forem criados testes
Desafios
--------------------------------------------------
---
http_interactions:
- request:
method: post
uri: https://api.iugu.com/v1/marketplace/create_account
body:
encoding: UTF-8
string: '{"name":"John Doe Co.","commissions":{"cents":0,"percent":20,"credit_card_cents":0,"credit_card_percent":15,"bank_slip_cents":0,"bank_slip_percent":20},"account_id":null}'
headers:
Content-Type:
@diegodfsd
diegodfsd / after.cs
Created June 15, 2018 20:32
Ensure.cs
protected Instance(bool multichannel, string name, string url, string site = null, string assemblyName = null, string pathTemplates = null,
string dashboardRelativeUrl = null, int? numberOfLicenses = null, AttendanceProtocolSettings protocolSettings = null, Status status = Status.Inactive) : this()
{
Ensure.Arg.NotEmpty(name, nameof(name));
Ensure.Arg.NotEmpty(url, nameof(url));
Ensure.Arg.Match(url, Validations.Url.SimpleUrlPattern, nameof(url));
Ensure.Arg.Is(!multichannel || site.IsNotNullOrEmpty(), nameof(site));
Ensure.Arg.Is(!multichannel || assemblyName.IsNotNullOrEmpty(), nameof(assemblyName));
Ensure.Arg.Is(!multichannel || pathTemplates.IsNotNullOrEmpty(), nameof(pathTemplates));
Ensure.Arg.Is(!multichannel || dashboardRelativeUrl.IsNotNullOrEmpty(), nameof(pathTemplates));