Esempio n. 1
0
        public void CountCorrectlyWhenIndividualsAdded()
        {
            var candidates = new Candidates(9);

            candidates.Add(1);
            candidates.Add(3);
            candidates.Add(7);
            candidates.Count.Should().Be(3);
        }
Esempio n. 2
0
 public void AddBlankWriteIns()
 {
     for (int i = 0; i < VoteFor; i++)
     {
         Candidates.Add(new Candidate("writein"));
     }
 }
Esempio n. 3
0
 public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
 {
     if (syntaxNode is ClassDeclarationSyntax @class && @class.AttributeLists.Count > 0)
     {
         Candidates.Add(@class);
     }
 }
Esempio n. 4
0
        public override Expression Visit(Expression expression)
        {
            if (expression == null)
            {
                return(null);
            }

            var previousCanBeEvaluated = CanBeEvaluated;

            CanBeEvaluated = true;
            base.Visit(expression);
            if (CanBeEvaluated)
            {
                if (CanEvaluate(expression))
                {
                    Candidates.Add(expression);
                }
                else
                {
                    CanBeEvaluated = false;
                }
            }
            CanBeEvaluated &= previousCanBeEvaluated;
            return(expression);
        }
Esempio n. 5
0
 public void ProcessCandidate(Move move)
 {
     if (IsViable(move))
     {
         Candidates.Add(move);
     }
 }
Esempio n. 6
0
        public void LoadAllCandidatesAndTests()
        {
            Tests.Clear();
            Candidates.Clear();
            TestDefinitions.Clear();

            Test_Definition.Load();
            Candidate.Load();
            Test.Load();

            foreach (Test_Definition td in Test_Definition)
            {
                TestDefinitions.Add(td);
            }


            foreach (Candidate c in Candidate)
            {
                Candidates.Add(c);
                foreach (Test t in c.Test)
                {
                    Tests.Add(t);
                    if (t.Test_Definition == null && t.test_definition_id > 0)
                    {
                        t.Test_Definition = db.Test_Definition.FirstOrDefault(td => td.Id == t.test_definition_id);
                    }
                }
            }
        }
Esempio n. 7
0
        public void SetCandidateShouldWork()
        {
            var candidates = new Candidates(9);

            candidates.Has(1).Should().BeFalse();
            candidates.Add(1).Should().BeTrue();
            candidates.Has(1).Should().BeTrue();
        }
Esempio n. 8
0
        private void AppliesTo(Func <MethodDef, bool> predicate)
        {
            var methods = ClassTypeDef.Methods.Where(predicate);

            foreach (var methodDef in methods)
            {
                Candidates.Add(new Candidate(methodDef));
            }
        }
Esempio n. 9
0
        private void Add(object obj)
        {
            Candidate candidate = new Candidate();

            SetCandidateChange(candidate, currentCandidate);
            Candidates.Add(candidate);
            FillCandidateSkils(candidate);
            context.SaveChanges();
            ClearForm();
        }
Esempio n. 10
0
        private void OnAddCandidate(object sender, RoutedEventArgs e)
        {
            if (Candidates.Count == availableCandidates.Count())
            {
                return;
            }
            var diff  = availableCandidates.Except(Candidates).ToArray();
            var index = random.Next(diff.Count());

            Candidates.Add(diff[index]);
        }
Esempio n. 11
0
        private void GetCandidates(ResourceMapItem resourceMapItem)
        {
            Candidates.Clear();

            foreach (Candidate candidate in EnumerateCandidates(resourceMapItem))
            {
                CandidateViewModel candidateViewModel = new CandidateViewModel(PriFile, PriStream, ResourceRootPath, resourceMapItem, candidate);

                Candidates.Add(candidateViewModel);
            }
        }
Esempio n. 12
0
        public void ProcessCandidate(Move move)
        {
            double score = ScoreCalculator.Calculate(move);

            if (score == Move.RejectScore)
            {
                return;
            }
            move.Score = score;
            Candidates.Add(move);
        }
