Permalink
Browse files

Update #283 - Added more extension messages for timed messages

  • Loading branch information...
1 parent 576400d commit 38c1208319d32368707946e793fa67f9a0eaa2f8 @avanderhoorn avanderhoorn committed Mar 23, 2013
Showing with 70 additions and 0 deletions.
  1. +70 −0 source/Glimpse.Core/Message/ITimedMessage.cs
@@ -54,5 +54,75 @@ public static T AsTimedMessage<T>(this T message, TimerResult timerResult)
return message;
}
+
+ /// <summary>
+ /// Populates relevant properties on the source message.
+ /// </summary>
+ /// <typeparam name="T">The type of the message.</typeparam>
+ /// <param name="message">The message.</param>
+ /// <param name="offset">The offset.</param>
+ /// <param name="duration">The duration.</param>
+ /// <param name="startTime">The start time.</param>
+ /// <returns>The <paramref name="message"/> with populated <see cref="ITimedMessage"/> properties.</returns>
+ public static T AsTimedMessage<T>(this T message, TimeSpan offset, TimeSpan duration, DateTime startTime)
+ where T : ITimedMessage
+ {
+ message.Offset = offset;
+ message.Duration = duration;
+ message.StartTime = startTime;
+
+ return message;
+ }
+
+ /// <summary>
+ /// Populates relevant properties on the source message. Duration is defaulted to Zero and StartTime is not set.
+ /// </summary>
+ /// <typeparam name="T">The type of the message.</typeparam>
+ /// <param name="message">The message.</param>
+ /// <param name="offset">The offset.</param>
+ /// <returns>The <paramref name="message"/> with populated <see cref="ITimedMessage"/> properties.</returns>
+ public static T AsTimedMessage<T>(this T message, TimeSpan offset)
+ where T : ITimedMessage
+ {
+ message.Offset = offset;
+ message.Duration = TimeSpan.Zero;
+
+ return message;
+ }
+
+ /// <summary>
+ /// Populates relevant properties on the source message. Duration is defaulted to Zero.
+ /// </summary>
+ /// <typeparam name="T">The type of the message.</typeparam>
+ /// <param name="message">The message.</param>
+ /// <param name="offset">The offset.</param>
+ /// <param name="startTime">The start time.</param>
+ /// <returns>The <paramref name="message"/> with populated <see cref="ITimedMessage"/> properties.</returns>
+ public static T AsTimedMessage<T>(this T message, TimeSpan offset, DateTime startTime)
+ where T : ITimedMessage
+ {
+ message.Offset = offset;
+ message.Duration = TimeSpan.Zero;
+ message.StartTime = startTime;
+
+ return message;
+ }
+
+ /// <summary>
+ /// Populates relevant properties on the source message. StartTime is not set.
+ /// </summary>
+ /// <typeparam name="T">The type of the message.</typeparam>
+ /// <param name="message">The message.</param>
+ /// <param name="offset">The offset.</param>
+ /// <param name="duration">The duration.</param>
+ /// <returns>The <paramref name="message"/> with populated <see cref="ITimedMessage"/> properties.</returns>
+ public static T AsTimedMessage<T>(this T message, TimeSpan offset, TimeSpan duration)
+ where T : ITimedMessage
+ {
+ message.Offset = offset;
+ message.Duration = duration;
+
+ return message;
+ }
}
}

0 comments on commit 38c1208

Please sign in to comment.