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 SanguineBond : CastableCard, IEnchantment, IEventHandler<PlayerLifeChanged> | |
{ | |
public SanguineBond() | |
{ | |
Name = "Sanguine Bond"; | |
ManaCost = Manacost.Create(black: 4, collorless: 2); | |
Description = "Whenever you gain life, target opponent loses that much life."; | |
} | |
public void Handle(PlayerLifeChanged @event) |
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
interface IEventHandler<TEvent> where TEvent : IEvent | |
{ | |
void Handle(TEvent @event); | |
} |
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
static IQueryable<TResult> OrderByPropertyName<TResult>(this IQueryable<TResult> that, string propertyName) | |
{ | |
var modelType = typeof(TResult); | |
var propertyInfo = modelType.GetProperty(propertyName); | |
if (propertyInfo == null) | |
throw new ArgumentException(string.Format( | |
"Cannot order by invalid property. Property \"{0}\" does not exist on type \"{1}\"", | |
propertyName, | |
modelType.FullName), |
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
static IQueryable<TResult> OrderByPropertyName<TResult>(this IQueryable<TResult> that, string propertyName) | |
{ | |
var modelType = typeof(TResult); | |
var propertyInfo = modelType.GetProperty(propertyName); | |
var orderByParam = Expression.Parameter(typeof(TResult), "orderBy"); | |
var expression = Expression.Lambda<Func<TResult, object>>( | |
Expression.Property( | |
orderByParam, | |
propertyInfo.GetGetMethod()), |
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 retVal = ( | |
from wClient in trans.Query<Warehouse>.SingleOrDefault(w => w.Id == warehouseId).Clients | |
from uClient in trans.Query<User>.SingleOrDefault(u => u.Id == userId).Clients | |
where wClient.Id == uClient.Id | |
select wClient).Skip(requestedPage * pageLength).Take(pageLength).ToList(); |
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
(defn print-fizz-buzz [numbers] | |
(map (fn [n] | |
(def mul-3 (= 0 (mod n 3))) | |
(def mul-5 (= 0 (mod n 5))) | |
(cond | |
(and mul-3 mul-5) "fizz-buzz" | |
mul-3 "fizz" | |
mul-5 "buzz" | |
:default n)) | |
numbers)) |
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; | |
namespace ConsoleApplication2 | |
{ | |
class Program | |
{ | |
class True { } | |
class False { } | |
static void Eval(Action<True> t) |
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 bool KeepHand(IEnumerable<GameObjectId> possibleHand) | |
{ | |
var result = false; | |
var viewModel = new KeepHandViewModel(possibleHand.Select(_queryModel.GetQueryModel<CardQueryModel>)); | |
viewModel.ResultChosen += keep => | |
{ | |
result = keep; | |
_controlActivator.DeactivateViewModel(viewModel); | |
}; |
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
[Test] | |
public void SimpleAuthenticationTest() | |
{ | |
dynamic client = new HttpServiceClient("http://localhost:5865"); | |
var response = client.Authentication.GetAuthenticate(email: "nelsonlaquet@gmail.com", password: "test"); | |
var id = (string)response.PlayerId; | |
id.Should().Be("2685eacd-b797-4d57-9dbc-88c4193b0061"); | |
} |
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 void HandleSubscriptionEvents(IEvent @event) | |
{ | |
@event.AsMaybeType<SessionSubscribedToChannelEvent>().Do(addSub => | |
{ | |
List<RunePeer> peers; | |
if (!_channelSubscriptions.TryGetValue(addSub.ChannelSubscribedToId, out peers)) | |
peers = _channelSubscriptions[addSub.ChannelSubscribedToId] = new List<RunePeer>(); | |
peers.Add(_peers[addSub.SessionId]); | |
}); |