예제 #1
0
        public IHttpActionResult Post(int matchId, [FromBody] EntryToAdd entryToAdd)
        {
            List <FishingMatch> fishingMatches = DataFileService.GetDataFile <FishingMatch>(DataFileType.Matches).ToList();

            FishingMatch fishingMatch = fishingMatches.SingleOrDefault(match => match.Id == matchId);

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

            var matchEntry = new MatchEntry
            {
                AnglerName = entryToAdd.AnglerName,
                AnglerId   = entryToAdd.AnglerId,
                Peg        = entryToAdd.Peg,
                Weight     = entryToAdd.Pounds + (entryToAdd.Ounces / OuncesInPound)
            };

            fishingMatch.MatchEntries.Add(matchEntry);

            fishingMatch.CalculateMatchPoints();

            DataFileService.WriteDataFile(DataFileType.Matches, fishingMatches);

            return(Created(string.Empty, entryToAdd));
        }
예제 #2
0
        /// <summary>
        /// The Init method is invoked to initialize an instance
        /// of the matcher with a version definition registry that
        /// it can use to lookup information about vesions as it is
        /// matching messages.
        /// </summary>
        /// <param name="registry">
        /// The version definition registry that the matcher is to
        /// use when looking up version information.
        /// </param>
        public void Init(IVfxFixVxRegistry registry)
        {
            // REC: Iterate over all of the version definitions
            // in the registry and construct corresponding match
            // entries for the matcher:
            foreach (VfxFixVxRecord vxRecord in registry)
            {
                // REC: The version name:
                string vxName = vxRecord.Name;

                MatchEntry matchEntry = new MatchEntry();

                matchEntry.Name = vxName;
                VfxFixVxRecord vxDetails = registry.Get(vxName);
                foreach (VfxFixVersion_Rule vxRule in vxDetails.Rules)
                {
                    matchEntry.Rules.Add(vxRule);
                }

                if (!_mapLayers.ContainsKey(vxDetails.Layer))
                {
                    _mapLayers.Add(vxDetails.Layer, new List <MatchEntry>());
                }

                _mapLayers[vxDetails.Layer].Add(matchEntry);
            }
        }
예제 #3
0
        private static List <ChampionshipRound> GetChampionshipRounds(IEnumerable <FishingMatch> matches, string anglerName)
        {
            var rounds = new List <ChampionshipRound>();
            var championshipRoundIndex = 1;

            foreach (FishingMatch match in matches)
            {
                MatchEntry anglerMatchEntry  = match.MatchEntries.SingleOrDefault(matchEntry => matchEntry.AnglerName == anglerName);
                var        championshipRound = new ChampionshipRound
                {
                    Number      = championshipRoundIndex,
                    Weight      = 0,
                    Points      = 0,
                    MatchFished = false
                };

                if (anglerMatchEntry != null)
                {
                    championshipRound.Weight      = anglerMatchEntry.Weight;
                    championshipRound.Points      = anglerMatchEntry.Points;
                    championshipRound.MatchFished = true;
                }

                rounds.Add(championshipRound);
                championshipRoundIndex += 1;
            }

            return(rounds);
        }
                protected LexerArgumentBuilder(MatchEntry matchEntry)
                {
                    MatchEntry = matchEntry;

                    if (matchEntry is SingleMatchEntry singleMatchEntry)
                    {
                        StaticLexemeText = StaticLexemes[singleMatchEntry.IntOperand];
                    }
                }
