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
using System; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Converters; | |
namespace Infrastructure.Json | |
{ | |
public class UnixTimestampConverter : DateTimeConverterBase | |
{ | |
private static readonly DateTime _epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); |
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 class JsonContentTest | |
{ | |
[Fact] | |
public void Testar_geracao_json() | |
{ | |
var jsonContent = "{\"user_id\":0,\"app_user_id\":7,\"name\":null,\"first_name\":\"Teacher Britzola\",\"surname\":\"Four\",\"username\":\"952pyiwuc2\",\"password\":\"1y60cgKx\",\"email\":\"teacher.four@gedu.demo.smartlab.me\",\"birthdate\":\"1978-09-28T01:00:00\",\"gender\":\"male\",\"role\":\"teacher\",\"student\":null,\"teacher\":{\"school\":{\"id\":8,\"name\":\"Col\\u00e9gio Educar - DEMO\",\"federative_unit\":\"SP\",\"city\":\"S\\u00e3o Paulo\",\"zip\":\"03303904\"},\"classes\":[{\"id\":3,\"name\":\"A1\",\"stage\":null}]}}"; | |
var obj = new | |
{ | |
user_id = 0, | |
app_user_id = 7, |
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 async Task WriteAsync(this IOwinContext context, string content, IDictionary<string, string> headers = null) | |
{ | |
foreach (var header in headers) | |
{ | |
context.Response.Headers.Add(header.Key, new[] { header.Value }); | |
} | |
await context.Response.WriteAsync(content); | |
} |
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
using System; | |
using System.Net; | |
using System.Text.RegularExpressions; | |
using BenchmarkDotNet.Attributes; | |
[Config("jobs=job1,job2 " + | |
"columns=column1,column2 " + | |
"exporters=exporter1,exporter2 " + | |
"loggers=logger1,logger2 " + | |
"diagnosers=diagnoser1,diagnoser2 " + |
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 class FreeGeoIP | |
{ | |
[JsonProperty("city")] | |
public string City { get; set; } | |
[JsonProperty("country_code")] | |
public string CountryCode { get; set; } | |
[JsonProperty("country_name")] | |
public string CountryName { get; set; } |
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
[Theory] | |
[InlineData(typeof(BookType), typeof(BookType))] | |
public void GivenTwoEnums_WhenNamesOfFromNotContainsInToEnum_ShouldBeFalse(Type from, Type to) | |
{ | |
var fromNames = Enum.GetNames(from); | |
var toNames = Enum.GetNames(to); | |
var namesThatNotContainsInToNamesQuery = fromNames.Where(name => !toNames.Contains(name)); | |
var names = String.Join(", ", namesThatNotContainsInToNamesQuery.ToArray()); |
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
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations; | |
namespace Web.Common | |
{ | |
public static class DataAnnotationsExtensions | |
{ | |
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Justification = "customary")] | |
public static bool IsValidAnnotations<T>(this T instance, out ICollection<ValidationResult> results) where T : class | |
{ |
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
using System; | |
using System.Collections; | |
using System.Globalization; | |
using System.Linq; | |
using System.Web.Mvc; | |
using System.Web.UI; | |
namespace Web.Controllers | |
{ | |
public class MessageController : Controller |
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
using System; | |
using System.Collections.Generic; | |
using System.Data.Entity; | |
using System.Data.Entity.Infrastructure; | |
using System.Data.Entity.Migrations; | |
using System.Data.Entity.Migrations.Infrastructure; | |
using System.Data.Entity.Validation; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; |
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
using CssSyntax; | |
using CssSyntax.SyntaxTree; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace CssDupfinder | |
{ | |
public class CssDuplicateSelectorWalker : CssWalker | |
{ |