Exemplo n.º 1
0
        /// <summary>
        /// Creates a new entity of the MatchMessage
        /// </summary>
        /// <param name="action">The current action</param>
        /// <param name="dict">The dictionary with parameters</param>
        public MatchMessage(MatchAction action, Dictionary<string, object> dict)
            : base(Schiffchen.Logic.Enum.Type.Match)
        {
            this.Action = action;
            switch (action)
            {
                case MatchAction.Diceroll:
                    this.Dice = (Int32)dict["dice"];
                    break;
                case MatchAction.Shot:
                    this.X = (Int32)dict["x"];
                    this.Y = (Int32)dict["y"];
                    break;
                case MatchAction.Shotresult:
                    this.X = (Int32)dict["x"];
                    this.Y = (Int32)dict["y"];
                    this.Result = (String)dict["result"];
                    break;
                case MatchAction.Gamestate:
                    this.Looser = (String)dict["looser"];
                    this.State = (String)dict["state"];
                    break;

            }
        }
Exemplo n.º 2
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;

            if (grdAction.SelectedIndex < 0)
            {
                return;
            }

            MatchAction ma = grdAction.SelectedItem as MatchAction;

            if (menuItem.Tag.ToString() == "update")
            {
                UpdateMatchAction updateMatchAction = new UpdateMatchAction(ma.ActionNumberID);
                updateMatchAction.ShowDialog();
            }
            else if (menuItem.Tag.ToString() == "del")
            {
                if (System.Windows.Forms.DialogResult.OK == GVAR.MsgBox("Are you confirm to delete the current  action? ",
                                                                        "Warning", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning))
                {
                    GVAR.g_ManageDB.DeleteMatchAction(ma.ActionNumberID);
                }
            }

            InitialActionDataGrid(m_curMatchID);
        }
Exemplo n.º 3
0
        /*
         *      public async Task<IActionResult> GetUserMatches()
         *      {
         *          var currentUser = await GetCurrentUser();
         *
         *
         *          var matchs = (await _matchRepository.GetUserMatches(currentUser))
         *                                              .OrderByDescending(m => m.MatchedSince)
         *                                              .ToList();
         *
         *
         *
         *
         *      }
         *
         */

        public async Task <IActionResult> CreateMatchAction(CreateMatchActionDTO createMatchActionDto)
        {
            if (!Guid.TryParse(createMatchActionDto.LikedUserGuid, out Guid likedUserGUid))
            {
                return(BadRequest());
            }

            var likedUser = await _userRepository.GetByGuidAsync(likedUserGUid);

            if (likedUser == null)
            {
                return(NotFound());
            }

            var currentUser = await GetCurrentUser();

            var newMatchAction = new MatchAction(currentUser, likedUser, createMatchActionDto.MatchActionStatus);

            newMatchAction = await _matchActionRepository.CreateMatchActionAsync(newMatchAction);

            if (await _matchActionRepository.IsFullMatchAsync(newMatchAction))
            {
                var newMatch = new Match()
                {
                };
                //TODO: Make a full match
                var savedMatch = await _matchRepository.CreateNewMatchAsync(newMatch);
            }

            await _matchRepository.SaveAsync();

            return(Ok());
        }
Exemplo n.º 4
0
        public async Task <bool> IsFullMatchAsync(MatchAction matchAction)
        {
            var userIds = new[] { matchAction.LikedID, matchAction.LikerID };

            return(await _tunderDbContext.MatchActions.CountAsync(m =>
                                                                  userIds.Contains(m.LikedID) &&
                                                                  userIds.Contains(m.LikerID) &&
                                                                  m.Status == MatchActionStatus.Liked) == 2);
        }
