static void engine_AfterReadRecord(EngineBase engine, FileHelpers.Events.AfterReadEventArgs <object> e)
    {
        FooBar fooBar = e.Record as FooBar;

        fooBar.ColumnA_Two = fooBar.ColumnA_One;
        fooBar.ColumnB_Two = fooBar.ColumnB_One;
    }
Example #2
0
        private EngineBase _average_engine = null;// new InMemoryEngine(timeWindow: TimeSpan.FromSeconds(3));
        //private double _peek_limit = 0;


        public StatisticEngineThrottle(double averageRate, TimeSpan averageTimeWindow) : base(averageRate)
        {
            //this._peek_limit = peekRate;

            this._average_engine = new InMemoryEngine(timeWindow: averageTimeWindow);
            //this._peek_engine = new InMemoryEngine(timeWindow: peekTimeWindow);
        }
        /// <summary>CTLファイルを出力する。</summary>
        /// <param name="filename"></param>
        /// <param name="eHandler"></param>
        public void WriteCtlFile(string filename, EngineBase.LogTextOutputEventHandler eHandler)
        {
            EngineBase engine = CreateReadySimulationEngine();

            engine.LogTextOutput += eHandler;
            engine.CreateCtlFile(filename);
        }
 private static void AfterReadValidation(EngineBase sender, AfterReadRecordEventArgs args)
 {
     if (String.IsNullOrWhiteSpace(((RequiredField)args.Record).Required))
     {
         throw new ConvertException("RequiredField is Null or WhiteSpace", typeof(String));
     }
 }
Example #5
0
        public Editor(int startLevelNumber)
        {
            ready = false;

            // setup engine
            engine = new EngineBase();

            if (engine.Ready)
            {
                engine.ClearColor(Color.Black);

                Profiler         = new Engine.GUI.Controls.Profiler();
                Profiler.Visible = false;

                // setup gui
                gui = new GUI(this);
                if (!gui.Ready)
                {
                    Log.WriteLine(Log.LOG_ERROR, "failed to setup GUI");
                    return;
                }

                engine.SetOverlay(gui);

                // setup level
                LoadLevel(startLevelNumber);
            }
        }
        /// <summary>
        /// Called in read operations just after the record was created from a record string.
        /// </summary>
        /// <param name="engine">The engine that generates the event.</param>
        /// <param name="e">The event data.</param>
        private void Csv_AfterReadRecord(EngineBase engine, AfterReadRecordEventArgs <Aliencube.Utilities.KoreanPostcodeAddressConverter.Services.Models.StreetBasedAddress> e)
        {
            var street    = e.Record.StreetName.Trim();
            var streetEng = e.Record.StreetNameEng.Trim();

            if (String.IsNullOrWhiteSpace(street))
            {
                return;
            }

            if (street == "0" && this._settings.StreetNameCorrections.ContainsKey(streetEng))
            {
                street = this._settings.StreetNameCorrections[streetEng];
            }
            else
            {
                foreach (var correction in this._settings
                         .StreetNameCorrections
                         .Where(p => street.StartsWith(p.Key)))
                {
                    street = street.Replace(correction.Key, correction.Value);
                }
            }

            e.Record.StreetName = street;
        }
Example #7
0
 private void AfterEvent(EngineBase engine, AfterReadEventArgs <OrdersFixed> e)
 {
     //  we want to drop all records with no freight
     if (e.Record.Freight == 0)
     {
         e.SkipThisRecord = true;
     }
 }
Example #8
0
 private void BeforeWriteEvent(EngineBase engine, BeforeWriteEventArgs <OrdersFixed> e)
 {
     //  We only want clients with large frieght values
     if (e.Record.Freight < 40)
     {
         e.SkipThisRecord = true;
     }
 }
Example #9
0
 private void AfterWriteEvent(EngineBase engine, AfterWriteEventArgs <OrdersFixed> e)
 {
     //  Hide a line
     if (e.Record.CustomerID.Trim() == "HANAR")
     {
         e.RecordLine = "-- Insufficient Access";
     }
 }
Example #10
0
 private void AfterWriteEvent(EngineBase engine, AfterWriteEventArgs <OrdersFixed> e)
 {
     //  We only want clients with large frieght values
     if (e.Record.CustomerID == "HANAR")
     {
         e.RecordLine = "Insufficient Access";
     }
 }
