Exemple #1
0
        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);
        }
Exemple #2
0
        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;
            }
        }
Exemple #3
0
        public override double EvaluateNumber()
        {
            var from = FirstChild.EvaluateNumber();
            var to   = SecondChild.EvaluateNumber();

            return(from + Random.NextDouble() * (to - from));
        }
Exemple #4
0
        public override bool EvaluateLogic()
        {
            var from = FirstChild.EvaluateLogic();
            var to   = SecondChild.EvaluateLogic();

            return(from == to ? from : Random.NextBool());
        }
Exemple #5
0
        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;
                    }
                }
            }
        }
Exemple #6
0
        protected virtual void Dispose(bool disposing)
        {
            FirstChild?.Dispose();
            NextSibling?.Dispose();

            FirstChild = NextSibling = ParentNode = PreviousSibling = null;
        }
Exemple #7
0
        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);
 }
Exemple #9
0
        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);
        }
Exemple #10
0
 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));
     }
 }
Exemple #12
0
 public override EBTStatus Step()
 {
     if (FirstChild == null)
     {
         return(EBTStatus.BT_FAILURE);
     }
     return(FirstChild.Step());
 }
Exemple #13
0
 protected override void DumpChildTo(TextWriter writer, int level)
 {
     if (FirstChild != null)
     {
         level++;
         FirstChild.DumpTo(writer, level);
     }
 }
Exemple #14
0
 public override Placement Clone()
 {
     return(new SplitPlacement {
         Stretch = Stretch,
         Separator = Separator,
         FirstChild = FirstChild?.Clone(),
         SecondChild = SecondChild?.Clone()
     });
 }
Exemple #15
0
 public void Initialize(Placement first, Placement second, DockSeparator separator, float stretch)
 {
     FirstChild?.Unlink();
     SecondChild?.Unlink();
     FirstChild  = first;
     SecondChild = second;
     Separator   = separator;
     Stretch     = stretch;
 }
Exemple #16
0
        protected virtual void Dispose(bool disposing)
        {
            RemotingServices.Disconnect(this);

            FirstChild?.Dispose();
            NextSibling?.Dispose();

            FirstChild = NextSibling = ParentNode = PreviousSibling = null;
        }
Exemple #17
0
 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)));
 }
Exemple #18
0
 public override Placement Clone()
 {
     return(new WindowPlacement {
         Position = Position,
         Size = Size,
         State = State,
         FirstChild = FirstChild?.Clone(),
         SecondChild = SecondChild?.Clone(),
     });
 }
Exemple #19
0
        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);
        }
Exemple #21
0
            /// <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);
            }
Exemple #22
0
        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);
        }
Exemple #23
0
 public void PrintPreOrder()
 {
     Console.WriteLine(Element);
     if (FirstChild != null)
     {
         FirstChild.PrintPreOrder();
     }
     if (NextSibling != null)
     {
         NextSibling.PrintPreOrder();
     }
 }
Exemple #24
0
        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);
        }
Exemple #25
0
 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);
 }
Exemple #27
0
        public override ENST OnExecute()
        {
            FirstChild.OnTick();
            switch (FirstChild.State)
            {
            case ENST.SUCCESS:
            case ENST.FAILURE:
                return(ENST.SUCCESS);

            default:
                return(FirstChild.State);
            }
        }
Exemple #28
0
 public void Replace(Placement child, Placement newChild)
 {
     if (FirstChild == child)
     {
         FirstChild?.Unlink();
         FirstChild = newChild;
     }
     else if (SecondChild == child)
     {
         SecondChild?.Unlink();
         SecondChild = newChild;
     }
 }
Exemple #29
0
        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);
        }