Skip to content

Instantly share code, notes, and snippets.

View ionoy's full-sized avatar

Mihhail Maslakov ionoy

  • Estonia
View GitHub Profile
public class MainViewModel : ReactiveObject
{
public MainViewModel()
{
LoadTweetsCommand = new ReactiveCommand();
LoadTweetsCommand.RegisterAsync(_ => {
throw new Exception("AA");
return LoadTweets();
}).Subscribe(x => TheTweets = x);
using System;
using System.Linq;
using System.Reflection;
using System.ServiceModel;
using LinFu.DynamicProxy;
namespace UAV.Communication
{
public static class CommunicationHelpers
{
class Program
{
static void Main(string[] args)
{
using (var host = CommunicationHelpers.CreateHost<UAVControl>(hostSuffix: args.Length > 0 ? args[0] : "")) {
host.Open();
Console.WriteLine("Service is available. Press <ENTER> to exit.");
Console.ReadLine();
public static UAVAsyncControl Connect(string endpointPostfix = "")
{
return new UAVAsyncControl(CommunicationHelpers.CreateClient(endpointPostfix));
}
public const int WaitOutRange = 367;
public const int SkipInRange = 368;
public const int SkipOutRange = 369;
public const int WaitHdgInRange = 370;
public const int WaitHdgOutRange = 371;
public const int SkipHdgInRange = 372;
public const int SkipHdgOutRange = 373;
public const int RotateRelativeWaypoint = 374;
private static readonly Dictionary<int, string> Translations;
public static string Translate(int commandId)
{
string ret;
if (Translations.TryGetValue(commandId, out ret))
return ret;
return "unknown";
}
Начали писать серию статей по NemerleWeb, и там понадобился макрос, который сделал бы объявление типов более лаконичными.
На данный момент первый пример — это классический todo список. Для такого списка неплохо было бы создать тип:
public class Task
{
public Name : string { get; set; }
public Priority : string { get; set; }
public IsDone : bool { get; set; }
}
[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()
////////// Usage ///////////
this.BindRadioButtons(v => v.ViewModel.RadioButtonValue,
v => v.RadioButtonA, "A",
v => v.RadioButtonB, "B");
////////// Implementation ///////////
public static IDisposable BindRadioButtons<TSender, TViewModelValue>(this TSender view,
Expression<Func<TSender, TViewModelValue>> viewModelProperty,
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();