コード例 #1
0
        protected override void ProcessCountMetricEvent(CountMetricEventInstance countMetricEvent)
        {
            StringBuilder stringBuilder = InitializeStringBuilder(countMetricEvent.EventTime.ToLocalTime());

            stringBuilder.Append(countMetricEvent.Metric.Name);
            streamWriter.WriteLine(stringBuilder.ToString());
            streamWriter.Flush();
        }
コード例 #2
0
        /// <include file='InterfaceDocumentationComments.xml' path='doc/members/member[@name="M:ApplicationLogging.IApplicationLogger.Log(ApplicationLogging.LogLevel,System.String)"]/*'/>
        public void Log(LogLevel level, string text)
        {
            // Typically this and the other Log() method overrides would check that the class was not closed and not disposed, so that an exception with a clear message could be throw in the case that either were true.
            //    However, in the interest of performance such checks are omitted.

            if (level >= minimumLogLevel)
            {
                streamWriter.WriteLine(CreateLogEntry(level, text).ToString());
                streamWriter.Flush();
            }
        }
コード例 #3
0
ファイル: Bunnies.cs プロジェクト: molivpopov/Telerik
 private static void SaveBunnies(IStreamWriter streamWriter, IList <IBunny> bunnies)
 {
     using (streamWriter)
     {
         foreach (var bunny in bunnies)
         {
             streamWriter.WriteLine(bunny.ToString());
         }
     }
 }
コード例 #4
0
 public void WriteLine(string value)
 {
     if (_writer != null)
     {
         _writer?.WriteLine(ProcessString(value));
     }
     else
     {
         _nativeWriter.WriteLine(ProcessString(value));
     }
 }
コード例 #5
0
 public void LogDoorLocked(int LockID)
 {
     W.Write("Log entry: ");
     W.WriteLine($"{DateTime.Now.ToShortTimeString()} {DateTime.Now.ToLongDateString()}");
     W.WriteLine($"Charging station locked using RFID: {LockID}");
     W.WriteLine("-------------------------------------------------------");
     W.Close();
 }
コード例 #6
0
 public bool SendLine(string value)
 {
     if (_connection.IsConnected == false)
     {
         _connection.Connect();
     }
     if (_streamWriter == null)
     {
         _streamWriter = _connection.GetStreamWriter();
     }
     try
     {
         _streamWriter.WriteLine(value);
         _streamWriter.Flush();
         _logger.Trace($"Sended: {value}");
         return(true);
     }
     catch
     {
         _streamWriter = null;
         return(false);
     }
 }
コード例 #7
0
        public void ProcessParagraphUnit(IParagraphUnit paragraphUnit)
        {
            var contextInfo        = paragraphUnit.Properties.Contexts.Contexts[1];
            var messageStringStart = int.Parse(contextInfo.GetMetaData(ContextKeys.MetaMessageStringStart));
            var messageStringEnd   = int.Parse(contextInfo.GetMetaData(ContextKeys.MetaMessageStringEnd));

            string currentOriginalLine;

            while ((currentOriginalLine = _extendedStreamReader.ReadLineWithEofLine()) != null)
            {
                if (_extendedStreamReader.CurrentLineNumber < messageStringStart)
                {
                    _streamWriter.WriteLine(currentOriginalLine);
                }

                var parseResult = _lineParsingSession.Parse(currentOriginalLine);

                _entryBuilder.Add(parseResult, _extendedStreamReader.CurrentLineNumber);

                var completeEntry = _entryBuilder.CompleteEntry;

                if (completeEntry == null || string.IsNullOrEmpty(completeEntry.MessageId))
                {
                    continue;
                }

                WriteMessageString(paragraphUnit, completeEntry.IsPluralForm);

                if (_extendedStreamReader.CurrentLineNumber > messageStringEnd && parseResult.LineType != LineType.EndOfFile)
                {
                    _streamWriter.WriteLine(currentOriginalLine);
                }

                break;
            }
        }
コード例 #8
0
        ProcessParagraphUnit_WhenStart_ShouldWriteLinesFromStartToMsgstr()
        {
            // Arrange
            var testString = @"line 1
line 2
msgid ""message id""
msgstr ""message string""
entryComplete
";
            var testee     = CreateTestee(testString);

            var paragraphUnitMock = CreateParagraphUnitMock(4);

            // Act
            testee.ProcessParagraphUnit(paragraphUnitMock);

            // Assert
            A.CallTo(() => _streamWriterMock.WriteLine("line 1")).MustHaveHappened();
            A.CallTo(() => _streamWriterMock.WriteLine("line 2")).MustHaveHappened();
            A.CallTo(() => _streamWriterMock.WriteLine(@"msgid ""message id""")).MustHaveHappened();
        }