<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7897726346237965482</id><updated>2012-01-09T12:08:33.969-08:00</updated><title type='text'>Random Crap Volume I</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://atappert.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://atappert.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Andrew</name><uri>http://www.blogger.com/profile/01174630370937086286</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7897726346237965482.post-8319329285509419587</id><published>2011-11-30T17:51:00.000-08:00</published><updated>2011-12-02T11:41:14.881-08:00</updated><title type='text'>Unlocking the power of IEnumerable T</title><content type='html'>&lt;div style="background-color: transparent;"&gt;
Since becoming proficient with using LINQ to find shit, I have never looked back. That is until I run into collection types that I can’t immediately query with LINQ expressions. And it seems like every time I encounter such a collection, my first course of action is hate on it for a little while. ControlCollection.FindControl hardly counts as a way to find controls and NameValueCollection has no apparent way to find things just to mention a couple. This goes for any of your custom collection types as well, unless you implemented your own search methods.  &lt;br /&gt;
&lt;br /&gt;
So one thing I have found myself doing time and time again is adding an extension method called AsEnumerable() to these types so that I don’t have to hate them. This method returns the collection as an IEnumerable&amp;lt;T&amp;gt;, unlocking &lt;a href="http://msdn.microsoft.com/en-us/library/ckzcawb8(v=VS.90).aspx"&gt;a pile of extension methods&lt;/a&gt; that allow me to query and otherwise manipulate said collection in more ways than I can imagine.  &lt;br /&gt;
Many collection classes in the framework already provide such a method, but many still do not.  Also note that the non-generic IEnumerable is not the same as the generic one and is far lesser in power compared to its generic counterpart IEnumerable&lt;t&gt;.&lt;/t&gt;&lt;br /&gt;
As an example, lets do this for the ControlCollection class so we can find all the controls on a page that have a certain css class.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable&amp;lt;Control&amp;gt; AsEnumerable(&lt;span class="kwrd"&gt;this&lt;/span&gt; ControlCollection controls)
{
   &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Control ctrl &lt;span class="kwrd"&gt;in&lt;/span&gt; controls)
   {
       &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var subCtrl &lt;span class="kwrd"&gt;in&lt;/span&gt; ctrl.Controls.AsEnumerable())
       {
           &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; subCtrl;
       }
        &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; ctrl;
   }
}&lt;/pre&gt;
&lt;pre class="csharpcode"&gt;&lt;/pre&gt;
&lt;br /&gt;
Now that the extension is in place, we can write some code like this to find what we want:&lt;br /&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Page_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
{
  IEnumerable&amp;lt;Control&amp;gt;&lt;control&gt; blueControls = Controls.AsEnumerable().Where(c =&amp;gt; c.CssClass.Contains(“blue”));
}&lt;/control&gt;&lt;/pre&gt;
&lt;br /&gt;
And for working with QueryStrings, this extension for the NameValueCollection class does the trick:&lt;br /&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IEnumerable&amp;lt;KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&amp;gt; AsEnumerable(&lt;span class="kwrd"&gt;this&lt;/span&gt; NameValueCollection col)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; col.Cast&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;().Select(key =&amp;gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; KeyValuePair&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;(key, col[key]));
}&lt;/pre&gt;
&lt;br /&gt;
Allowing us to do something like this:&lt;br /&gt;
&lt;pre class="csharpcode"&gt;Request.QueryString.AsEnumerable().Where(c =&amp;gt; c.Key == &lt;span class="str"&gt;"someParameter"&lt;/span&gt;);&lt;/pre&gt;
&lt;br /&gt;
Go forth now and be cured of lame collection hate knowing that you can spend less time crawling collections and more time racing against the clock that is always counting, always ticking away at the relevancy of your current developer skill set. &amp;nbsp;Hell, with all the extra time you can spend now writing LINQ instead of wrestling with iterators, think of how much longer you can procrastinate now on that certification your boss has pestering you about...&lt;br /&gt;
&lt;div style="background-color: transparent;"&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7897726346237965482-8319329285509419587?l=atappert.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://atappert.blogspot.com/feeds/8319329285509419587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7897726346237965482&amp;postID=8319329285509419587' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/8319329285509419587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/8319329285509419587'/><link rel='alternate' type='text/html' href='http://atappert.blogspot.com/2011/11/unlocking-power-of-ienumerable.html' title='Unlocking the power of IEnumerable T'/><author><name>Andrew</name><uri>http://www.blogger.com/profile/01174630370937086286</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7897726346237965482.post-8847313531865809982</id><published>2010-03-12T16:49:00.000-08:00</published><updated>2012-01-09T12:08:33.984-08:00</updated><title type='text'>Making Sharepoint RTE aways create a popup window for editing</title><content type='html'>stick this hackjob of a function in your head tag and call it at the end of your document.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; function fixEditorButtons()&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;// rewire rich text editor buttons to popup source view RTE window in content mode&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var anchors = document.getElementsByTagName("A");&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;if(anchors.length == 0)
return;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var rteArray = new Array();&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;// gather up the rich text editor edit buttons&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;for(var i = 0; i &amp;lt; anchors.length; i++)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;if(anchors[i].attributes.getNamedItem("title") != null)&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;if(anchors[i].attributes.getNamedItem("title").value == "Edit Content")&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;rteArray.push(anchors[i]);&amp;nbsp;}}}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;for(var i = 0; i &amp;lt; rteArray.length; i++)
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var oEditButton = rteArray[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;// grab the code as SP created it&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var code = new String(oEditButton.onclick);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;// snag the control name of the RTE current display control&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var controlnameBeginIndex = code.search(/RTE2_LaunchEditor/) + 27;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var temp = code.substring(controlnameBeginIndex);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var controlnameEndIndex = temp.search(/\'/);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var controlName = temp.substring(0,controlnameEndIndex) + "_displayContent";&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;// find where we need to insert our additional code that creates the popup window&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var insertPoint = code.search(/cancelBubble/) - 67;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;// build new code, start with old code&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;var newcode = code.substring(0,insertPoint);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;newcode += "RTE2_SaveHtmlStateIfChanged('" + controlName + "');";&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;newcode += "var instanceVariables=RTE_GetEditorInstanceVariables('"+ controlName +"');";&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;newcode += "RTE2_LaunchEditor( instanceVariables.aSettings, instanceVariables.clientId,&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;instanceVariables.displayContentElement.id, instanceVariables.emptyPanel.id,&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;instanceVariables.hiddenInputField.id, instanceVariables.webUrl,&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;'True', false,true);";&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;newcode += code.substring(insertPoint);

rteArray[i].onclick =&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;Function(newcode.slice(20,newcode.length - 1));&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7897726346237965482-8847313531865809982?l=atappert.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://atappert.blogspot.com/feeds/8847313531865809982/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7897726346237965482&amp;postID=8847313531865809982' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/8847313531865809982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/8847313531865809982'/><link rel='alternate' type='text/html' href='http://atappert.blogspot.com/2010/03/making-sharepoint-rte-aways-create.html' title='Making Sharepoint RTE aways create a popup window for editing'/><author><name>Andrew</name><uri>http://www.blogger.com/profile/01174630370937086286</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7897726346237965482.post-1931106720259509619</id><published>2008-03-06T09:50:00.000-08:00</published><updated>2008-03-06T14:48:50.386-08:00</updated><title type='text'>Are parents responsible the delinquency of teenaged SPLists?</title><content type='html'>Ever since I hooked up with Microsoft and began fathering little bits of softwares, I always thought that I would raise good code. However, like many have endured, one of my softwares began acting defiant and outrageous. We debugged the software repeatedly and how stubborn it was! Certainly didn't get any of that from MY influence! ahem! Lets get into the psyche of this little rebel a bit...
&lt;br/&gt;&lt;br/&gt;
&lt;code&gt;
public static SPList GetListByName(SPWeb rootWeb, string listName)&lt;br/&gt;
{&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach (SPList list in rootWeb.Lists)&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (list.Title.Equals(listName, &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StringComparison.InvariantCultureIgnoreCase))&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return list;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach (SPWeb web in rootWeb.Webs)&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SPList resultList = GetListByName(web, listName);&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (resultList != null)&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return resultList;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return null;&lt;br/&gt;
}&lt;br/&gt;&lt;br/&gt;
&lt;/code&gt;

Take a look at the base case where the list is found and returned. Pretty standard stuff no? What is not (by even a far stretch of even the most eclectic programmer's imagination) obvious here is that the list being returned has a... how do I say this.... &lt;em&gt;special&lt;/em&gt; Views property (of type SPViewCollection). The crime here is that these views are wrong. No, The collection isn't empty, it doesn't throw exceptions when you try to access it, it isn't null, it doesn't contain any number of views other than the amount of views it really does have, and the views aren't uninitialized or anything. They are wrong because they only have two columns, no matter what.&lt;br/&gt;&lt;br/&gt;

The victim of such a crime is one that wants the list for its views and is given this list as joke. How did I deal with such reckless behavior? Well, it didn't go down without a hairy fight thats for sure, but in the end, I taught it to return regular SPLists that were not special.
&lt;br/&gt;&lt;br/&gt;
&lt;code&gt;
SPSite s = SPContext.Current.Site;&lt;br/&gt;
SPList l = s.AllWebs[rootWeb.Name].Lists[listName];&lt;br/&gt;
return l;&lt;br/&gt;
&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7897726346237965482-1931106720259509619?l=atappert.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://atappert.blogspot.com/feeds/1931106720259509619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7897726346237965482&amp;postID=1931106720259509619' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/1931106720259509619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/1931106720259509619'/><link rel='alternate' type='text/html' href='http://atappert.blogspot.com/2008/03/are-parents-responsible-delinquency-of.html' title='Are parents responsible the delinquency of teenaged SPLists?'/><author><name>Andrew</name><uri>http://www.blogger.com/profile/01174630370937086286</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7897726346237965482.post-350458884708254122</id><published>2008-02-05T16:14:00.000-08:00</published><updated>2008-02-05T16:55:21.093-08:00</updated><title type='text'>Revision# 6,450,002.0 of the command line parameter parsing piece</title><content type='html'>One of the most re-invented wheels of all time is the one which takes options from a set of command line arguments. It's a fine tradition to reinvent this wheel and here I present the fruits of today's celebration.


&lt;pre style="color:#666666"&gt;
static void Main(string[] args)
{
    string option1 = getCommandLineParameter("-option1", args);
    string option2 = getCommandLineParameter("-option2", args);

    if (option1 != null &amp;&amp; option2 != null)
    {
        // react to these parameters
    }
    else
    {
        // react to these parameters not being given
    }
}


private static string getCommandLineParameter(string optionName, string[] args)
{
    short i;
    for (i = 0; i &lt; args.Length; i++)
    {
        if (args[i] == optionName)
        {
            if (args[i + 1] != null)
            {
                return args[i + 1];
            }
            else
            {
                return null;
            }
        }
    }

    return null;
}

&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7897726346237965482-350458884708254122?l=atappert.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://atappert.blogspot.com/feeds/350458884708254122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7897726346237965482&amp;postID=350458884708254122' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/350458884708254122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/350458884708254122'/><link rel='alternate' type='text/html' href='http://atappert.blogspot.com/2008/02/revision-64500020-of-command-line.html' title='Revision# 6,450,002.0 of the command line parameter parsing piece'/><author><name>Andrew</name><uri>http://www.blogger.com/profile/01174630370937086286</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7897726346237965482.post-4458077073565382909</id><published>2008-01-28T14:40:00.000-08:00</published><updated>2008-01-28T14:50:04.767-08:00</updated><title type='text'>If operating systems were beers...</title><content type='html'>&lt;li&gt;DOS Beer&lt;/li&gt;&lt;br/&gt;
Requires you to use your own can opener, and requires you to read the directions carefully before opening the can. Originally only came in an 8-oz. can, but now comes in a 16-oz. can. However, the can is divided into 8 compartments of 2 oz. each, which have to be consumed separately. Although soon to be discontinued, a lot of people are going to keep drinking it after it’s no longer available.&lt;br/&gt;&lt;br/&gt;

&lt;li&gt;Mac Beer&lt;/li&gt;&lt;br/&gt;
At first, came only in a 16-oz. can, but now comes in a 32-oz. can. Considered by many to be a “light” beer. All the cans look identical. When you take one from the fridge, it opens itself. The ingredients list is not on the can. If you call the brewery to ask about the ingredients, you are told that “you don’t need to know.” A notice on the side reminds you to drag your empties to the trash can.&lt;br/&gt;&lt;br/&gt;

&lt;li&gt;Windows 3.1 Beer&lt;/li&gt;&lt;br/&gt;
The world’s most popular. Comes in a 16-oz. can that looks a lot like Mac Beer’s. Requires that you already own DOS Beer. Claims that it allows you to drink several DOS Beers simultaneously, but in reality you can only drink a few of them, very slowly. Especially slow if you are drinking the Windows Beer at the same time. Sometimes, for apparently no reason, a can of Windows Beer will explode when you open it.&lt;br/&gt;&lt;br/&gt;

&lt;li&gt;OS/2 Beer&lt;/li&gt;&lt;br/&gt;
Comes in a 32-oz can. Does allow you to drink several DOS Beers simultaneously. Allows you to drink Windows 3.1 Beer simultaneously too, but somewhat slower. Advertises that its cans won’t explode when you open them, even if you shake them up first. You never really see anyone drinking OS/2 Beer, but the manufacturer (International Beer Manufacturing) claims that 9 million six-packs have been sold.&lt;br/&gt;&lt;br/&gt;

&lt;li&gt;Windows 95 Beer&lt;/li&gt;&lt;br/&gt;
No one drinks it much yet, but a lot of people have taste-tested it and claim it’s wonderful. The can looks a lot like Mac Beer’s can, but tastes more like Windows 3.1 Beer. It comes in 32-oz. cans, but when you look inside, the cans only have 16 oz. of beer in them. Most people will probably keep drinking Windows 3.1 Beer until their friends try Windows 95 Beer and say they like it. The ingredients list, when you look at the small print, has some of the same ingredients that come in DOS beer, even though the manufacturer claims that this is an entirely new brew.
&lt;br/&gt;&lt;br/&gt;

&lt;li&gt;Windows NT Beer&lt;/li&gt;&lt;br/&gt;
Comes in 32-oz. cans, but you can only buy it by the truckload. This causes most people to have to go out and buy bigger refrigerators. The can looks just like Windows 3.1 Beer’s, but the company promises to change the can to look just like Windows 95 Beer’s - after Windows 95 Beer starts shipping. Touted as an “industrial strength” beer, and suggested only for use in bars.&lt;br/&gt;&lt;br/&gt;

&lt;li&gt;UNIX Beer&lt;/li&gt;&lt;br/&gt;
Comes in several different brands, in cans ranging from 8 oz. to 64 oz. Drinkers of UNIX Beer display fierce brand loyalty, even though they claim that all the different brands taste almost identical. Sometimes the pop-tops break off when you try to open them, so you have to have your own can opener around for those occasions, in which case you either need a complete set of instructions or a friend who has been drinking UNIX Beer for several years.&lt;br/&gt;&lt;br/&gt;

&lt;li&gt;AmigaDOS Beer&lt;/li&gt;&lt;br/&gt;
The company has gone out of business, but their recipe has been picked up by some weird German company, so now this beer will be an import. AmigaDOS Beer never really sold very well because the original manufacturer didn’t understand marketing. Like UNIX Beer, AmigaDOS Beer fans are an extremely loyal and loud group. It originally came in a 16-oz. can, but now comes in 32-oz. cans too. When this can was originally introduced, it appeared flashy and colorful, but the design hasn’t changed much over the years, so it appears dated now. Critics of this beer claim that it is only meant for watching TV anyway.&lt;br/&gt;&lt;br/&gt;

&lt;li&gt;VMS Beer&lt;/li&gt;&lt;br/&gt;
Requires minimal user interaction, except for popping the top and sipping. However, cans have been known on occasion to explode, or contain extremely un-beer-like contents. Best drunk in high pressure development environments. When you call the manufacturer for the list of ingredients, you’re told that it’s proprietary and referred to an unknown listing in the manuals published by the FDA. Rumors have it that this was once listed in the Physicians’ Desk Reference as a tranquilizer, but no one can claim to have actually seen it.

&lt;br/&gt;&lt;br/&gt;
Note: I did not author this, I found it on the net somewhere.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7897726346237965482-4458077073565382909?l=atappert.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://atappert.blogspot.com/feeds/4458077073565382909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7897726346237965482&amp;postID=4458077073565382909' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/4458077073565382909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/4458077073565382909'/><link rel='alternate' type='text/html' href='http://atappert.blogspot.com/2008/01/if-operating-systems-were-beers.html' title='If operating systems were beers...'/><author><name>Andrew</name><uri>http://www.blogger.com/profile/01174630370937086286</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7897726346237965482.post-2698475750505821522</id><published>2008-01-28T11:42:00.001-08:00</published><updated>2008-01-28T12:28:13.304-08:00</updated><title type='text'>An initial public offering</title><content type='html'>I no longer know how this thing works and so I must set it free. My old roomate remembers me cracking away at this some years ago - I'll take his word for it. I should probably remove VBScript from my résumé (and good riddance!).

Save this text into a text file with a .wsf extension (i.e. playlistgenerator.wsf)
It is a playlist generator BTW.

&lt;pre style="COLOR: #666666"&gt;
&amp;lt;job&amp;gt;
  &amp;lt;object id = oRS progid = "ADODB.Recordset"/&amp;gt;
  &amp;lt;reference object = "ADODB.Recordset"/&amp;gt;
  &amp;lt;script language = "VBScript"&amp;gt;
    Option Explicit

    Sub DefineAndOpenRS()
      'Define and open the disconnected recordset

      With oRS
        .ActiveConnection = Nothing
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .LockType = adLockBatchOptimistic
        With .Fields
          .Append "MyStuff", adVarChar, 255
        End With
        .Open
      End With
    End Sub

    Sub InsertRow(sData)
      'Add data to a new row in the recordset

      oRs.AddNew
      oRS.Fields.Item("MyStuff").Value = sData
    End Sub

    Function ConcatRows()
      With oRS
        .MoveFirst
        ConcatRows = ""
        Do
          if oRS.Fields.Item("MyStuff").Value = "playlist generator" or _
             oRS.Fields.Item("MyStuff").Value = "playlist.m3u" then
            ' do nothing
          else
            ConcatRows = ConcatRows _
            &amp;amp; .Fields.Item("MyStuff").Value _
            &amp;amp; vbNewLine
          end if

          .MoveNext
        Loop Until .EOF
      End With
    End Function

    Dim lItem, sResults

    DefineAndOpenRS

    dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")

    dim folder
    Set folder = fso.GetFolder(".")

    dim fileList
    Set fileList = folder.Files

    dim playListFile
    Set playListFile = folder.CreateTextFile("playlist.m3u", true)

    dim file
    for each file in fileList
      if file.Name = "playlist generator.wsf" or file.Name = "playlist.m3u" then
        ' do nothing
      else
        InsertRow(file.Name)
      end if
    next

    oRS.Sort = "MyStuff ASC"

    do while not oRS.eof
      playListFile.WriteLine(oRS.Fields.Item("MyStuff").Value)
      oRS.movenext
    loop

    playListFile.Close

    sResults = ConcatRows()
    oRS.Close
    MsgBox sResults, vbOkOnly
  &amp;lt;/script&amp;gt;
&amp;lt;/job&amp;gt;



&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7897726346237965482-2698475750505821522?l=atappert.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://atappert.blogspot.com/feeds/2698475750505821522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7897726346237965482&amp;postID=2698475750505821522' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/2698475750505821522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7897726346237965482/posts/default/2698475750505821522'/><link rel='alternate' type='text/html' href='http://atappert.blogspot.com/2008/01/initial-public-offering.html' title='An initial public offering'/><author><name>Andrew</name><uri>http://www.blogger.com/profile/01174630370937086286</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