Esempio n. 13
0
        public bool TryNominate(PlayerMobile pm)
        {
            CityLoyaltyEntry pentry = City.GetPlayerEntry <CityLoyaltyEntry>(pm);

            if (pm.Young)
            {
                pm.SendMessage("Young players cannot be nominated for the ballot!");
            }
            else if (!City.IsCitizen(pm) || pentry == null)
            {
                pm.SendLocalizedMessage(1153890); // You must be a citizen of this City to nominate yourself for the ballot!
            }
            else if (City.GetLoyaltyRating(pm) < LoyaltyRating.Adored)
            {
                pm.SendLocalizedMessage(1153891); // You must at least be adored within the City to nominate yourself for the ballot.
            }
            else
            {
                Account a = pm.Account as Account;
                for (int i = 0; i < a.Length; i++)
                {
                    Mobile m = a[i];

                    if (!(m is PlayerMobile))
                    {
                        continue;
                    }

                    BallotEntry ballot = Candidates.FirstOrDefault(entry => entry.Player == m);

                    if (ballot != null && m is PlayerMobile)
                    {
                        pm.SendLocalizedMessage(ballot.Endorsements.Count > 0 ? 1153917 : 1153889);  // A character from this account is currently endorsed for Candidacy and cannot be nominated.                                                                      // A character from this account has already been nominated to run for office.
                        return(false);                                                               // A character from this account has already been nominated to run for office.
                    }

                    ballot = Candidates.FirstOrDefault(entry => entry.Endorsements.Contains(m));

                    if (ballot != null && m is PlayerMobile)
                    {
                        pm.SendLocalizedMessage(1153892); // A character from this account has already endorsed a nominee!
                        return(false);
                    }
                }

                Candidates.Add(new BallotEntry(pm, pentry.Love, pentry.Hate));
                pm.PrivateOverheadMessage(Network.MessageType.Regular, 0x3B2, 1153905, pm.NetState); // *You etch your name into the stone*
                pm.SendLocalizedMessage(1154087);                                                    // You have 24 hours to get your nomination endorsed. If you do not get an endorsement within that period you will need to re-nominate yourself.

                return(true);
            }

            return(false);
        }
Esempio n. 14
0
 public static bool AddCandidate(Candidate c)
 {
     if (Candidates.Exists(ci => { return(ci.Name.Equals(c.Name)); }))
     {
         return(false);
     }
     else
     {
         Candidates.Add(c);
         return(true);
     }
 }
Esempio n. 15
0
        /// <summary>
        /// unset the value for this cell, deletes all candidates
        /// </summary>
        public void Unset()
        {
            var oldValue = Value;

            Value = 0;
            foreach (int i in Utils.OneToNine)
            {
                Candidates.Add(i);
            }

            _puzzle.AddCandidates(GetCellsVisible(), new[] { oldValue });
        }
