Cross Live Writer // 01

After some time spent reading and trying to figure out where to start the porting on Open Live Writer, I started converting on of the projects of the solutions, “HTML Parser” to a PCL in order to be able to use this code later in my Xamarin apps.

I thought to share my changes here on my blog:

ArrayList

This collection dynamically resizes. It grows in capacity as elements are added (if space is needed). It is most often used in older C# programs. – DotNetPerls

This class has been around since the first versions of .Net and since non generic collections are not available in PCL I’ve changed all the ArrayList to List<T>

HashTable

This optimizes lookups. It computes a hash of each key you add. It then uses this hash code to look up the element very quickly. – DotNetPerls

This is the ancestor of the dictionary, it is slower and again not available in PCL. I’ve changed all the Hastable to Dictionary<T,T>

Stack

Stack is a LIFO collection. It provides a powerful and simple last-in-first-out data structure. This can help you develop parsers quickly and also replace complex recursive algorithms. Stack is a generic type. – DotNetPerls

To use Stack, we just need to specify the type so change Stack to Stack<T>

Web.HttpUtility

This class is not available in the PCL profile we use but we can use

that exposes the methods we need.

IsInstanceOfType

Again this is not available but we can use:

that returns a bool like Type.IsInstanceOfType

This is almost all the changes I had to do to make a buildable PCL of HTMLParser, I haven’t had already time to test it and see the performances but it should work ok.