Exemplo n.º 5
0
        public void ShouldHandleNullPattern()
        {
            var action = new MatchAction<string>
            {
                {"a", s => state = PatternAInvocation},
                {Match.Null, s => state = NullPatternInvocation}
            }.Action;

            action(null);

            AssertStateIs(NullPatternInvocation);
        }
    public RemoveExistingRowsBuilder AutoValidityIfValueChanged()
    {
        MatchButDifferentAction = new MatchAction(MatchMode.Custom)
        {
            CustomAction = (row, match) =>
            {
                row[TableBuilder.ValidFromColumn.Name] = TableBuilder.DwhBuilder.EtlRunIdAsDateTimeOffset.Value;
                row[TableBuilder.ValidToColumnName]    = TableBuilder.DwhBuilder.Configuration.InfiniteFutureDateTime;
            },
        };

        return(this);
    }
        public void ShouldCallDefaultActionWhenPatternDoesNotMatchAndDefaultIsSpecified()
        {
            var action = new MatchAction<string, int>
            {
                {"a", 3, (s, i) => state = PatternAAnd3Invocation},
                {"b", 5, (s, i) => state = PatternBAnd5Invocation},
                { Match.Default, (s, i) => state = DefaultInvocation }
            }.Action;

            action("c", 7);

            AssertStateIs(DefaultInvocation);
        }
        public void ShouldEvaluatePredicatesForAllArgumentsWhenMatchingPatterns()
        {
            var action = new MatchAction<string, int>
            {
                {"a", 3, (s, i) => state = PatternAAnd3Invocation},
                {s => s.StartsWith("d"), i => i > 10 && i < 15, (s, i) => state = PredicatePatternInvocation},
                { Match.Default, (s, i) => state = DefaultInvocation }
            }.Action;

            action("dcx", 12);

            AssertStateIs(PredicatePatternInvocation);
        }
Exemplo n.º 9
0
        public void ShouldEvaluatePredicateWhenMatchingPatterns()
        {
            var action = new MatchAction<string>
            {
                {"a", s => state = PatternAInvocation},
                {s => s.StartsWith("d"), s => state = PredicatePatternInvocation},
                { Match.Default, s => state = DefaultInvocation }
            }.Action;

            action("dcx");

            AssertStateIs(PredicatePatternInvocation);
        }
        public void ShouldCallProperActionWhenPatternMatches()
        {
            var action = new MatchAction<string, int>
            {
                {"a", 3, (s, i) => state = PatternAAnd3Invocation},
                {"b", 5, (s, i) => state = PatternBAnd5Invocation},
                {"c", 7, (s, i) => state = PatternCAnd7Invocation}
            }.Action;

            action("a", 3);

            AssertStateIs(PatternAAnd3Invocation);
        }
