internal KeyValuePair <Key, double>?LastEventWhenMoreOrEqual(Key to, double threshold) { if (Predicates.Less(to, From)) { return(null); } if (Maximum < threshold) { return(null); } KeyValuePair <Key, double>?result = null; if ((null != FirstChild) && (null != SecondChild)) { result = SecondChild.LastEventWhenMoreOrEqual(to, threshold); if (null == result) { result = FirstChild.LastEventWhenMoreOrEqual(to, threshold); } return(result); } Debug.Assert(null == FirstChild); Debug.Assert(null == SecondChild); if ((Close >= threshold) && (Predicates.LessOrEqual(To, to))) { result = new KeyValuePair <Key, double>(To, Close); } else if (Open >= threshold) { result = new KeyValuePair <Key, double>(From, Open); } return(result); }
public override CompiledFragment Compile(CompiledMethod method) { if (FirstChild == null) { return(null); } // Apply the current line: method.CurrentLine = LineNumber; try{ // Compile operator chains: (d=a+b+c;) CompilationServices.CompileOperators(this, method); // Compile the now singular operator: CompiledFragment cFrag = FirstChild.Compile(method) as CompiledFragment; return(cFrag); }catch (CompilationException e) { if (e.LineNumber == -1) { // Setup line number: e.LineNumber = LineNumber; } // Rethrow: throw e; } }
public override double EvaluateNumber() { var from = FirstChild.EvaluateNumber(); var to = SecondChild.EvaluateNumber(); return(from + Random.NextDouble() * (to - from)); }
public override bool EvaluateLogic() { var from = FirstChild.EvaluateLogic(); var to = SecondChild.EvaluateLogic(); return(from == to ? from : Random.NextBool()); }
private void OnLoaded(object sender, RoutedEventArgs e) { if (VisualTreeHelper.GetChildrenCount(this) > 0) { FrameworkElement FirstChild; if ((FirstChild = VisualTreeHelper.GetChild(this, 0) as FrameworkElement) != null) { ToggleButton AddRemoveButton; if ((AddRemoveButton = FirstChild.FindName("AddRemoveButton") as ToggleButton) != null) { AddRemoveButton.Checked += OnAddRemoveButtonChecked; } ToggleButton OverflowButton; if ((OverflowButton = FirstChild.FindName("OverflowButton") as ToggleButton) != null) { OverflowButton.Unchecked += OnOverflowButtonUnchecked; } MenuItem ResetToolBarMenuItem; if ((ResetToolBarMenuItem = FirstChild.FindName("ResetToolBarMenuItem") as MenuItem) != null) { ResetToolBarMenuItem.Click += OnResetToolBarClicked; } } } }
protected virtual void Dispose(bool disposing) { FirstChild?.Dispose(); NextSibling?.Dispose(); FirstChild = NextSibling = ParentNode = PreviousSibling = null; }
internal double FindMaximum(Key from, Key to) { if (Predicates.LessOrEqual(from, From) && Predicates.LessOrEqual(To, to)) { return(Maximum); } if (Predicates.Less(to, From) || Predicates.More(from, To)) { return(double.NegativeInfinity); } if ((null != FirstChild) && (null != SecondChild)) { double first = FirstChild.FindMaximum(from, to); double second = SecondChild.FindMaximum(from, to); double result = Math.Max(first, second); return(result); } if (Predicates.LessOrEqual(from, To)) { return(Close); } if (Predicates.MoreOrEqual(to, From)) { return(Open); } return(double.NegativeInfinity); }
public override bool Match(IParserState p) { while (FirstChild.Match(p)) { } return(true); }
internal KeyValuePair <Key, double>?FirstEventWhenMore(Key from, double threshold) { if (Predicates.More(from, To)) { return(null); } if (Maximum <= threshold) { return(null); } KeyValuePair <Key, double>?result = null; if ((null != FirstChild) && (null != SecondChild)) { result = FirstChild.FirstEventWhenMore(from, threshold); if (null == result) { result = SecondChild.FirstEventWhenMore(from, threshold); } return(result); } Debug.Assert(null == FirstChild); Debug.Assert(null == SecondChild); if ((Open > threshold) && (Predicates.MoreOrEqual(From, from))) { result = new KeyValuePair <Key, double>(From, Open); } else if (Close > threshold) { result = new KeyValuePair <Key, double>(To, Close); } return(result); }
public override BTStatus Step() { if (FirstChild == null) { return(BTStatus.Failure); } return(FirstChild.Step()); }
public override int GetHashCode() { unchecked { return(((FirstChild != null ? FirstChild.GetHashCode() : 0) * 397) ^ (SecondChild != null ? SecondChild.GetHashCode() : 0)); } }
public override EBTStatus Step() { if (FirstChild == null) { return(EBTStatus.BT_FAILURE); } return(FirstChild.Step()); }
protected override void DumpChildTo(TextWriter writer, int level) { if (FirstChild != null) { level++; FirstChild.DumpTo(writer, level); } }
public override Placement Clone() { return(new SplitPlacement { Stretch = Stretch, Separator = Separator, FirstChild = FirstChild?.Clone(), SecondChild = SecondChild?.Clone() }); }
public void Initialize(Placement first, Placement second, DockSeparator separator, float stretch) { FirstChild?.Unlink(); SecondChild?.Unlink(); FirstChild = first; SecondChild = second; Separator = separator; Stretch = stretch; }
protected virtual void Dispose(bool disposing) { RemotingServices.Disconnect(this); FirstChild?.Dispose(); NextSibling?.Dispose(); FirstChild = NextSibling = ParentNode = PreviousSibling = null; }
public override IEnumerable <IFormulaToken> Tokenize() { return(Enumerable.Repeat(CreateToken(), 1) .Concat(Enumerable.Repeat(FormulaTokenFactory.CreateParenthesisToken(true), 1)) .Concat(FirstChild == null ? FormulaTokenizer.EmptyChild : FirstChild.Tokenize()) .Concat(Enumerable.Repeat(FormulaTokenFactory.CreateParameterSeparatorToken(), 1)) .Concat(SecondChild == null ? FormulaTokenizer.EmptyChild : SecondChild.Tokenize()) .Concat(Enumerable.Repeat(FormulaTokenFactory.CreateParenthesisToken(false), 1))); }
public override Placement Clone() { return(new WindowPlacement { Position = Position, Size = Size, State = State, FirstChild = FirstChild?.Clone(), SecondChild = SecondChild?.Clone(), }); }
public static async Task InsertTestData(int count) { Debug.WriteLine($"Begin inserting {count} TestModels to the db"); var dbContextFactory = AppContainer.GlobalContainer.Resolve <CustomDBContextFactory>(); int batch; var stopwatch = new Stopwatch(); stopwatch.Start(); while (count > 0) { batch = count > 5000 ? 5000 : count; var modelList = new List <TestModel>(); var firstChildList = new List <FirstChild>(); for (int i = 0; i < batch; i++) { var testModel = new TestModel() { TestModelName = "Test Name", Description = "Test Description", Height = i, Width = i, TestModelId = count - i + 1 }; var firstChild = new FirstChild { FirstChildName = "First Child Name", Description = "First Child Description", Height = i, Width = i, TestModelId = count - i + 1, FirstChildId = count - i + 1 }; modelList.Add(testModel); firstChildList.Add(firstChild); } using (var dbContext = dbContextFactory.CreateDbContext(new string[] { })) { dbContext.TestModels.AddRange(modelList); dbContext.FirstChildren.AddRange(firstChildList); await dbContext.SaveChangesAsync(); } Debug.WriteLine($"{count} more to insert..."); count -= batch; } Debug.WriteLine($"Finished inserting testmodels: {stopwatch.Elapsed}"); }
protected bool IsNumberT2L() { // TODO: meaningful (translated?) error message var t = FirstChild.IsNumber(); if (!SecondChild.IsNumber() == t) { throw new SemanticsErrorException(this, "Children are different"); } return(false); }
/// <summary> /// delete subtree starting with this node /// </summary> /// <returns> returns next sibling</returns> internal NodeBase deleteSubTree() { while (FirstChild != null) { FirstChild.deleteSiblingsWithSubtree(); } NodeBase next = NextSibling; delete(); return(next); }
public override bool Match(IParserState p) { int store = p.GetPos(); if (!FirstChild.Match(p)) { throw new ParsingException(p.GetInput(), store, p.GetPos(), FirstChild, Msg); } return(true); }
public void PrintPreOrder() { Console.WriteLine(Element); if (FirstChild != null) { FirstChild.PrintPreOrder(); } if (NextSibling != null) { NextSibling.PrintPreOrder(); } }
public static void test_multiple_child_classes() { FirstChild obj = new FirstChild(); Test.AssertEquals(1, obj.receivedValue); SecondChild obj2 = new SecondChild(); Test.AssertEquals(2, obj2.receivedValue); obj = new FirstChild(); Test.AssertEquals(1, obj.receivedValue); }
public override ENST OnExecute() { if (Condition.V == false) { FirstChild.OnTick(); return(FirstChild.State); } else { FirstChild.OnExit(ENST.FAILURE); return(ENST.FAILURE); } }
protected bool IsNumberN2N() { // TODO: meaningful (translated?) error message if (!FirstChild.IsNumber()) { throw new SemanticsErrorException(this, "First child must be number"); } if (!SecondChild.IsNumber()) { throw new SemanticsErrorException(this, "Second child must be number"); } return(true); }
public override ENST OnExecute() { FirstChild.OnTick(); switch (FirstChild.State) { case ENST.SUCCESS: case ENST.FAILURE: return(ENST.SUCCESS); default: return(FirstChild.State); } }
public void Replace(Placement child, Placement newChild) { if (FirstChild == child) { FirstChild?.Unlink(); FirstChild = newChild; } else if (SecondChild == child) { SecondChild?.Unlink(); SecondChild = newChild; } }
public int GetSize() { int size = 1; if (FirstChild != null) { size += FirstChild.GetSize(); } if (NextSibling != null) { size += NextSibling.GetSize(); } return(size); }
public void AddChild(DisseminateNode <TKey, TValue> child) { child.Parent = this; ChildrenCount++; if (FirstChild == null) { FirstChild = child; return; } // Always add it as the last child FirstChild.InsertBefore(child); Debug.Assert(RightSibling != null && LeftSibling != null); }