This file contains 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
class Abstraction | |
{ | |
Bridge bridge; | |
public Abstraction(Bridge implementation) | |
{ | |
bridge = implementation; | |
} | |
public string Operation() | |
{ | |
return "Abstraction <<< BRIDGE >>>> " + bridge.OperationImp(); |
This file contains 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
Guard.Against<InvalidOperationException>(string.IsNullOrEmpty(serverName), "Server name must be provided") |
This file contains 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.Linq; | |
using System.Linq.Expressions; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Ormazabal.PanelMonitoring.Helpers | |
{ | |
static class Expressions |
This file contains 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 Guard | |
{ | |
public static void NotNull<T>(Expression<Func<T>> notNullableExpression) where T : class | |
{ | |
var compliedExpression = notNullableExpression.Compile(); | |
if (compliedExpression() == null) | |
{ | |
var paramName = notNullableExpression.GetObjectNameGraph(); | |
throw new ArgumentNullException(paramName); |
This file contains 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
private static HttpClient client = new HttpClient(); | |
// GET | |
var response = await client.GetAsync(@"http://localhost/admin"); | |
var cookies = response.Headers.FirstOrDefault(pair => String.Compare(pair.Key, @"Set-Cookie", StringComparison.OrdinalIgnoreCase) == 0).Value; | |
// get token from html | |
var html = await response.Content.ReadAsStringAsync(); | |
var regex = new Regex("(name=\\\"_token\\\" value=)\\\"(.*)\\\""); | |
var token = regex.Match(html).Groups[2].Value; |
This file contains 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 Newtonsoft.Json; | |
using System.Net.Http; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json.Converters; | |
namespace ArchDev | |
{ | |
public static class HttpClientExtensions |
This file contains 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.IO; | |
using System.Net.Http; | |
using System.Net.Http.Formatting; | |
using System.Threading.Tasks; | |
namespace Infrastructure.Services | |
{ | |
public class HttpClientService : IHttpClientService |
This file contains 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 JsonClient : IRestClient | |
{ | |
private IJsonSerializer serializer; | |
private HttpClient httpClient; | |
protected virtual HttpClient HttpClient | |
{ | |
get | |
{ | |
return this.httpClient ?? (this.httpClient = new HttpClient()); |
This file contains 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
client.DefaultRequestHeaders.Accept.Clear(); | |
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | |
var param = new Dictionary<string, string> | |
{ | |
{ | |
"title", title | |
} | |
}; | |
var query = await new FormUrlEncodedContent(param).ReadAsStringAsync(); |
This file contains 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.IO; | |
using System.Xml; | |
using System.Xml.Schema; | |
using System.Xml.XPath; | |
namespace XSD_fun | |
{ | |
class Program | |
{ |