Exemplo n.º 1
0
 public Entry(int regID, int length, string name, string unit, EntryFormat format, Func <int[], object> specialRule)
 {
     this.RegisterID  = regID;
     this.Length      = length;
     this.Name        = name;
     this.Unit        = unit;
     this.Format      = format;
     this.SpecialRule = specialRule;
 }
Exemplo n.º 2
0
        private void Record(RecorderEvent rEvent)
        {
            // DESIGN NOTE:
            // Recorders listen to all broadcasts and filter by entry evaluation...
            if (!string.IsNullOrEmpty(rEvent.Entry))
            {
                try
                {
                    // TODO:
                    // 1. Detect & Save Command
                    // 2. On response detection, fire Writing event w/ Command & Response
                    // 3. Either:
                    //      - Detect deferred Open and Open using formatted location
                    //      - Record resulting formatted entry

                    // TODO: Refine logic to include edge scenarios
                    // 1. EntryFormat only contains Command reference
                    // 2. EntryFormat only contains Response reference
                    // 3. EntryFormat contains neither
                    // 3. EntryFormat empty (null)

                    if (EvaluateEntry(CommandEvaluators, rEvent.Entry))
                    {
                        ActiveCommand = rEvent.Entry;
                    }
                    else if (!string.IsNullOrEmpty(ActiveCommand))
                    {
                        string location = string.Empty;
                        if (!string.IsNullOrEmpty(LocationFormat))
                        {
                            try
                            {
                                Recorder.OnOpening(rEvent.TestName, rEvent.StepNumber, LocationFormat, Values, ActiveCommand, rEvent.Entry, ref location);
                                if (string.IsNullOrEmpty(location))
                                {
                                    throw new ArgumentNullException("Invalid resulting Location in Recorder.");
                                }
                            }
                            catch (Exception ex)
                            {
                                OnError(ex);
                                throw ex;
                            }
                            Recorder.Open(location);
                            LocationFormat = string.Empty;
                        }

                        string entry = string.Empty;
                        if (EvaluateEntry(ResponseEvaluators, rEvent.Entry))
                        {
                            try
                            {
                                if (EntryStyle == EntryStyle.Single)
                                {
                                    Recorder.OnRecording(rEvent.TestName, rEvent.StepNumber, EntryFormat, Values, ActiveCommand, rEvent.Entry, ref entry);
                                }
                                else
                                {
                                    string lines = string.Empty;
                                    foreach (string line in rEvent.Entry.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
                                    {
                                        entry = string.Empty;
                                        string format = EntryFormat.Replace("{Response[*]}", line);

                                        Recorder.OnRecording(rEvent.TestName, rEvent.StepNumber, format, Values, ActiveCommand, rEvent.Entry, ref entry);
                                        lines += entry + "\r\n";
                                    }
                                    entry = lines;
                                }
                                if (string.IsNullOrEmpty(entry))
                                {
                                    throw new ArgumentNullException("Invalid resulting Entry in Recorder.");
                                }
                            }
                            catch (Exception ex)
                            {
                                OnError(ex);
                                throw ex;
                            }
                        }

                        Recorder.Record(entry);
                    }
                }
                catch (Exception ex)
                {
                    TransitionTo(m_StateFaulted, s_TranIdx_Opened_Faulted);
                }
            }
        }
Exemplo n.º 3
0
 public Entry(int regID, int length, string name, EntryFormat format, Func <int[], object> specialRule)
     : this(regID, length, name, null, format, specialRule)
 {
 }
Exemplo n.º 4
0
 public Entry(int regID, int length, string name, string unit, EntryFormat format)
     : this(regID, length, name, unit, format, null)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create a new <see cref="IndexToLocationTable"/>.
 /// </summary>
 public IndexToLocationTable(TrueTypeHeaderTable directoryTable, EntryFormat format, IReadOnlyList <uint> glyphOffsets)
 {
     DirectoryTable = directoryTable;
     Format         = format;
     GlyphOffsets   = glyphOffsets ?? throw new ArgumentNullException(nameof(glyphOffsets));
 }