private void LoadFeedbackMessage() { Message = Template; Message = Message.Replace("$object", Object); Message = Message.Replace("$block", Block); Message = Message.Replace("$item", Item); Message = Message.Replace("$time", DateTimeStamp.ToString("HH:mm")); }
private static void CheckDateTimeStamp( DateTimeStamp t ) { string s = t.ToString(); var m = new StringMatcher( "X" + s + "Y" ); Assert.That( m.MatchChar( 'X' ) ); DateTimeStamp parsed; Assert.That( m.MatchDateTimeStamp( out parsed ) && parsed == t ); Assert.That( m.MatchChar( 'Y' ) ); m = new StringMatcher( s.Insert( 2, "X" ) ); Assert.That( m.MatchDateTimeStamp( out parsed ), Is.False ); Assert.That( m.ErrorMessage, Is.Not.Null ); int i; Assert.That( m.MatchInt32( out i ) && i == 20 ); }
private static void CheckDateTimeStamp(DateTimeStamp t) { string s = t.ToString(); var m = new StringMatcher("X" + s + "Y"); Assert.That(m.MatchChar('X')); DateTimeStamp parsed; Assert.That(m.MatchDateTimeStamp(out parsed) && parsed == t); Assert.That(m.MatchChar('Y')); m = new StringMatcher(s.Insert(2, "X")); Assert.That(m.MatchDateTimeStamp(out parsed), Is.False); Assert.That(m.ErrorMessage, Is.Not.Null); int i; Assert.That(m.MatchInt32(out i) && i == 20); }
private static void CheckDateTimeStamp(DateTimeStamp t) { string s = t.ToString(); var m = new StringMatcher("X" + s + "Y"); m.MatchChar('X').Should().BeTrue(); DateTimeStamp parsed; m.MatchDateTimeStamp(out parsed).Should().BeTrue(); parsed.Should().Be(t); m.MatchChar('Y').Should().BeTrue(); m = new StringMatcher(s.Insert(2, "X")); m.MatchDateTimeStamp(out parsed).Should().BeFalse(); m.ErrorMessage.Should().NotBeNull(); int i; m.MatchInt32(out i).Should().BeTrue(); i.Should().Be(20); }
static string FindUniqueTimedFile( string pathPrefix, string fileSuffix, DateTime time, int maxTryBeforeGuid, Func<string, bool> tester ) { if( pathPrefix == null ) throw new ArgumentNullException( "pathPrefix" ); if( fileSuffix == null ) throw new ArgumentNullException( "fileSuffix" ); if( maxTryBeforeGuid < 0 ) throw new ArgumentOutOfRangeException( "maxTryBeforeGuid" ); DateTimeStamp timeStamp = new DateTimeStamp( time ); int counter = 0; string result = pathPrefix + timeStamp.ToString() + fileSuffix; for( ; ; ) { if( tester( result ) ) break; if( counter < maxTryBeforeGuid ) { timeStamp = new DateTimeStamp( timeStamp, timeStamp ); result = pathPrefix + timeStamp.ToString() + fileSuffix; } else { if( counter == maxTryBeforeGuid + 1 ) throw new CKException( Impl.CoreResources.FileUtilUnableToCreateUniqueTimedFile ); if( counter == maxTryBeforeGuid ) { result = pathPrefix + FormatTimedUniqueFilePart( time ) + fileSuffix; } } ++counter; } return result; }
static StringBuilder CreateHeader( DateTimeStamp logTime, string text, LogLevel level, CKTrait tags ) { StringBuilder buffer = new StringBuilder(); buffer.Append( '<' ).Append( level.ToString() ).Append( '>' ).Append( '@' ).Append( logTime.ToString() ); if( tags != null && !tags.IsEmpty ) buffer.Append( " - " ).Append( tags.ToString() ); buffer.AppendLine(); if( text != null && text.Length > 0 ) buffer.Append( text ).AppendLine(); return buffer; }