Example #11
0
 private static void Engine_BeforeReadRecord(EngineBase engine, FileHelpers.Events.BeforeReadEventArgs <CSSEGISandDataDailyReport> e)
 {
     //var algo = ((CSSEGISandDataDailyReport)e.Record).Country_Region;
     //if (algo != null)
     //{
     //    string hola = "adios";
     //}
 }
 /// <summary>
 /// After the record is read,  allow details to be inspected.
 /// </summary>
 /// <param name="engine">Engine that parsed the record</param>
 /// <param name="line">Record that was analysed</param>
 /// <param name="lineChanged">Was it changed before</param>
 /// <param name="lineNumber">Record number read</param>
 internal AfterReadEventArgs(EngineBase engine,
     string line,
     bool lineChanged,
     int lineNumber)
     : base(engine, line, lineNumber)
 {
     SkipThisRecord = false;
     RecordLineChanged = lineChanged;
 }
        private void BeforeEvent(EngineBase sender, BeforeReadRecordEventArgs e)
        {
            if (e.RecordLine.StartsWith(" ") || e.RecordLine.StartsWith("-"))
            {
                e.SkipThisRecord = true;
            }

            before++;
        }
    static void engine_AfterReadRecord(EngineBase engine, FileHelpers.Events.AfterReadEventArgs <MyClass> e)
    {
        bool isEmailValid = IsEmailValid(e.Record.Email);

        if (!isEmailValid)
        {
            throw new Exception("Email is invalid");
        }
    }
Example #15
0
 /// <summary>
 /// After the record is read,  allow details to be inspected.
 /// </summary>
 /// <param name="engine">Engine that parsed the record</param>
 /// <param name="line">Record that was analysed</param>
 /// <param name="lineChanged">Was it changed before</param>
 /// <param name="lineNumber">Record number read</param>
 internal AfterReadEventArgs(EngineBase engine,
                             string line,
                             bool lineChanged,
                             int lineNumber)
     : base(engine, line, lineNumber)
 {
     SkipThisRecord    = false;
     RecordLineChanged = lineChanged;
 }
Example #16
0
        private static void BeforeReadRecord(EngineBase engine, BeforeReadRecordEventArgs e)
        {
            Console.WriteLine("--> Before read line: " + e.RecordLine);

            if (e.LineNumber == 2)
            {
                e.SkipThisRecord = true;
                Console.WriteLine("-->   skiping line 2");
            }
        }
Example #17
0
 private static void Engine_BeforeReadRecord(EngineBase engine, FileHelpers.Events.BeforeReadEventArgs e)
 {
     string[] elements = e.RecordLine.Split(',');
     if (elements.Length < Constants.TotalTransactionElements)
     {
         FileLogger.LogWarning("TransactionImporter failed to import line:" + e.RecordLine);
         e.SkipThisRecord = true;
         return;
     }
     e.RecordLine = StringUtilities.ReplaceEmbeddedCommasWithSpaces(e.RecordLine);
 }
        public void FindSequenceTest4()
        {
            // Arrange
            var sut = new EngineBase();

            // Act
            var result = sut.FindSequence(sequence1, array1);

            // Assert
            CollectionAssert.AreEqual(expected1, result);
        }
        public void getSwappedArrayTest1()
        {
            // Arrange
            byte[] expected = new byte[] { 0x00, 0x00, 0x00, 0x00 };

            // Act
            var result = EngineBase.getSwappedArray(0);

            // Assert
            CollectionAssert.AreEqual(expected, result);
        }
Example #20
0
        private void RunHandler(EngineBase engine, TimeSpan rampUpDelay)
        {
            LoadTesterActivityController.SetThreadName();

            TraceFactory.Logger.Debug("Pausing for {0} secs".FormatWith(rampUpDelay.TotalSeconds));
            ApplicationFlowControl.Instance.Wait(rampUpDelay);
            TraceFactory.Logger.Debug("Pausing for {0} secs - COMPLETE".FormatWith(rampUpDelay.TotalSeconds));

            engine.Run();

            TraceFactory.Logger.Debug("Engine run complete");
        }
        public void FindSequenceTest3()
        {
            // Arrange
            var stream = new MemoryStream(array2);
            var sut    = new EngineBase();

            // Act
            var result = sut.FindSequence(sequence2, stream);

            // Assert
            CollectionAssert.AreEqual(expected2, result);
        }
        public void getSwappedArrayTest2()
        {
            // Arrange
            byte[] expected = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF };
            uint   ui       = 4294967295;

            // Act
            var result = EngineBase.getSwappedArray((int)ui);

            // Assert
            CollectionAssert.AreEqual(expected, result);
        }
