EPiServer Extension methods, part 1 of many
November 7, 2009
So Frederik Vig started a community project around EPiServer Extensions which I believe is a great initiative. Already having a great number of extension methods that we are currently using.
Rather than just dump them in the source code repository I thought I would try to get my blogging going again by posting each method with a short blog post so that people can comment easy and come with suggestions for improvement
One liners
October 12, 2007
OK, can’t really take credit for this one (thx Cristian), but wanted to share a C# one liner with you. If you know me and seen my code you should know that I love those one line statements, especially for properties.
So here it is, a one line lazy load property:
private ArrayList _lazyLoadedList;
public ArrayList LazyLoadedList
{
get { return _lazyLoadedList ?? (_lazyLoadedList = new ArrayList()); }
}
And while we’re sharing, you can know that this is how my standard ViewState properties has been looking since 2.0.
public virtual string Text
{
get { return (string)(ViewState["Text"] ?? string.Empty); }
set { ViewState["Text"] = value; }
}
Damn I love that ??-operator!