Пример #1
0
        private Dictionary <string, SignalDrawState> ReadDrawStates(STFReader stf)
        {
            stf.MustMatchBlockStart();
            int count = stf.ReadInt(null);
            Dictionary <string, SignalDrawState> drawStates = new Dictionary <string, SignalDrawState>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signaldrawstate", () => {
                    if (drawStates.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalDrawState");
                    }
                    else
                    {
                        SignalDrawState drawState = new SignalDrawState(stf);
                        if (drawStates.ContainsKey(drawState.Name))
                        {
                            string newState = $"DST{drawStates.Count}";
                            drawStates.Add(newState, drawState);
                            STFException.TraceInformation(stf, $"Duplicate SignalDrawState name \'{drawState.Name}\', using name \'{newState}\' instead");
                        }
                        else
                        {
                            drawStates.Add(drawState.Name, drawState);
                        }
                    }
                }),
            });
            if (drawStates.Count < count)
            {
                STFException.TraceWarning(stf, (count - drawStates.Count).ToString() + " missing SignalDrawState(s)");
            }
            return(drawStates);
        }
Пример #2
0
 /// <summary>
 /// Comparator function for ordering signal draw states
 /// </summary>
 /// <param name="drawStateA">first draw state to compare</param>
 /// <param name="drawStateB">second draw state to compare</param>
 /// <returns>integer describing whether first draw state needs to be sorted before second state (so less than 0, 0, or larger than 0)</returns>
 public static int Comparer(SignalDrawState drawStateA, SignalDrawState drawStateB)
 {
     return(drawStateA.Index - drawStateB.Index);
 }
Пример #3
0
 /// <summary>
 /// Comparator function for ordering signal draw states
 /// </summary>
 /// <param name="drawStateA">first draw state to compare</param>
 /// <param name="drawStateB">second draw state to compare</param>
 /// <returns>integer describing whether first draw state needs to be sorted before second state (so less than 0, 0, or larger than 0)</returns>
 public static int Comparer(SignalDrawState drawStateA, SignalDrawState drawStateB)
 {
     return(drawStateA?.Index - drawStateB?.Index ?? 0);
 }