Esempio n. 16
0
        private void BtnSearch_OnClick(object sender, RoutedEventArgs e)
        {
            Candidates.Clear();

            Task.Factory.StartNew(() =>
                                  dynamicMemberDatabase.FindCandidates(parsedInputValue, parsedInputValue, parsedOutputValue, 0))
            .ContinueWith(task =>
            {
                foreach (var x in task.Result)
                {
                    Candidates.Add(x);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Esempio n. 17
0
        private async void Conn_OnIceCandidateAsync(RTCPeerConnectionIceEvent __param0)
        {
            var Candidate = __param0.Candidate;
            var m         = new SendCadidatModel();

            m.candidate = new CandidateModel
            {
                candidate     = Candidate.Candidate,
                sdpMid        = Candidate.SdpMid,
                sdpMlineindex = Candidate.SdpMLineIndex
            };
            m.uid = Uid;
            Candidates.Add(m);
            await SendCandidate(m);

            //await SendCand(Candidate);
        }
Esempio n. 18
0
        async private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var container   = new InkRecognizerContainer();
                var recognizers = container.GetRecognizers();
                if (recognizers != null && recognizers.Count > 0)
                {
                    // 以下三行為取得Combobox選擇語系, 並設定語系的辨識引擎
                    string recognizerName = recognizersCombobox.SelectedItem.ToString();
                    var    recognizer     = recognizers.FirstOrDefault((x) => x.Name == recognizerName);
                    if (recognizer != null)
                    {
                        container.SetDefaultRecognizer(recognizer);
                    }
                }
                if (inkCanvas.InkPresenter.StrokeContainer != null)
                {
                    var result = await container.RecognizeAsync(inkCanvas.InkPresenter.StrokeContainer, InkRecognitionTarget.All);

                    string returnText = string.Empty;
                    inkCanvas.InkPresenter.StrokeContainer.Clear();
                    Candidates.Clear();
                    foreach (var r in result)
                    {
                        foreach (var c in r.GetTextCandidates())
                        {
                            Candidates.Add(c);
                        }
                    }
                    listview.Visibility = Visibility.Visible;
                    button.Visibility   = Visibility.Collapsed;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }

            //if (result != null)
            //{
            //    returnText = result[0].GetTextCandidates()[0];
            //}

            //OnRecognized(returnText);
        }
Esempio n. 19
0
        public void TestAdd()
        {
            // invalid case: add not contained value
            Assert.True(tgt.Add(SudokuValue._1)); Assert.Equal(9, tgt.Count());
            Assert.True(tgt.Add(SudokuValue._2)); Assert.Equal(9, tgt.Count());
            Assert.True(tgt.Add(SudokuValue._9)); Assert.Equal(9, tgt.Count());

            // valid case: add already contained value
            tgt.Clear();
            Assert.False(tgt.Add(SudokuValue._1)); Assert.Equal(1, tgt.Count());
            Assert.False(tgt.Add(SudokuValue._2)); Assert.Equal(2, tgt.Count());
            Assert.False(tgt.Add(SudokuValue._9)); Assert.Equal(3, tgt.Count());
        }
Esempio n. 20
0
        public void Build(List <PhotoSession> photoSessions)
        {
            Candidates.Clear();
            Sessions = photoSessions;
            ComputeSessionsScores();

            var rankedSessions = Sessions.OrderByDescending(s => s.Score).ToList();

            while (rankedSessions.Any())
            {
                var mainSession    = rankedSessions.First();
                var nearbySessions = rankedSessions
                                     .Skip(1)
                                     .Where(s => IsNear(mainSession.Location, s.Location)).ToList();

                var newCandidate = new DestinationCandidate(mainSession);

                if (nearbySessions.Count() > 0)
                {
                    newCandidate.Add(nearbySessions.ToList());
                }


                Candidates.Add(newCandidate);
                rankedSessions = rankedSessions
                                 .Skip(1)
                                 .Where(s => !nearbySessions.Contains(s)).ToList();
            }

            // Merge();
            Candidates = Candidates.OrderByDescending(l => l.TotalScore).ToList();

            // fill in the destination  from the session locations
            foreach (var candidate in Candidates)
            {
                var childLocation = candidate.Sessions.Select(s => s.Location).ToList();

                candidate.Location    = _locationService.DetectParentLocation(childLocation);
                candidate.DisplayName = candidate?.Location.DisplayName ?? "Unknown";

                Debug.Assert(candidate.Location != null);
            }
        }
Esempio n. 21
0
        public PresidentCandidatesListViewModel(Entities.PresidentVoting voting, MethodResult canCandidateResult, bool canVote)
        {
            foreach (var candidate in voting.PresidentCandidates.ToList())
            {
                Candidates.Add(new PresidentCandidateViewModel(candidate));
            }

            Info = new CountryInfoViewModel(voting.Country);

            ElectionDay  = voting.StartDay;
            CanCandidate = canCandidateResult.isSuccess;
            if (CanCandidate == false)
            {
                CannotCandidateReason = canCandidateResult.Errors[0].ToString();
            }

            IsElectionDay = voting.VotingStatusID == (int)VotingStatusEnum.Ongoing;
            CanVote       = canVote;
        }
Esempio n. 22
0
        private void LoadCandidatesQualifiedForOpening(ViewQualifiedCandidatesForOpeningViewMessage obj)
        {
            SelectedCandidate = new Candidate();

            var placements = PlacementService.GetAllPlacements().Where(d => d.OpeningId == obj.Opening.Id);

            Opening = obj.Opening;
            var candidates = CandidateService.GetCandidatesQualifiedForRequiredQualification(obj.RequiredQualificationId);

            Candidates.Clear();
            foreach (var v in candidates)
            {
                if (placements.Any(d => d.CandidateId == v.Id && d.OpeningId == Opening.Id))
                {
                    continue;
                }
                Candidates.Add(v);
            }
            //TODO might want to use DTO instead of full candidate soon
        }
        async private void RecognizeButton_Click(object sender, RoutedEventArgs e)
        {
            var strokes = inkCanvas.InkPresenter.StrokeContainer.GetStrokes();

            if (strokes.Count <= 0)
            {
                return;
            }
            var result =
                await Container.RecognizeAsync(inkCanvas.InkPresenter.StrokeContainer, InkRecognitionTarget.All);

            Candidates.Clear();
            foreach (var item in result)
            {
                foreach (var candidate in item.GetTextCandidates())
                {
                    Candidates.Add(candidate);
                }
            }
        }
Esempio n. 24
0
        public Candidates unserializeCandidates(string srcfile, string position)
        {
            Candidates candidates = new Candidates();

            if (File.Exists(srcfile))
            {
                using (StreamReader sr = new StreamReader(srcfile, Encoding.UTF8))
                {
                    string name;
                    while ((name = sr.ReadLine()) != null)
                    {
                        if (name != String.Empty)
                        {
                            Candidate candidate = new Candidate(name, position);
                            candidates.Add(candidate);
                        }
                    }
                }
            }
            return(candidates);
        }
        private async Task InitializeCandidates()
        {
            try
            {
                Candidates.Clear();
                var candidates = await Task.FromResult(GetCandidates());

                foreach (var candidate in candidates)
                {
                    Candidates.Add(new CandidateLookupItem()
                    {
                        Candidate = candidate, IsChecked = CandidateHasVote(candidate, Person)
                    });
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.WriteLine(ex.Message);
#endif
                //TODO: Logger
            }
        }
Esempio n. 26
0
        public void Set(int newValue, bool refreshOtherCellCandidates = false)
        {
            int oldValue = Value;

            Value = newValue;
            if (newValue == 0)
            {
                foreach (int i in Utils.OneToNine)
                {
                    Candidates.Add(i);
                }
                _puzzle.ChangeCandidates(GetCellsVisible(), oldValue, remove: false);
            }
            else
            {
                Candidates.Clear();
                _puzzle.ChangeCandidates(GetCellsVisible(), newValue);
            }
            if (refreshOtherCellCandidates)
            {
                _puzzle.RefreshCandidates();
            }
        }
Esempio n. 27
0
        public void CheckMatch(string str, int index)
        {
            var           c = str[index];
            DelimiterType typeOfDelimiter;

            if (_delimiter.IsDelimiter(c, out typeOfDelimiter))
            {
                switch (typeOfDelimiter)
                {
                case DelimiterType.Start:
                    var candidate = new MatchingCandidate(str, index);
                    _openCandidates.Add(candidate);
                    Candidates.Add(candidate);
                    break;

                case DelimiterType.End:
                    var matchingCandidate = _openCandidates.Last();
                    matchingCandidate.AppendDelimiterEnd(c);
                    _openCandidates.Remove(matchingCandidate);
                    break;

                case DelimiterType.StartContinue:
                    _openCandidates.Last().AppendDelimiterStart(c);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else
            {
                foreach (var candidate in _openCandidates)
                {
                    candidate.Append(c);
                }
            }
        }
Esempio n. 28
0
        public async Task CreateReceiver(MediaStream mediaStream, long fromUid)
        {
            var conn = new RTCPeerConnection(RtcConfig);

            CurrentRoom.Recvs.Add(fromUid, conn);
            CurrentRoom.Recvs[fromUid].AddStream(mediaStream);
            CurrentRoom.Recvs[fromUid].OnIceCandidate += async(p) =>
            {
                var Candidate = p.Candidate;
                var m         = new SendCadidatModel();
                m.candidate = new CandidateModel
                {
                    candidate     = Candidate.Candidate,
                    sdpMlineindex = Candidate.SdpMLineIndex,
                    sdpMid        = Candidate.SdpMid,
                };
                m.uid     = Uid;
                m.fromUid = fromUid;
                Candidates.Add(m);
                await SendCandidate(m);
            };
            CurrentRoom.Recvs[fromUid].OnAddStream += (p) =>
            {
                var stream = p.Stream;

                var videotracks = stream.GetVideoTracks();


                var source = LocalMedia.CreateMediaSource(videotracks.FirstOrDefault(), stream.Id);

                RemoteMediaPlayer.SetMediaStreamSource(source);

                RemoteMediaPlayer.Play();
            };

            await CreatOffer(Uid, fromUid);
        }
        public async Task InitializeAsync()
        {
            IsBusy = true;

            try
            {
                var candidates = await recruitmentQueryService.GetAcceptedCandidatesAsync();

                Candidates.Clear();

                foreach (var candidate in candidates)
                {
                    Candidates.Add(candidate);
                }
            }
            catch (Exception exc)
            {
                await alertService.DisplayAlertAsync(string.Empty, "Something went wrong", "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Dispatches the expression to one of the more specialized visit methods in this class.
        /// </summary>
        /// <param name="node">The expression to visit.</param>
        /// <returns>
        /// The modified expression, if it or any subexpression was modified; otherwise, returns the
        /// original expression.
        /// </returns>
        public override Expression Visit(Expression node)
        {
            if (node is null)
            {
                return(node !);
            }
            var saveCannotBeEvaluated = CanNotBeEvaluated;

            CanNotBeEvaluated = false;
            base.Visit(node);
            if (!CanNotBeEvaluated)
            {
                if (FunctionCanBeEvaluated(node))
                {
                    Candidates.Add(node);
                }
                else
                {
                    CanNotBeEvaluated = true;
                }
            }
            CanNotBeEvaluated |= saveCannotBeEvaluated;
            return(node);
        }