Wednesday, July 27, 2011

Installing Sharepoint Server 2010

<a href='' target='_new' title='Installing SharePoint Server 2010'>Video: Installing SharePoint Server 2010</a>

Sunday, May 1, 2011

(cautiously) Using extension methods to make (cleaner?) code.

I’ve read allot of warning as I learned about extension methods.  To me they have a similar “feel” to them as macros did in C/C++.  The trap that exists is the ability to make a complicated contraptions that seem really slick when coding but aren’t actually a good thing in the long run – i.e. down the road either you or someone like you will spend more time figuring out what is going on than it’s worth.

Still, I’m using them here and there.  I tell myself I’ve gone down the bad road of complexity in my past experience enough to keep it under control.

But the feeling in the back of my mind is that I’m playing with fire.

Time will tell.

Maybe I’ll come back to this in a half a year and note if I was right to be cautious.

Example Scenario: You are using a BindingSource with a DataSet and a DataGridView.  You want to access the row but it’s a pain to cast twice.


I could write a private member function but it would be a one off.   I could write a public static helper member function, but I’d end up with a different style of code:

MyUtility.GetRowAt<DataSet1>.MyDataRowType>(bindingSource, rowIndex)

That’s not really bad.

And the extension method version isn’t much different.

static class MyExt
internal static T
this BindingSource bs, int i)
where T : class
return ((DataRowView)bs[i]).Row as T;

However, with the extension method, my code doesn’t switch over to the “utility call” style, which to me, brings the level of indirection, and the associated complexity more the fray than:

Just like macros, my code is what I want it to be right now, and I got around a limitation by leveraging a language feature providing generic extensibility.
So the question is: will I regret this?

Tuesday, February 15, 2011

Code to do a simple regex extraction


I like about the above:

  • one line does the match and one line does the extraction of the match and the conversion to the target type
  • to me, it reads clearly
  • it seems like a good use of “var” because I don’t care much that “reg” is a GroupCollection

Used LINQ to Coalesce Form Keys


Display Multiple Currency Symbols in C#

If you have a money amount:

decimal money = 107.04;

And know the code for a culture:

string cultureName = “en-gb”; // display currency in pounds

Create string containing a culture specific currency:

string formattedCurrency = String.Format(CultureInfo.CreateSpecificCulture(map[cur]), "{0:C}", decimal);

The table is on msdn:

Then you can insert that string into HTML (tested on IE 8):


Monday, February 14, 2011

Sql Server 2008 Security/Logins

I’m using windows authentication in an intranet.

The way I am configuring permissions is:

1. Add a login for an individual or group to the instance level security.

2. Set the user mappings for databases I wish to give access, assigning roles.


Predefined database roles:

  • db_owner: Members have full access.
  • db_accessadmin: Members can manage Windows groups and SQL Server logins.
  • db_datareader: Members can read all data.
  • db_datawriter: Members can add, delete, or modify data in the tables.
  • db_ddladmin: Members can run dynamic-link library (DLL) statements.
  • db_securityadmin: Members can modify role membership and manage permissions.
  • db_bckupoperator: Members can back up the database.
  • db_denydatareader: Members can’t view data within the database.
  • db_denydatawriter: Members can’t change or delete data in tables or views.


Captain’s Log

This morning I added a feature to the campaign page to copy info to clipboard.

I needed to review the details surrounding how to wire a client side click to individually rendered elements of the template.

Found How to dynamically set control IDs inside a repeater template?

How does one copy to the clipboard via JavaScript?

Found (IE only)

My Code: Copy-To-Clipboard client side click handler.


What can I use for a copy-to-clipboard icon?

Now the page has the functional copy icon in it:
My Code: ASP.NET logic for putting a copy-to-clipboard icon after the short description of the campaign.
Issue: The feature is not fully useful until I change the ETL to bring in the entire description as opposed to the first 255 characters only. Pros and Cons?

Monday, January 24, 2011

Code and Example of FormSerializer utility class.


You are writing a windows forms application and you want a simple way to save the location (and possibly other properties) of your WinForms.

Code for FormSerializer

using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace EomApp1.UI
    public class FormSerializer
        public static void Serialize(Form f, string path)
            XmlSerializer xs = new XmlSerializer(typeof(FormProps));
            using (Stream s = File.Create(path))
                    FormProps props = new FormProps();
                    props.x = f.Location.X;
                    props.y = f.Location.Y;
                    xs.Serialize(s, props);
        public static void Deserialize(Form f, string path)
            XmlSerializer xs = new XmlSerializer(typeof(FormProps));
            if (File.Exists(path))
                using (Stream s = File.OpenRead(path))
                        FormProps props = (FormProps)xs.Deserialize(s);
                        f.Location = new Point(props.x, props.y);
        public class FormProps
            public int x;
            public int y;