February 0909

Delicious bookmark plug-in – new version

I know its only been a few days since I released my Delicious Bookmarks plug-in for Windows Live Writer, but I found a few better ways of doing some things so reworked the plug-in to take advantage.

I guess it pays to read the documentation, SDK or API for something when you’re building a plug-in, but part of the fun of programming, for me at least, is to try to work it out for myself – and that’s what my original version of the plug-in was, me working out how I could do it my own way. What this means is that I’ve been able to leverage some features of WLW API to make the code more streamlined and also, by taking advantage of what’s on offer, do things in a way that WLW was designed to do. For example I to get the rss feed from delicious I was simply passing the url to an XPathNavigator and having that be responsible for requesting the feed. However using the built in PluginHttpRequest

PluginHttpRequest request = new PluginHttpRequest(uri);
Stream stream = request.GetResponse(TIMEOUT_SECONDS * 1000);

to make the HTTP request lowers the security requirements for the plug-in; and this fixed the problem I had trying to run this in the office.

Another nice feature that I took advantage of was the built in persistence mechanism, IProperties that allowed me to get rid of the xml config file that I had been using until then to persist data between uses. There was nothing ‘wrong’ with my xml config file, but it relied on the user having permissions to write to the installation directory, I’d already made a mistake when changing an attribute name in 1 place that I’d not refactored properly  - this way all I needed to do was to create a class that modelled my name/values and then provide an interface for the user to set their values. Again the developers of WLW were thoughtful enough to give me a nice easy place to allow that to happen. By adding “HasEditableOptions = true” to my WriterPlugin Attributes WLW added a button to the plug-in details screen for “Options”, which I used to hook up a revised WinForm to gather the users Options with. Then persist them via the IProperties interface and I’ve got my new version of the plug-in.

End result: smaller, easier to read classes, easier to write UnitTests for and easier to add new features to. So if anyone has any requests please let me know.

Delicious Bookmarks installer v1.2

Comments

  1. People's Republic of China 007b2b (Sunday, March 29, 2009) # 007b2b

    smaller, easier to read classes, easier to write UnitTests for and easier to add new features to. So if anyone has any requests please let me know.

Comments are closed