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 SalesController : Controller | |
{ | |
private readonly IOrderPersister orderPersister; | |
private readonly IShippingPersister shippingPersister; | |
public SalesController(IOrderPersister orderPersister, IShippingPersister shippingPersister) | |
{ | |
this.orderPersister = orderPersister ?? throw new ArgumentNullException(nameof(orderPersister)); | |
this.shippingPersister = shippingPersister ?? throw new ArgumentNullException(nameof(shippingPersister)); | |
} |
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 DocumentDbHack | |
{ | |
// WARNING: This class works in the dark side of the force | |
private static readonly FieldInfo documentPropertiesHack = typeof(Document) | |
.GetField("propertyBag", BindingFlags.Instance | BindingFlags.NonPublic); | |
public static dynamic GetUnderlyingObject(this Document source) | |
{ | |
return source == null ? null: documentPropertiesHack.GetValue(source); |
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
[Test] | |
public void WhenAddGetterThenExcuteLogic() | |
{ | |
dynamic doc = new ExpandoObject(); | |
doc.Object = "Pizza"; | |
doc.State = "Calda"; | |
dynamic ddoc = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(doc)); | |
ddoc.ReState = JObject.FromObject(new ComputedState(ddoc)); |
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 interface ITransformer | |
{ | |
Task<dynamic> Transform(dynamic source); | |
Task<dynamic[]> TransformEach(IEnumerable<dynamic> source); | |
} | |
public abstract class TransformerPipeline: ITransformer | |
{ | |
private readonly ITransformer innerTransformer; |
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.ComponentModel; | |
using System.Dynamic; | |
using System.Linq; | |
namespace Hunabku.DynTransfomer | |
{ | |
/// <summary> | |
/// Definition and behaviour to transform a POCO to another POCO. |
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 Base64StringExtensions | |
{ | |
public static string ToBase64Url(this byte[] source) | |
{ | |
var sb = new StringBuilder(Convert.ToBase64String(source, Base64FormattingOptions.None)); | |
var paddingCount = 0; | |
for (var i = 0; i < sb.Length; i++) | |
{ | |
switch (sb[i]) | |
{ |
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
{ | |
"variables": [], | |
"info": { | |
"name": "Azure Search", | |
"_postman_id": "16089191-30b3-c37d-4bdd-e7823ec7b8d8", | |
"description": "", | |
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" | |
}, | |
"item": [ | |
{ |
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
<PropertyGroup> | |
<TargetFramework>net461</TargetFramework> | |
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> | |
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | |
</PropertyGroup> | |
<PropertyGroup> | |
<DebugType Condition="'$(TargetFramework)' != '' AND '$(TargetFramework)' != 'netcoreapp11'">Full</DebugType> | |
</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
[Route("api/[controller]")] | |
public class ValuesController : Controller | |
{ | |
private static Dictionary<int, string> valuesRepo = new Dictionary<int, string>(); | |
[HttpGet] | |
public IActionResult Get() | |
{ | |
return Ok(valuesRepo.Select(x=> new { Id= x.Key, Value= x.Value })); | |
} |
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
SELECT TOP 5 | |
st.text, | |
qp.query_plan, | |
qs.* | |
FROM sys.dm_exec_query_stats qs | |
CROSS APPLY sys.dm_exec_sql_text(qs.plan_handle) st | |
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp | |
ORDER BY total_worker_time DESC |