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.Threading.Tasks; | |
using Orleans; | |
namespace ConverterContracts | |
{ | |
/// <summary> | |
/// Grain interface IConverter | |
/// </summary> | |
public interface IConverter : IGrainWithGuidKey | |
{ |
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
<ItemGroup> | |
<PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.*" /> | |
</ItemGroup> |
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
<ItemGroup> | |
<PackageReference Include="Contoso.Utility.UsefulStuff" Version="3.6.0" /> | |
</ItemGroup> |
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 BenchmarkDotNet.Attributes; | |
using System.Collections.Generic; | |
namespace BenchNET | |
{ | |
public class Iterate | |
{ | |
private List<string> lstStr; | |
private int Counter; |
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 BenchmarkDotNet.Running; | |
using System; | |
namespace BenchNET | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
var summary = BenchmarkRunner.Run<Iterate>(); |
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
[HttpPost] | |
[ModelStateValidationActionFilter] | |
public IHttpActionResult Post(object model) | |
{ | |
// Do something here ;) | |
} |
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 ModelStateValidationActionFilterAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(HttpActionContext actionContext) | |
{ | |
var modelState = actionContext.ModelState; | |
if (!modelState.IsValid) | |
actionContext.Response = actionContext.Request | |
.CreateErrorResponse(HttpStatusCode.BadRequest, modelState); | |
} |
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 CustomerService | |
{ | |
[CacheableResult(600)] // 600 seconds, 10 minutes cache policy | |
public List<dynamic> ReturnCustomer() | |
{ | |
var lstCustomer = new List<dynamic>(); | |
var customer = new Customer | |
{ | |
Id = 1, |
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 CustomerController : NancyModule | |
{ | |
public CustomerController() : base("/customers") | |
{ | |
try | |
{ | |
var obj = new CustomerService(); | |
Get["/"] = _ => | |
{ |
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
private static void Main(string[] args) | |
{ | |
Console.WriteLine("Starting NancyFX..."); | |
using (var nancyHost = new NancyHost(new Uri("http://localhost:8889/nancy/"))) | |
{ | |
nancyHost.Start(); | |
Console.WriteLine("Nancy now listening - navigating to http://localhost:8889/nancy/. Press enter to stop"); | |
Console.ReadLine(); | |
} | |
} |