Example #23
0
        public static async Task <EngineService> Instantiate()
        {
            var typeManager = new TypeManager();
            var engine      = new EngineBase(new MemoryStorage(typeManager));

            foreach (var e in Graph.GenesisData)
            {
                await engine.ProcessEvent(e);
            }

            return(new EngineService(engine, typeManager));
        }
        //-> {/Example.File}

        //-> {Example.File:EventHandler.cs}
        private void BeforeEvent(EngineBase engine, BeforeReadEventArgs <OrdersFixed> e)
        {
            if (e.RecordLine.StartsWith(" ") || e.RecordLine.StartsWith("-"))
            {
                e.SkipThisRecord = true;
            }

            //  Sometimes changing the record line can be useful, for example to correct for
            //  a bad data layout.  Here is an example of this, commented out for this example

            //if (e.RecordLine.StartsWith(" "))
            //   e.RecordLine = "Be careful!";
        }
Example #25
0
        private void BeforeReadRecord(EngineBase engine, BeforeReadEventArgs <T> e)
        {
            var line = e.RecordLine.Trim();

            if (!string.IsNullOrWhiteSpace(line) &&
                !HeaderRegex.IsMatch(line) &&
                !line.StartsWith(CsvParserConstants.CommentMarker))
            {
                return;
            }

            ++SkippedRecords;
            e.SkipThisRecord = true;
        }
        /// <summary>
        /// Get the Engine
        /// </summary>
        /// <param name="phase"></param>
        /// <returns></returns>
        protected override EngineBase GetEngine(ResourceExecutionPhase phase)
        {
            EngineBase engine = null;

            if (!Engines.TryGetValue(phase, out engine))
            {
                var detail = GetFilteredWorkerDetail(phase);
                engine = ObjectFactory.Create <EngineBase>(detail.ExecutionMode, detail);
                engine.ActivityStateChanged += OnActivityStateChanged;
                Engines.Add(phase, engine);
            }

            return(engine);
        }
    public void AfterRead(EngineBase engine, string line)
    {
        if (!ID.HasValue && Previous != null)
        {
            this.ID = Previus.ID;
        }

        if (!Val.HasValue && Previous != null)
        {
            this.Val = Previus.Val;
        }

        Previuous = this;
    }
 static void engine_AfterReadRecord(EngineBase engine, FileHelpers.Events.AfterReadEventArgs <MyClass> e)
 {
     if (String.IsNullOrWhiteSpace(e.Record.Field1))
     {
         throw new Exception("Field1 is invalid");
     }
     if (String.IsNullOrWhiteSpace(e.Record.Field2))
     {
         throw new Exception("Field2 is invalid");
     }
     if (String.IsNullOrWhiteSpace(e.Record.Field3))
     {
         throw new Exception("Field3 is invalid");
     }
 }
        protected virtual EngineBase GetEngine(ResourceExecutionPhase phase)
        {
            EngineBase engine = null;

            if (!Engines.TryGetValue(phase, out engine))
            {
                var details = GetFilteredWorkerDetail(phase);
                if (phase != ResourceExecutionPhase.Main)
                {
                    details.ExecutionMode = ExecutionMode.Iteration;
                    details.RepeatCount   = 1;
                }
                TraceFactory.Logger.Debug("Creating engine for {0} Phase".FormatWith(phase));
                engine = ObjectFactory.Create <EngineBase>(details.ExecutionMode, details);
                engine.ActivityStateChanged += OnActivityStateChanged;
                Engines.Add(phase, engine);
            }

            return(engine);
        }
Example #30
0
        private void AfterReadCSVEvent(EngineBase engine, AfterReadEventArgs <ImportCLassModel> e)
        {
            if (e.Record.PurchaseOrder.Length > 11)
            {
                throw new Exception("Line " + e.LineNumber + ": PurchaseOrder is too long");
            }

            if (e.Record.Material.Length > 8)
            {
                throw new Exception("Line " + e.LineNumber + ": Material is too long");
            }

            if (e.Record.MaterialShortText.Length > 41)
            {
                throw new Exception("Line " + e.LineNumber + ": MaterialShortText is too long");
            }

            if (e.Record.StorageBin.Length > 6)
            {
                throw new Exception("Line " + e.LineNumber + ": StorageBin is too long");
            }
        }
