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 string Translate(int commandId) | |
{ | |
string ret; | |
if (Translations.TryGetValue(commandId, out ret)) | |
return ret; | |
return "unknown"; | |
} |
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
Начали писать серию статей по NemerleWeb, и там понадобился макрос, который сделал бы объявление типов более лаконичными. | |
На данный момент первый пример — это классический todo список. Для такого списка неплохо было бы создать тип: | |
public class Task | |
{ | |
public Name : string { get; set; } | |
public Priority : string { get; set; } | |
public IsDone : bool { 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
[Unit] | |
public class ReactiveToDo | |
{ | |
[Dto] public class Task { Name : string; IsDone : bool; Priority : string; } | |
mutable _tasks = List.[Task](); | |
mutable _todoName = "New task"; | |
mutable _todoPriority = "high"; | |
public this() |
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
new TestScheduler().With(sc => { | |
var client = Substitute.For<IQuadClient>(); | |
var packets = new Subject<IMavLinkPacket>(); | |
client.Packets.Returns(packets); | |
var quad = new Quad(client, MessageBus.Current); | |
packets.OnNext(new Mav.mavlink_heartbeat_t { base_mode = (byte)Mav.MAV_MODE_FLAG.SAFETY_ARMED }); | |
sc.AdvanceByMs(1); | |
quad.State = new LandState(); |
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
new TestScheduler().With(sc => { | |
var bus = MessageBus.Current; | |
var quad = Substitute.For<IQuad>(); | |
var vm = new MapViewModel(new Mission(quad, bus), quad, bus); | |
bus.SendMessage(new StartAddingWaypointsMessage()); | |
Assert.IsTrue(vm.IsAddingWaypoints); | |
bus.SendMessage(new StopAddingWaypointsMessage()); |
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
{ | |
{ | |
{ | |
{ | |
def _var5 = template(TourneyList, _ .View) | |
}; | |
when ( | |
{ | |
def _var7 = TourneyList.Selected != null; | |
TourneyList.Selected != null |
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
[Unit] | |
class Draggable | |
{ | |
public OffsetX : int { get; set; } | |
public OffsetY : int { get; set; } | |
public this(moveHandler = null, downHandler = null, upHandler = null) | |
{} | |
public Handler() : void |
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
handle mousedown(down) { | |
handle mousemove(move) until mouseup { | |
.... | |
} | |
} | |
handle keydown(k0) { | |
if(k0 == 'a') { | |
handle once keydown(k1) { | |
if(k1 == 'b') { |
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
macro HandleOnce(eventName, eventArgs, body) | |
syntax ("handle", eventName, eventArgs, "once", body) | |
{ | |
HandleImpl.OnceImpl(eventName, eventArgs, body); | |
} | |
macro Handle(eventName, eventArgs, body) | |
syntax ("handle", eventName, eventArgs, body) | |
{ | |
HandleImpl.Impl(eventName, eventArgs, body); |