📄 timefield.cs
字号:
using System;
namespace SDP
{
/// <summary>
/// A RepeatTime represents a t= field contained within a TimeDescription.
///
/// A RepeatTime specifies the start and stop times for a SessionDescription.
/// </summary>
public class TimeField : Field
{
private DateTime start;
/// <summary>
/// Gets the start time.
/// </summary>
public DateTime Start
{
get { return this.start; }
}
private DateTime stop;
/// <summary>
/// Gets the stop time.
/// </summary>
public DateTime Stop
{
get { return this.stop; }
}
/// <summary>
/// Creates a new TimeField.
/// </summary>
/// <param name="value">The value portion of the field.</param>
public TimeField(string value)
: base("t=" + value)
{
string val = base.value;
string[] parts = val.Split(' ');
if (parts.Length == 2)
{
this.start = NtpTime.GetDateTime(long.Parse(parts[0]));
this.stop = NtpTime.GetDateTime(long.Parse(parts[1]));
}
else
{
throw new Exception("Unsupported time format");
}
}
/// <summary>
/// Creates a new TimeField.
/// </summary>
/// <param name="start">The start time.</param>
/// <param name="stop">The stop time.</param>
public TimeField(DateTime start, DateTime stop)
: this(NtpTime.GetNtpTime(start).ToString() + " " + NtpTime.GetNtpTime(stop).ToString())
{
this.start = start;
this.stop = stop;
}
/// <summary>
/// Converts this TimeField to its string representation.
/// </summary>
/// <returns>A string.</returns>
public override string ToString()
{
return NtpTime.GetNtpTime(this.start).ToString() + " " + NtpTime.GetNtpTime(this.stop).ToString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -