|
using System;
using CP.Apps.ScreenSaver.com.codeproject.www;
namespace CP.Apps.ScreenSaver.Data
{
/// <summary>
/// A class for updating messages
/// </summary>
public abstract class MessageUpdate : IPresentationDataUpdater
{
protected LatestBrief webService;
protected abstract MessageBrief[] Messages
{
get;
}
protected abstract int UpdatePeriod
{
get;
}
#region Implementation of IPresentationDataUpdater
public bool UpdatePresentationData(CP.Apps.ScreenSaver.Data.PresentationData data)
{
try
{
webService = new LatestBrief();
MessageBrief[] messages = this.Messages;
PresentationItem[] items = new PresentationItem[messages.Length];
data.UpdateType = this.GetType().FullName;
for(int i = 0; i < messages.Length; i++)
{
PresentationItem item = new PresentationItem();
item.Author = Util.StripHtml(messages[i].Author);
item.Text = String.Format("{0} ({1})", Util.StripHtml(messages[i].Subject), messages[i].MsgsInThread);
items[i] = item;
}
data.Items = items;
//Update the update interval
data.UpdateInterval = this.UpdatePeriod;
}
finally
{
if (webService != null)
{
webService.Dispose();
webService = null;
}
}
return true;
}
#endregion
}
public class LoungeUpdate : MessageUpdate
{
protected override CP.Apps.ScreenSaver.com.codeproject.www.MessageBrief[] Messages
{
get
{
return webService.GetLatestLoungeBrief(webService.GetMaxLoungeListLength());
}
}
protected override int UpdatePeriod
{
get
{
return webService.GetLoungeLatestUpdatePeriod();
}
}
}
public class CommentsUpdate : MessageUpdate
{
protected override CP.Apps.ScreenSaver.com.codeproject.www.MessageBrief[] Messages
{
get
{
return webService.GetLatestCommentsBrief(webService.GetMaxCommentListLength());
}
}
protected override int UpdatePeriod
{
get
{
return webService.GetCommentLatestUpdatePeriod();
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.