Utilities

FogCreek.Core.Arrays

Class that provides static utility methods for manipulating arrays in Wasabi. Since Wasabi lacks support for generics, these methods are implmented as code generators that produce type specific methods.

Append

Concatenates two arrays together producing a new array:

Dim zs = Arrays.AppendInt32(xs, ys)

ArrayFromICollection

Coverts an ICollection into a strongly typed array. Useful for allowing you to build up a list of objects using a .NET collection and then turn it into an array after you’re done with it:

Dim result = Arrays.ArrayFromICollectionInt32(list)

Filter

Produces a new array containing only the values that match the supplied predicate:

Dim ys = Arrays.FilterInt32(xs, Lambda (x) x > 0)

Map

Produces a new array containing the result of passing eacy element through a transformation function:

Dim ys = Arrays.MapInt32ToInt32(xs, Lambda (x) x + 1)

FogCreek.Core.Html

Encode

HTML encodes the string that’s passed in making it safe fore inclusion as a text node in an HTML document:

<p class="comment"><%= Html.Encode(comment.body) %></p>

AttributeEncode

Warning

Html.AttributeEncode() does not encode ', or > this means two things:

  1. Attributes in HTML must be quoted using double quotes ("), otherwise an encoded string could prematurely terminate the attribute resulting in an XSS vulnerability.
  2. Html.AttributeEncode() should not be used outside of HTML attributes, because doing so can allow illegal characters through (>) which can result in an invalid HTML document (though probably not an XSS vulnerability).

Replaces ", <, and & with their repective HTML entities making an arbitrary string suitable for use inside an HTML attribute:

<p data-user-name="<%= Html.AttributeEncode(user.name)">...</p>

Table Of Contents

Previous topic

Classes

Next topic

Glossary

This Page