Exemplo n.º 11
0
        public void ShouldCallProperActionWhenPatternMatches()
        {
            var action = new MatchAction<string>
            {
                {"a", s => state = PatternAInvocation},
                {"b", s => state = PatternBInvocation},
                {"c", s => state = PatternCInvocation}
            }.Action;

            action("a");

            AssertStateIs(PatternAInvocation);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the args Type for the specified action.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static Type GetArgsType(this MatchAction action)
        {
            if (action == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(action.ArgsType))
            {
                return(null);
            }

            return(Type.GetType(action.ArgsType));
        }
Exemplo n.º 13
0
        public void ShouldCallDefaultActionWhenPatternDoesNotMatchAndDefaultIsSpecified()
        {
            var action = new MatchAction<string>
            {
                {"a", s => state = PatternAInvocation},
                {"b", s => state = PatternBInvocation},
                { Match.Default, s => state = DefaultInvocation }
            }.Action;

            action("c");

            AssertStateIs(DefaultInvocation);
        }
Exemplo n.º 14
0
        private void MatchUrl(string htmlText, MatchAction action)
        {
            int length;
            GlossaryLinkItem linkItem = GlossaryManager.Instance.SuggestLink(htmlText, out length);

            if (linkItem != null && length > 0)
            {
                string matchText = htmlText.Substring(htmlText.Length - length, length);

                MarkupRange insertMarkupRange = _blogPostHtmlEditorControl.SelectedMarkupRange.Clone();
                for (int i = 0; i < length; i++)
                {
                    insertMarkupRange.Start.MoveUnit(_MOVEUNIT_ACTION.MOVEUNIT_PREVCHAR);
                }

                action(matchText, linkItem, insertMarkupRange);
            }
        }
        /// <summary>
        /// Creates a new instance of the EditRuleWindow.
        /// </summary>
        /// <param name="router">A reference to the current RoutingEngine instance.</param>
        /// <param name="rule">Either a MatchAction to edit, or null to crate a new MatchAction.</param>
        public EditRuleWindow(RoutingEngine router, MatchAction rule)
        {
            this.router = router;
            InitializeComponent();

            this.cmbSource.ItemsSource = this.router.Sources;
            this.cmbDest.ItemsSource   = this.router.Destinations;

            if (rule != null)
            {
                this.rule = rule;
                this.cmbSource.SelectedValue = rule.MatchSource;
                if (rule.GetMatchType().IsEnum)
                {
                    ((ComboBox)this.matchBorder.Child).SelectedValue = rule.Match;
                }
                else
                {
                    ((TextBox)this.matchBorder.Child).Text = rule.Match.ToString();
                }
                this.cmbDest.SelectedValue   = rule.ActionDestination;
                this.cmbAction.SelectedValue = rule.Action.ToString(CultureInfo.InvariantCulture);
                if (rule.GetArgsType().IsEnum)
                {
                    ((ComboBox)this.argsBorder.Child).SelectedValue = rule.Args;
                }
                else
                {
                    ((TextBox)this.argsBorder.Child).Text = rule.Args.ToString();
                }
                this.CheckEnabled.IsChecked = rule.Enabled;
            }
            else
            {
                this.Title = Properties.Resources.NEW_RULE;
                this.rule  = new MatchAction();
                this.matchBorder.IsEnabled = false;
                this.cmbAction.IsEnabled   = false;
                this.argsBorder.IsEnabled  = false;
            }

            this.initializing = false;
            CheckOK();
        }
        public int MoveRule(MatchAction rule, int direction)
        {
            lock (this.lockObject) {
                int index    = this.Rules.IndexOf(rule);
                int newIndex = index + direction;

                if ((newIndex < 0) || (newIndex >= this.Rules.Count))
                {
                    return(-1); // Index out of range - nothing to do
                }

                // Removing removable element
                this.Rules.Remove(rule);
                // Insert it in new position
                this.Rules.Insert(newIndex, rule);

                return(newIndex);
            }
        }
Exemplo n.º 17
0
        private void InitialUserControl(int actionNumberID)
        {
            MatchAction matchActoin = GVAR.g_ManageDB.GetSingleMatchActioin(GVAR.g_matchID, actionNumberID);

            if (matchActoin == null)
            {
                return;
            }

            InitialComboBox_Period(matchActoin.Period);
            InitialComboBox_Action();
            InitialComboBox_ShirtNumber(matchActoin.ComPos);

            txtTime.Text      = matchActoin.MatchTime;
            txtNoc.Text       = matchActoin.Noc;
            txtScorehome.Text = matchActoin.ScoreHome.ToString();
            txtScoreaway.Text = matchActoin.ScoreAway.ToString();

            cbShirtNumber.SelectedValue = matchActoin.ShirtNumber;
            cbAction.SelectedValue      = matchActoin.ActionTypeID;
        }
Exemplo n.º 18
0
        private void ButtonOK_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtScoreaway.Text) || string.IsNullOrWhiteSpace(txtScorehome.Text) || string.IsNullOrWhiteSpace(txtTime.Text))
            {
                GVAR.MsgBox("Can not have empty field!");
                return;
            }

            string regRule = @"^\d{2}:\d{2}$";
            Regex  regex   = new Regex(regRule);
            Match  m       = regex.Match(txtTime.Text);

            if (!m.Success)
            {
                GVAR.MsgBox("time pattern is error. must be 05:34");
                return;
            }

            try
            {
                MatchAction matchAction = new MatchAction();
                matchAction.ActionNumberID = m_actionNumberID;
                matchAction.ActionTypeID   = int.Parse(cbAction.SelectedValue.ToString());
                matchAction.Period         = int.Parse(cbPeriod.SelectedValue.ToString());
                matchAction.MatchTime      = txtTime.Text;
                matchAction.ScoreHome      = int.Parse(txtScorehome.Text);
                matchAction.ScoreAway      = int.Parse(txtScoreaway.Text);
                matchAction.ShirtNumber    = int.Parse(cbShirtNumber.SelectedValue.ToString());

                GVAR.g_ManageDB.UpdateMatchAction(matchAction);
            }
            catch
            {
            }
            finally
            {
                ClosewindowEvent();
            }
        }
