Slight edit to copyright statement. Added Diagnostics utility and extension methods...
[lwes-dotnet/github-mirror.git] / Lwes-test-emitter-console / Program.cs
blobaab2e0de7ad1261c8924c134a5142367a5a9e8dc
1 ///
2 /// This file is part of the LWES .NET Binding (LWES.net)
3 ///
4 /// COPYRIGHT© 2009, Phillip Clark (cerebralkungfu[at*g mail[dot*com)
5 /// original .NET implementation
6 ///
7 /// LWES.net is free software: you can redistribute it and/or modify
8 /// it under the terms of the GNU General Public License as published by
9 /// the Free Software Foundation, either version 3 of the License, or
10 /// (at your option) any later version.
11 ///
12 /// LWES.net is distributed in the hope that it will be useful,
13 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
14 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 /// GNU General Public License for more details.
16 ///
17 /// You should have received a copy of the GNU General Public License
18 /// along with LWES.net. If not, see <http://www.gnu.org/licenses/>.
19 ///namespace Lwes_test_emitter_console
20 namespace Lwes_test_emitter_console
22 using System;
23 using System.Diagnostics;
24 using System.Threading;
26 using Org.Lwes;
27 using Org.Lwes.Emitter;
29 class Program
31 #region Methods
33 static void Main(string[] args)
35 // Use emit some trace messages - these will route through
36 // the configured LwesTraceListener to the LWES.
37 // This is how most DotNet applications will interact with LWES.
38 TraceSource ts = new TraceSource("Console");
39 ts.TraceEvent(TraceEventType.Verbose, 1, "Starting Lwes-test-emitter-console");
41 var control = new { NumberOfEventsToEmit = 10000, MaxNumberOfAttributes = 44 };
43 Console.WriteLine(String.Format("LWES EventEmitter - \r\nThis console will generate and emit {0} random events to the LWES"
44 , control.NumberOfEventsToEmit.ToString("N0")));
46 Thread.Sleep(1000);
48 // Create an emitter - this is the emitter named in the lwes/emitters
49 // configuration node.
50 using (IEventEmitter emitter = EventEmitter.CreateDefault())
52 for (int i = 0; i < control.NumberOfEventsToEmit; i++)
54 Event ev = EventUtils.GenerateRandomEvent(String.Concat("TestEvent_", i), control.MaxNumberOfAttributes, SupportedEncoding.UTF_8);
55 emitter.Emit(ev);
59 ts.TraceEvent(TraceEventType.Verbose, 2, "Exiting Lwes-test-emitter-console");
62 #endregion Methods