예제 #1
0
        public override void Write(LineWriter writer)
        {
            writer.WriteLine($"{Tag}({Category}) = {Value}");
            {
                base.Write(writer);

                var nestedWriter = writer.Nest();
                foreach (var keyValue in Values)
                {
                    nestedWriter.WriteLine(keyValue.Key + " = " + keyValue.Value);
                }
            }
            writer.WriteLine("End" + Tag);
        }
예제 #2
0
파일: Watcher.cs 프로젝트: helgihaf/Grocker
        private void ReadTaskMain()
        {
            bool         keepOnReading = true;
            StreamReader reader        = null;

            while (keepOnReading)
            {
                // If not already reading, find something to read
                if (reader == null)
                {
                    reader = GetStreamReader();
                }

                // Check for data on our current reader
                if (reader != null)
                {
                    string line;
                    try
                    {
                        while ((line = reader.ReadLine()) != null)
                        {
                            LineWriter.WriteLine(line);
                        }
                    }
                    catch (IOException ex)
                    {
                        LineWriter.WriteLine(string.Format(">>>> {0} <<<<", ex.Message));
                        reader = null;
                        continue;
                    }
                }

                // Check for file system events
                WatcherEvent watcherEvent = null;
                lock (eventQueueLock)
                {
                    if (eventQueue.Count == 0)
                    {
                        Monitor.Wait(eventQueueLock, FilePollingMs);
                    }
                    if (eventQueue.Count > 0)
                    {
                        watcherEvent  = eventQueue.Dequeue();
                        keepOnReading = watcherEvent != null;
                    }
                }
                if (watcherEvent != null)
                {
                    reader = HandleWatcherEvent(reader, watcherEvent);
                }
            }
        }
예제 #3
0
파일: Watcher.cs 프로젝트: helgihaf/Grocker
        private StreamReader GetStreamReader()
        {
            StreamReader streamReader = null;

            var filePath = FindFilePath();

            if (filePath != null)
            {
                streamReader = FindTailOf(filePath);
                if (streamReader != null)
                {
                    LineWriter.WriteLine(string.Format("++++++ File: {0} ++++++", filePath));
                    OnFileFound(filePath);
                }
            }
            return(streamReader);
        }
예제 #4
0
        public void WriteLine_ShouldDisplayCorrectText()
        {
            using (var sw = new StringWriter())
            {
                // Arrange
                LineWriter lineWriter = new LineWriter();
                Console.SetOut(sw);
                int           hierarchyLevel = 0;
                EmployeeModel employeeModel  = new EmployeeModel(1, 0, "A", "B", "C", "D", "E", "1", "2", "3");
                Employee      employee       = new Employee(employeeModel, hierarchyLevel);
                string        expected       = "1, 0, A, B, C, D, E";

                // Act
                lineWriter.WriteLine(employee);
                var result = sw.ToString().Trim();

                // Assert
                Assert.AreEqual(expected, result, "Employee was not corectly displayed");
            }
        }
예제 #5
0
 public override void Execute(IJobExecutionContext context) =>
 LineWriter.WriteLine($"[Job 1] Execute called at \t{DateTime.Now.TimeOfDay}");
예제 #6
0
 public override void Write(LineWriter writer)
 {
     writer.WriteLine(Line.Content);
 }