Example #31
0
        private void OnBeforeReadRecord <TCrossSectionPoint>(EngineBase engine, BeforeReadEventArgs <TCrossSectionPoint> eventArgs)
            where TCrossSectionPoint : class, ICrossSectionPoint
        {
            var line = eventArgs.RecordLine;

            eventArgs.SkipThisRecord = true;

            if (string.IsNullOrWhiteSpace(line) || IsHeaderRecord(line))
            {
                return;
            }

            if (IsCrossSectionSurveyData(line))
            {
                ParseCrossSectionSurveyData(line);
                return;
            }

            if (IsCrossSectionPointData(line))
            {
                eventArgs.SkipThisRecord = false;
            }
        }
 private void engine_AfterWriteRecord(EngineBase sender, AfterWriteEventArgs<SampleType> e)
 {
     after++;
 }
 private void BeforeEvent2(EngineBase sender, BeforeReadEventArgs<SampleType> e)
 {
     e.SkipThisRecord = true;
     before++;
 }
        private void BeforeEvent(EngineBase sender, BeforeReadEventArgs<SampleType> e)
        {
            if (e.RecordLine.StartsWith(" ") || e.RecordLine.StartsWith("-"))
                e.SkipThisRecord = true;

            before++;
        }
 private void AfterEvent2(EngineBase sender, AfterReadEventArgs<SampleType> e)
 {
     e.SkipThisRecord = true;
     after++;
 }
 private void AfterEvent(EngineBase sender, AfterReadEventArgs<SampleType> e)
 {
     after++;
 }
 private static void BeforeEventChange(EngineBase engine, BeforeReadEventArgs<SampleType> e)
 {
     Assert.IsFalse(e.RecordLineChanged);
     e.RecordLine = "11121314901234";
     Assert.IsTrue(e.RecordLineChanged);
 }
 ICarBuildContext ICarBuildContext.WithEngine(EngineBase engine)
 {
     Engine = engine;
     return this;
 }
 /// <summary>
 /// Record before being parsed by the engine
 /// </summary>
 /// <param name="engine">Engine that will analyse the record</param>
 /// <param name="line">Record read from the source</param>
 /// <param name="lineNumber">record number read</param>
 internal BeforeReadEventArgs(EngineBase engine, string line, int lineNumber)
     : base(engine, line, lineNumber)
 {
     SkipThisRecord = false;
 }
Example #40
0
 public void AfterRead(EngineBase engine, string line)
 {
     Nombre = Nombre.Replace("#", "Ñ");
 }
Example #41
0
 /// <summary>
 /// Create a read event argument, contains line number and record read
 /// </summary>
 /// <param name="engine">Engine used to parse data</param>
 /// <param name="line">record to be analysed</param>
 /// <param name="lineNumber">record count read</param>
 internal ReadEventArgs(EngineBase engine, string line, int lineNumber)
     : base(engine, lineNumber)
 {
     RecordLineChanged = false;
     mRecordLine = line;
 }
 /// <summary>
 /// Check record just before processing.
 /// </summary>
 /// <param name="engine">Engine that will parse record</param>
 /// <param name="lineNumber">line number to be parsed</param>
 internal BeforeWriteEventArgs(EngineBase engine, int lineNumber)
     : base(engine, lineNumber)
 {
     SkipThisRecord = false;
 }
		/// <summary>CTLファイルを出力する。</summary>
		/// <param name="filename"></param>
		/// <param name="eHandler"></param>
		public void WriteCtlFile(string filename, EngineBase.LogTextOutputEventHandler eHandler)
			{
			EngineBase engine = CreateReadySimulationEngine();
			engine.LogTextOutput += eHandler;
			engine.CreateCtlFile( filename );
			}
 /// <summary>
 /// Define an event message for an engine
 /// </summary>
 /// <param name="engine">Engine type</param>
 /// <param name="lineNumber">Line number error occurred</param>
 protected FileHelpersEventArgs(EngineBase engine, int lineNumber)
 {
     Engine = engine;
     LineNumber = lineNumber;
 }
 private void engine_BeforeWriteRecord(EngineBase sender, BeforeWriteEventArgs<SampleType> e)
 {
     before++;
 }
Example #46
0
 /// <summary>
 /// Write events are based on this
 /// </summary>
 /// <param name="engine">Engine parsing data</param>
 /// <param name="lineNumber">Record number</param>
 internal WriteEventArgs(EngineBase engine, int lineNumber)
     : base(engine, lineNumber)
 {
 }
 /// <summary>
 /// Record parsed after engine has finished
 /// </summary>
 /// <param name="engine">engine that created the record</param>
 /// <param name="lineNumber">Record number of the record</param>
 /// <param name="line">LIne to be written</param>
 internal AfterWriteEventArgs(EngineBase engine, int lineNumber, string line)
     : base(engine, lineNumber)
 {
     RecordLine = line;
 }