예제 #5
0
 private Node ConnectEntry(Node source, Entry entry)
 {
     return(entry switch
     {
         MatchEntry matchEntry => ConnectMatch(source, matchEntry),
         StateEntry stateEntry => ConnectState(source, stateEntry, stateEntry.State.Inline || Automata.ForceInlineAll),
         QuantifierEntry quantifierEntry => ConnectQuantifier(source, quantifierEntry),
         PredicateEntryBase predicateEntry => ConnectPredicate(source, predicateEntry),
         ActionEntry actionEntry => ConnectAction(source, actionEntry),
         EpsilonEntry _ => source,
         _ => throw new ArgumentOutOfRangeException(nameof(entry))
     });
예제 #6
0
        public IEnumerable <PairResult> GetPairsMatch([FromUri] int id)
        {
            FishingMatch fishingMatch = Get(id);
            var          pairResults  = new List <PairResult>();

            if (!fishingMatch.IsPairs)
            {
                return(pairResults);
            }

            foreach (MatchEntry matchEntry in fishingMatch.MatchEntries)
            {
                bool toAdd = !pairResults.Any(pair => pair.Peg1 == matchEntry.Peg || pair.Peg2 == matchEntry.Peg);

                if (!toAdd)
                {
                    continue;
                }

                var matchEntryPair = new List <MatchEntry> {
                    matchEntry
                };

                MatchEntry pairedMatchEntry = fishingMatch.MatchEntries.Single(me => me.PairedWithPeg == matchEntry.Peg);
                matchEntryPair.Add(pairedMatchEntry);

                var pairResult = new PairResult
                {
                    Angler1 = matchEntryPair[0].AnglerName,
                    Angler2 = matchEntryPair[1].AnglerName,
                    Peg1    = matchEntryPair[0].Peg,
                    Peg2    = matchEntryPair[1].Peg,
                    Weight  = matchEntryPair[0].Weight + matchEntryPair[1].Weight
                };

                if (pairResult.Peg1 == pairResult.Peg2)
                {
                    pairResult.Peg2    = null;
                    pairResult.Angler2 = "(weight doubled)";
                }

                pairResults.Add(pairResult);
            }

            return(pairResults.OrderByDescending(result => result.Weight));
        }
예제 #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (PropMask?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)VariousPropertyBits;
         hashCode = (hashCode * 397) ^ (Caption?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)PicturePosition;
         hashCode = (hashCode * 397) ^ (int)MousePointer;
         hashCode = (hashCode * 397) ^ (Accelerator?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Size?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Picture?.Length.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (MouseIcon?.Length.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (TextProps?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)MaxLength;
         hashCode = (hashCode * 397) ^ (int)BorderStyle;
         hashCode = (hashCode * 397) ^ (ScrollBars?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ DisplayStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ (PasswordChar?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)ListWidth;
         hashCode = (hashCode * 397) ^ BoundColumn.GetHashCode();
         hashCode = (hashCode * 397) ^ TextColumn.GetHashCode();
         hashCode = (hashCode * 397) ^ ColumnCount.GetHashCode();
         hashCode = (hashCode * 397) ^ ListRows.GetHashCode();
         hashCode = (hashCode * 397) ^ ColumnInfoCount.GetHashCode();
         hashCode = (hashCode * 397) ^ MatchEntry.GetHashCode();
         hashCode = (hashCode * 397) ^ ListStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ ShowDropButtonWhen.GetHashCode();
         hashCode = (hashCode * 397) ^ DropButtonStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ MultiSelect.GetHashCode();
         hashCode = (hashCode * 397) ^ (BorderColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)SpecialEffect;
         hashCode = (hashCode * 397) ^ (Value?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (GroupName?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Remainder?.Length.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
예제 #8
0
            public ExecutionPath(Node pathSourceNode, Node[] route, int weight, params MatchEntry[] match)
            {
                PathSourceNode = pathSourceNode;
                Nodes          = route;
                IsInvalid      = Nodes == null || Nodes.Length == 0;
                Output         = IsInvalid ? null : Nodes[Nodes.Length - 1];

                if (match == null || match.Length == 0)
                {
                    IsReturnPath   = true;
                    LookAheadMatch = Array.Empty <MatchEntry>();
                }
                else
                {
                    Match          = match[0];
                    LookAheadMatch = match;
                }

                Weight = weight;

                CalcInfo(ref Weight, out PassLazyNode, out EnterReturnNodes, out StackEvalDelta);
            }
예제 #9
0
        public MatchEntry Pick(DateTime timepoint, int cnt = 0)
        {
            var query = _matchList.Where(x => (x.Timepoint.Equals(timepoint) && x.Cnt == cnt));
            int qcnt  = query.Count();

            if (qcnt != 1)
            {
                if (SearchMode)
                {
                    var matches    = FileList.Where(x => DateEqual(x.Timepoint, timepoint)).ToList();
                    var matchEntry = new MatchEntry(timepoint, matches, cnt);
                    _matchList.Add(matchEntry);
                    return(matchEntry);
                }
                else
                {
                    throw new ArgumentException($"Invalid number of entries found ({qcnt}), 1 expected");
                }
            }

            return(query.First());
        }
예제 #10
0
 public OperandNode(Automata <TInstruction, TOperand> automata, Graph graph, MatchEntry matchEntry) : base(automata, graph)
 {
     MatchEntry = matchEntry;
 }
예제 #11
0
파일: Automata.Edge.cs 프로젝트: Egaros/lib
 public Edge(Node sourceNode, Node targetNode, MatchEntry operandMatch, int weight = 0) : this(sourceNode, targetNode, weight)
 {
     OperandMatch = operandMatch;
     IsMatch      = true;
 }
 public ExternalLexemeArgumentBuilder(Type argumentType, MatchEntry matchEntry) : base(argumentType, matchEntry)
 {
 }
 protected override void BuildInvoke(ILBuilderContext ilBuilderContext, MatchEntry matchEntry, bool main)
 {
 }
 private static ArgumentBuilder CreateLexerArgumentBuilder(Type type, Type converterType, MatchEntry matchEntry)
 {
     return(new LocalLexerArgumentBuilder(type, matchEntry));
 }
                protected override void BuildInvoke(ILBuilderContext ilBuilderContext, MatchEntry matchEntry, bool main)
                {
                    if (main == false)
                    {
                        return;
                    }

                    var parserEntry = matchEntry switch
                    {
                        ParserSingleMatchEntry s => s.ParserEntryData,
                        ParserSetMatchEntry s => s.ParserEntryData,
                        _ => throw new ArgumentOutOfRangeException()
                    };

                    if (parserEntry.FlatIndex == -1)
                    {
                        return;
                    }

                    var parserProduction = parserEntry.ParserProduction;

                    if (parserProduction == null)
                    {
                        return;
                    }

                    if (parserProduction.IsInline)
                    {
                        return;
                    }

                    var entryBuilder = parserProduction.Binder.Template[parserEntry.FlatIndex];

                    if (entryBuilder == null)
                    {
                        return;
                    }

                    if (!(entryBuilder is LexerArgumentBuilder lexerArgumentBuilder))
                    {
                        throw new InvalidOperationException();
                    }

                    ilBuilderContext.EmitLdContext();
                    ilBuilderContext.IL.Emit(OpCodes.Call, PeekStateEntryMethodInfo);
                    ilBuilderContext.IL.Emit(OpCodes.Ldfld, ProductionInstanceBuilderArgumentsFieldInfo);
                    ilBuilderContext.IL.Emit(OpCodes.Ldc_I4, parserEntry.FlatIndex);
                    ilBuilderContext.IL.Emit(OpCodes.Ldelem_Ref);

                    lexerArgumentBuilder.EmitConsumeValue(this, ilBuilderContext);

                    if (parserProduction.Binder.TryReturn)
                    {
                        ilBuilderContext.EmitLdContext();
                        ilBuilderContext.IL.Emit(OpCodes.Ldc_I4, parserEntry.FlatIndex);
                        ilBuilderContext.IL.Emit(OpCodes.Call, OnAfterConsumeValueMethodInfo);
                    }

                    //ilBuilderContext.EmitLdContext();
                    //ilBuilderContext.IL.Emit(OpCodes.Ldc_I4, parserStateEntry.FlatIndex);
                    //ilBuilderContext.IL.Emit(OpCodes.Call, ConsumeLexerEntryMethodInfo);
                }
예제 #16
0
 protected virtual void BuildInvoke(ILBuilderContext ilBuilderContext, MatchEntry matchEntry, bool main)
 {
 }
 public LocalLexerArgumentBuilder(Type argumentType, MatchEntry matchEntry) : base(argumentType, matchEntry)
 {
 }