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.Web; | |
using System.Net.Http; | |
using WebApiContrib.Caching; | |
using WebApiContrib.MessageHandlers; | |
public class IPAddressThrottlingHandlers : ThrottlingHandler | |
{ | |
public IPAddressThrottlingHandlers(IThrottleStore store, Func<string, long> maxRequestsForIpAddress, TimeSpan period, string message) |
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 BalanceController : ApiController | |
{ | |
[HttpGet] | |
public HttpResponseMessage Get() | |
{ | |
return Request.CreateResponse(HttpStatusCode.OK, | |
new List<Balance> | |
{ | |
new Balance{ Date = new DateTime(2014,02,01), Amount = 500m }, | |
new Balance{ Date = new DateTime(2014,02,05), Amount = 400m }, |
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
var throttlingHandler = new ThrottlingHandler( | |
new InMemoryThrottleStore(), | |
quota => 10, | |
TimeSpan.FromMinutes(1), | |
"Exceed the limit 10 requests per minute!"); | |
config.MessageHandlers.Add(throttlingHandler); |
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 FX.Configuration; | |
public class MyConfig : JsonConfiguration | |
{ | |
public MyConfig() : base("MyConfig.json") { } | |
public string Name { get; set; } | |
public int Count { get; set; } | |
public int[] Ports { get; set; } | |
public DateTime StartDate { get; set; } |
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
{ | |
"Name": "Config", | |
"Count": 30, | |
"Ports": [ 9001, 9002, 9003 ], | |
"StartDate": "2015-06-01", | |
"RecycleTime" : "0.0:1:00", | |
"Server": { | |
"Name": "Server 1", | |
"IP": "10.10.10.10" |
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 Program | |
{ | |
static void Main(string[] args) | |
{ | |
var config = new MyConfig(); | |
Console.WriteLine(config.ToString()); | |
Console.Read(); | |
} |
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
PM> Install-Package AKKA <Enter> | |
Attempting to gather dependencies information for package 'akka.1.0.5' with respect to project 'ConsoleApplication1', targeting '.NETFramework,Version=v4.6.1' | |
..................... | |
Successfully installed 'Akka 1.0.5' to ConsoleApplication1 |
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
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="Akka" version="1.0.5" targetFramework="net461" /> | |
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net461" /> | |
</packages> |
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 Akka.Actor; | |
namespace ConsoleApplication1 | |
{ | |
public class SmsSenderActor : ReceiveActor | |
{ | |
public SmsSenderActor() | |
{ | |
Receive<string>(message => Console.WriteLine(message)); |
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 Akka.Actor; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var smsActorSystem = ActorSystem.Create("SmsActorSystem"); | |
Console.WriteLine("Actor System Created"); |
OlderNewer