Writing an Output Adapter for Particls is not a complex exercise.
To get started, create a new Class Library project. In this page, I'll discuss implementing a C# adapter, however nothing stops the same being done in any other .NET language (such as VB.NET or even J#.NET).
To be able to implement a Particls Output Adapter, your project will need to reference Particls.Core.dll (in Program Files\Particls).
In your class Library, create a class that implements Particls.Core.Adapters.IOutputAdapter. This interface requires implementing the following methods:
- Init() - this method will be called as your adapter is first loaded. Note that Init does not signal that you should start doing your work - only that you should prepare yourself.
- Finish() - the opposite of the Init method. This will be called when Particls is shutting down your adapter, and requires you to free up your resources.
- Start() - indicates that your adapter should start outputting items. Note that this differs from Init in that it may be called multiple times if a user chooses to stop and start your functionality.
- Pause() - indicates that your adapter should stop outputting items. Any temporary resources can be freed at this point (if you allocated them in line with your Start method), but your adapter may be required to start again upon a call to Start.
- AddItem(Item pItem) - indicates that a new item has arrived, or that the status of an existing item has changed.
And thats it. Five methods to implement. Now, for a simple implementation.
using System;
using System.IO;
using Particls.Core;
using Particls.Core.Adapters;
using Particls.Core.Entities;
namespace Particls.SDK.Output.LoggingAdapter {
public class AdapterBase : IOutputAdapter {
private string mOutputFile = @"C:LogOutput.txt";
private TextWriter mOutput;
private bool mShouldWrite = false;
public ItemStatus AddItem(Item objItem) {
if (!mShouldWrite) return ItemStatus.Success;
if (objItem.State == ITEMSTATE.NEW) {
mOutput.WriteLine(string.Format("{0} {1} {2}", objItem.iAmValue, objItem.Title, objItem.Description));
mOutput.Flush();
}
return ItemStatus.Success;
}
public void Init() {
mOutput = new StreamWriter(mOutputFile, true);
}
public void Finish() {
mOutput.Close();
}
public ItemStatus Start() {
mShouldWrite = true;
return ItemStatus.Failed;
}
public ItemStatus Pause() {
mShouldWrite = false;
return ItemStatus.Failed;
}
}
}
Build the adapter, and put the resulting Adapter in your Program Files\Particls\Adapters directory. Start (or restart) Particls. The spam should arrive in no time!
Output Adapters Ideas
- A newsmap (all your news on one page – size depicts importance)
- A screensaver that displays Particls items while your computer is sleeping
- A Sidebar (similar to a buddly list – for alert items)
- SMS Alerts (sends important items to your phone)
- IM Alerts (sends items to your IM client)
- Emailer (sends a digest of items to your email)
- A blog widget so your readers can keep track of what you find important (perhaps based on Pebbles)
- A river of news (maybe in XAML?)
- A ticker that sits in the taskbar as a Toolbar
- A ticker that sits in IE and/or Firefox as a Toolbar
- A ticker that docks to the screen top or bottom and mimics the CNN Crawler (maybe even in XAML?) (to replace the default ticker)
- An attachment manager that captures incoming enclosure data (including microformats maybe?) and allows the user to act on them
- Particls → mp3 → iPod Converter (Instant podcasts of your top feed items) – Perhaps Talkr.com would be useful
- Tag Cloud generator using the tags provided by Particls for each item. Use combined importance of items to determine tag size (instead of number of items). Users can click to display matching items.
Comments (0)
You don't have permission to comment on this page.