Skip to content

Instantly share code, notes, and snippets.

View ionoy's full-sized avatar

Mihhail Maslakov ionoy

  • Estonia
View GitHub Profile
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());
viewmodel StatusViewModel
{
// Simple property definition, by default public and defines both get/set
string Name;
// Getter only
string Name get;
// Private field is everything prefixed by '_'
string _name;
interface IService {
IObservable<int> Values { get; }
}
viewmodel StatusViewModel {
string Name = {
var val = stream service.Values;
return val + 3;
}
// Is translated to
@ionoy
ionoy / templates
Last active January 3, 2016 10:42
abstract ast NodeMember {
in Parent : Node;
in TemplateScope : Scope;
TemplateScope = TableScope("Templates", null);
}
ast Node : NodeMember {
Members : NodeMember*;
Members.TemplateScope = TemplateScope;
diff --git a/Nitra/DotNetLang/Collectors/BaseTypeReferenceSet.n b/Nitra/DotNetLang/Collectors/BaseTypeReferenceSet.n
index b533192..27471a9 100644
--- a/Nitra/DotNetLang/Collectors/BaseTypeReferenceSet.n
+++ b/Nitra/DotNetLang/Collectors/BaseTypeReferenceSet.n
@@ -33,8 +33,9 @@ namespace DotNet
private mutable _ancestorTypes : HashSet[TypeSymbol];
private mutable _parentClassScope : Scope;
private mutable _parentFullScope : Scope;
+ private mutable _ancestorsFullScope : Scope;
private _parentTypes : HashSet[TypeSymbol];
@ionoy
ionoy / a.cs
Created February 27, 2016 15:05
allMessages.GroupBy(msg => msg.Type)
.Select(g => g.Throttle(TimeSpan.FromSeconds(0.5)) // Ждём паузы между сообщениями
.Select(msg => HandleMessage(msg)) // HandleMessage возвращает Task<Result>
.Switch() // Если придёт новое сообщение этого типа, то старый ответ будет игнорирован
.SelectMany(res => SendResponse(res)))
.Subscribe()
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Storyboard x:Key="FadeIn" TargetName="TestButton">
Observable.Interval(TimeSpan.FromSeconds(2))
.Delay(TimeSpan.FromSeconds(1))
.ObserveOnDispatcher()
.Subscribe(_ => ((Storyboard)Resources["FadeIn"]).Begin());
Observable.Interval(TimeSpan.FromSeconds(2))
.ObserveOnDispatcher()
.Subscribe(_ => ((Storyboard)Resources["FadeOut"]).Begin());
namespace Nitra.Visualizer.ViewModels
{
public class AstNodeViewModel : ReactiveObject
{
readonly ObjectDescriptor _objectDescriptor;
readonly NitraClient _client;
[Reactive]
public bool NeedLoadContent { get; private set; }
public ReactiveList<AstNodeViewModel> Items { get; set; }
syntax Expr
{
| MemberRef = Key=QualifiedReference
| ArrayRef = Key=QualifiedReference "[" Expr "]"
| MethodCall = Key=QualifiedReference "(" (Argument; "," sm)* ")"
| Braces = "(" Expr ")"
| Complex = (MethodCall | MemberRef | ArrayRef | Braces) "." Expr
}