Exemplo n.º 19
0
 private bool MatchAny(Expression e, MatchAction ma)
 {
     ma(e);
     return true;
 }
 public void AddRule(MatchAction rule)
 {
     lock (this.lockObject) {
         this.Rules.Add(rule);
     }
 }
        public void ShouldNotCallAnyActionWhenPatternDoesNotMatch()
        {
            var action = new MatchAction<string, int>
            {
                {"a", 3, (s, i) => state = PatternAAnd3Invocation},
                {"b", 5, (s, i) => state = PatternBAnd5Invocation}
            }.Action;

            action("c", 12);

            AssertStateIs(NotChangedByTest);
        }
Exemplo n.º 22
0
        public void ShouldNotCallAnyActionWhenPatternDoesNotMatch()
        {
            var action = new MatchAction<string>
            {
                {"a", s => state = PatternAInvocation},
                {"b", s => state = PatternBInvocation}
            }.Action;

            action("c");

            AssertStateIs(NotChangedByTest);
        }
Exemplo n.º 23
0
 public Segment(MatchAction action, IToken token, Cardinality cardinality)
 {
     this.Action      = action;
     this.Item        = token;
     this.Cardinality = cardinality;
 }
Exemplo n.º 24
0
        public void AddAction()
        {
            if (m_matchMemberAndAction == null || String.IsNullOrWhiteSpace(m_selectedActionCode))
            {
                return;
            }

            #region 根据ActionCode和Active(是否在场)进行判断操作是否有效
            switch (m_selectedActionCode)
            {
            case "In":
                if (!m_matchMemberAndAction.Active)
                {
                    GVAR.g_ManageDB.UpdateActiveInMember(m_curMatchID, m_matchMemberAndAction.ComPos, m_matchMemberAndAction.RegisterID, 1);
                }
                else
                {
                    PopUpWindow(MyPopUpWindowType.OnCourt);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "Try":
                if (m_matchMemberAndAction.Active)
                {
                    AddScoreByCompos(m_matchMemberAndAction.ComPos, GVAR.Score_Try);
                }
                else
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "PT":
                if (m_matchMemberAndAction.Active)
                {
                    AddScoreByCompos(m_matchMemberAndAction.ComPos, GVAR.Score_Try);
                }
                else
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "CG":
                if (m_matchMemberAndAction.Active)
                {
                    AddScoreByCompos(m_matchMemberAndAction.ComPos, GVAR.Score_ConversionGoal);
                }
                else
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "CM":
                if (!m_matchMemberAndAction.Active)
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "PG":
                if (m_matchMemberAndAction.Active)
                {
                    AddScoreByCompos(m_matchMemberAndAction.ComPos, GVAR.Score_PenaltyGoal);
                }
                else
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "PM":
                if (!m_matchMemberAndAction.Active)
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "DG":
                if (m_matchMemberAndAction.Active)
                {
                    AddScoreByCompos(m_matchMemberAndAction.ComPos, GVAR.Score_DropGoal);
                }
                else
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "DM":
                if (!m_matchMemberAndAction.Active)
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "Out":
                if (m_matchMemberAndAction.Active)
                {
                    GVAR.g_ManageDB.UpdateActiveInMember(m_curMatchID, m_matchMemberAndAction.ComPos, m_matchMemberAndAction.RegisterID, 0);
                }
                else
                {
                    PopUpWindow(MyPopUpWindowType.OnBench);
                    InitialMemberAndActioin();
                    return;
                }
                break;

            case "YCard":
                break;

            case "2YCard":
                break;

            case "RCard":
                if (m_matchMemberAndAction.Active)
                {
                    GVAR.g_ManageDB.UpdateActiveInMember(m_curMatchID, m_matchMemberAndAction.ComPos, m_matchMemberAndAction.RegisterID, 0);
                }
                break;

            default:
                break;
            }
            #endregion

            MatchAction matchAction = new MatchAction
            {
                MatchID        = m_curMatchID,
                MatchSplitID   = GVAR.g_period,
                RegisterID     = m_matchMemberAndAction.RegisterID,
                ComPos         = m_matchMemberAndAction.ComPos,
                MatchTime      = GetActionTime(true),
                ScoreHome      = m_homeTeamScore.ScoreTotal,
                ScoreAway      = m_awayTeamScore.ScoreTotal,
                ActionTypeCode = m_selectedActionCode
            };

            GVAR.g_ManageDB.AddMatchAction(matchAction);

            txtLastName.Text   = m_selectedPlayerName;
            txtLastAction.Text = m_selectedActionName;

            InitialAwayMemnberDataGrid(m_curMatchID);
            InitialHomeMemnberDataGrid(m_curMatchID);
            InitialActionDataGrid(m_curMatchID);

            InitialMemberAndActioin();
        }
        private void MatchUrl(string htmlText, MatchAction action)
        {
            int length;
            GlossaryLinkItem linkItem = GlossaryManager.Instance.SuggestLink(htmlText, out length);
            if (linkItem != null && length > 0)
            {
                string matchText = htmlText.Substring(htmlText.Length - length, length);

                MarkupRange insertMarkupRange = _blogPostHtmlEditorControl.SelectedMarkupRange.Clone();
                for (int i = 0; i < length; i++)
                    insertMarkupRange.Start.MoveUnit(_MOVEUNIT_ACTION.MOVEUNIT_PREVCHAR);

                action(matchText, linkItem, insertMarkupRange);
            }
        }
Exemplo n.º 26
0
        public void ShouldInvokeOnlyFirstMatch()
        {
            var action = new MatchAction<string>
            {
                {"a", s => state = PatternAInvocation},
                {"a", s => state = PatternASecondInvocation},
                { Match.Default, s => state = DefaultInvocation }
            }.Action;

            action("a");

            AssertStateIs(PatternAInvocation);
        }
Exemplo n.º 27
0
 public Router AddRoute(Method Method, string Path, MatchAction Handler) => AddRoute(Method, Path, (r, d) => Handler(r));
Exemplo n.º 28
0
 public RegexActionPair(Regex regex, MatchAction matchAction)
 {
     Regex       = regex;
     MatchAction = matchAction;
 }
        public void ShouldHandleNullPattern()
        {
            var action = new MatchAction<string, int?>
            {
                {"a", 3, (s, i) => state = PatternAAnd3Invocation},
                {Match.Null, (s, i) => state = NullPatternInvocation}
            }.Action;

            action(null, null);

            AssertStateIs(NullPatternInvocation);
        }
Exemplo n.º 30
0
        private void CreateRuleReferencingSet(string setName, MatchDirection direction = MatchDirection.SOURCE, MatchAction action = MatchAction.DROP)
        {
            string dirStr = direction == MatchDirection.DEST ? "daddr" : "saddr";
            string actStr = string.Empty;

            switch (action)
            {
            case MatchAction.ACCEPT:
                actStr = "accept";
                break;

            case MatchAction.DROP:
            default:
                actStr = "drop";
                break;
            }

            string cmd    = $@"sudo nft add rule {HostConfig.Table} {HostConfig.Chain} ip {dirStr} @{setName} {actStr}";
            bool   result = Connector.ExecuteCommand(cmd);
        }
 public void RemoveRule(MatchAction rule)
 {
     lock (this.lockObject) {
         this.Rules.Remove(rule);
     }
 }
Exemplo n.º 32
0
 public Router PUT(string Path, MatchAction Handler) => AddRoute(Method.PUT, Path, Handler);
Exemplo n.º 33
0
 public Router DELETE(string Path, MatchAction Handler) => AddRoute(Method.DELETE, Path, Handler);
Exemplo n.º 34
0
 private bool MatchAny(Expression e, MatchAction ma)
 {
     ma(e);
     return(true);
 }
Exemplo n.º 35
0
 public SequenceStep(IParseFunction parseFunction, MatchAction matchAction)
 {
     this.Function    = parseFunction;
     this.MatchAction = matchAction;
 }
Exemplo n.º 36
0
 public Router HEAD(string Path, MatchAction Handler) => AddRoute(Method.HEAD, Path, Handler);
Exemplo n.º 37
0
        public async Task <MatchAction> CreateMatchActionAsync(MatchAction matchAction)
        {
            await _tunderDbContext.MatchActions.AddAsync(matchAction);

            return(matchAction);
        }