Blog of a Filipino Developer about C#, VB.NET, ASP.NET, Java, PHP, SQL Server, MySql and Oracle RSS 2.0
 Thursday, June 26, 2008

In part 3 of our series "Ten Questions - Filipino Developer Edition",  I was able to talk to Melvin Dave Vivas, founder of PinoyJUG, developer, technopreneur and part-time fashion photojounalist(Heheh! I bet he wants me to include this on his intro :P).

Read more about this interview here.

Thursday, June 26, 2008 6:02:41 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Fun Stuff | Interviews
 Tuesday, June 24, 2008

A friend of mine sent this link to me today and it made me really laugh really hard... Man, talk about someone posting a review on something that they don't really understand.

Actual review link can be found here: http://www.amazon.com/review/product/B000PSWZSC/ref=cm_cr_pr_link_2?%5Fencoding=UTF8&pageNumber=2&sortBy=bySubmissionDateDescending

Comments about his post can be found here: http://www.amazon.com/review/R1PPJ35WY17216/ref=cm_cr_pr_cmt?%5Fencoding=UTF8&ASIN=B000PSWZSC&nodeID=#wasThisHelpful

Hehehe!

Tuesday, June 24, 2008 9:50:44 PM (GMT Standard Time, UTC+00:00)  #    Comments [1] -
Fun Stuff | Weird Wide Web

This week we continue our quest to get to know well-known Filipino developers and this time I was able to catch Jojo Paderes, one of the founding board members of PinoyJUG, coder-extraordinaire at Viewlocity and father to two lovely twins.

Read more about this interview here http://devpinoy.org/blogs/keithrull/archive/2008/06/24/ten-questions-with-jojo-paderes.aspx

Tuesday, June 24, 2008 6:32:21 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Fun Stuff | Interviews
 Friday, June 20, 2008

Because of the inspiration from what Chris Williams started I have decided to start Ten Questions - Filipino Developers Edition. Basically, the idea is to interview well-known Filipino developers and ask them 10 questions that would shed light on their persona and their geekiness!

On this first go around we interview Migz Paraz, a fixture in the Philippine IT industry since the 90s. He is well-known for his involvement with the Filipino Java community and for his thoughts posted on his blog at paraz.com among others.

Read more about this interview here.

http://devpinoy.org/blogs/keithrull/archive/2008/06/20/ten-questions-with-migz-paraz.aspx

Friday, June 20, 2008 10:22:03 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
DevConversations | Fun Stuff
 Monday, February 04, 2008
It's funny, just after posting this post in response to an article that N@rds posted that I realized that I have been preaching about extension methods and his problem was a great example on when to make use of this excellent feature.
Monday, February 04, 2008 6:00:07 PM (GMT Standard Time, UTC+00:00)  #    Comments [2] -
.NET | Fun Stuff | Tutorial
 Friday, February 01, 2008
I wrote an article about this topic a few months ago but I wanted to explain it a little further in this article by showing real-world scenarios on when and how to use this feature. So what does Extension Method mean? According to MSDN: "Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type." Now that we have that settled lets look at a good scenario that depicts a great time when to use an Extension Method.
Friday, February 01, 2008 9:15:19 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Fun Stuff | Tutorial
 Saturday, January 26, 2008

Me and my wife will be at the Code Camp in Fullerton tommorow and we are excited. Code Camp is a great time to get together, learn new things about technology and network with people with the same mindset about technology and that is passion for learning and enriching knowledged. We are driving tonight to Fullerton so that we can be early tommorow.

There are already a few sessions that I am eyeing to go to. One of them is the session of John Bowen regarding WPF DataBinding and WPF controls. I met John Bowen 3 years ago in the .NET Rocks roadshow bus. I think this session is going to be awesome. I've been playing with alot of WPF lately and I'm interested in seeing and learning cool things about this technology.

Another session I'd love to see is the topic "Branching and Merging Guidance for VSTS 2008 and Team Foundation Server" presented by Mickey Williams. I haven't done anything with VSTS before but I know its going to be a great primer for me because merging and branching is one of the things that happens alot when you are in a team development environment.

Oh boy! This is going to be a great Code Camp. Time to go home and get ready for this event. See you there!

Saturday, January 26, 2008 1:17:37 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | All about Keith | Fun Stuff | Life | Tech News and Issues | Your Career | Code Camp
 Friday, January 25, 2008

I encountered a problem today with one of my projects. The problem was about a third-party application choking when it encounters files greater than 20MB. I have a Windows Service that creates PDFs of KPIs for around 150 users and each of the file that I generate is around 25MB each. I can compress the PDF file to lower resolution format but the management decided that we shouldn't trade quality over speed so I was stuck thinking of a different solution.

Then it came to me that I can zip the files so that I get a smaller file.

I started evaluating C# zip libraries and ended up choosing #ZipLib from the creators of SharpDevelop because of it's simplicity and robustness. The only thing I didn't like was the fact that I wasn't find a great documentation about the library. I ended up fiddling with it. It wasn't hard but you need to play with it alot to understand whats happening in the background.

Ok, now lets start by identifying what we need to create a zip file with SharpZipLib. The first thing that you need to do is download the binaries from the #ZipLib website and reference that DLL in your project.

Now that is done you need to add the ICSharpCode.SharpZipLib namespace in you source file to be able to start creating zip files using the #ZipLib library.

To start creating a zip file, all you need to do is to initialize a ZipFile object.

//initialize the file so that it can accept updates
ZipFile z = ZipFile.Create(filename);

The code above creates a new zip file with the specified filename. Next we need to call the BeginUpdate method of the ZipFile object to tell it that we are going to do some modifications to that file.

//initialize the file so that it can accept updates
z.BeginUpdate();

At this stage we can now add files to our zip file.

//add your file e.g "c:\reports\gummywhammyyummy.pdf"
z.Add(<Your file to add including it's path>);

Once you are done you need to commit  your changes and close the file.

//commit the update once we are done
z.CommitUpdate();
//close the file
z.Close();

Done. Now you have created your first zip file using #ZipLib. Neat! Below is the complete code listing of what we did above

/// <summary>
/// A method that creates a zip file
/// </summary>
/// <param name="zipFileStoragePath">the storage location</param>
/// <param name="zipFileName">the zip file name</param>
/// <param name="fileToCompress">the file to compress</param>
private void CreateZipFile(string zipFileStoragePath
    , string zipFileName
    , string fileToCompress)
{
    //create our zip file
    ZipFile z = ZipFile.Create(zipFileStoragePath + zipFileName);

    //initialize the file so that it can accept updates
    z.BeginUpdate();

    //add the file to the zip file
    z.Add(fileToCompress);

    //commit the update once we are done
    z.CommitUpdate();
    //close the file
    z.Close();
}

But what if you want to add a directory to your zip file? The ZipFile object provides a method called AddDirectory() that accepts a parameter directoryName. The problem with this method is that it doesn't add the files inside the specified directory but instead just creates a directory inside the zip file. To make this work, you need to get the files inside that directory by looping thru all objects in that directory and adding them one at a time. I was able to accomplish this task by creating a recursive function that drills through the whole directory structure of the folder you want to zip. Below is a snippet of the function.

/// <summary>
/// Creates a zip file
/// </summary>
/// <param name="zipFileStoragePath">where to store the zip file</param>
/// <param name="zipFileName">the zip file filename</param>
/// <param name="fileToZip">the file to zip</param>
/// <returns>indicates whether the file was created successfully</returns>
private bool CreateZipFile(string zipFileStoragePath
    , string zipFileName
    , FileInfo fileToZip)
{
    return CreateZipFile(   zipFileStoragePath
                        ,   zipFileName
                        ,   (FileSystemInfo)fileToZip);
}

/// <summary>
/// Creates a zip file
/// </summary>
/// <param name="zipFileStoragePath">where to store the zip file</param>
/// <param name="zipFileName">the zip file filename</param>
/// <param name="directoryToZip">the directory to zip</param>
/// <returns>indicates whether the file was created successfully</returns>
private bool CreateZipFile(string zipFileStoragePath
    , string zipFileName
    , DirectoryInfo directoryToZip)
{
    return CreateZipFile(   zipFileStoragePath
                        ,   zipFileName
                        ,   (FileSystemInfo)directoryToZip);
}

/// <summary>
/// Creates a zip file
/// </summary>
/// <param name="zipFileStoragePath">where to store the zip file</param>
/// <param name="zipFileName">the zip file filename</param>
/// <param name="fileSystemInfoToZip">the directory/file to zip</param>
/// <returns>indicates whether the file was created successfully</returns>
private bool CreateZipFile(string zipFileStoragePath
    , string zipFileName
    , FileSystemInfo fileSystemInfoToZip)
{
    return CreateZipFile(   zipFileStoragePath
                        ,   zipFileName
                        ,   new FileSystemInfo[] 
                            { 
                                fileSystemInfoToZip 
                            });
}

/// <summary>
/// A function that creates a zip file
/// </summary>
/// <param name="zipFileStoragePath">location where the file should be created</param>
/// <param name="zipFileName">the filename of the zip file</param>
/// <param name="fileSystemInfosToZip">an array of filesysteminfos that needs to be added to the file</param>
/// <returns>a bool value that indicates whether the file was created</returns>
private bool CreateZipFile(string zipFileStoragePath
    , string zipFileName
    , FileSystemInfo[] fileSystemInfosToZip)
{
    // a bool variable that says whether or not the file was created
    bool isCreated = false;

    try
    {
        //create our zip file
        ZipFile z = ZipFile.Create(zipFileStoragePath + zipFileName);
        //initialize the file so that it can accept updates
        z.BeginUpdate();
        //get all the files and directory to zip
        GetFilesToZip(fileSystemInfosToZip, z);
        //commit the update once we are done
        z.CommitUpdate();
        //close the file
        z.Close();
        //success!
        isCreated = true;
    }
    catch (Exception ex)
    {
        //failed
        isCreated = false;
        //lets throw our error
        throw ex;
    }
 
    //return the creation status
    return isCreated;
}

/// <summary>
/// Iterate thru all the filesysteminfo objects and add it to our zip file
/// </summary>
/// <param name="fileSystemInfosToZip">a collection of files/directores</param>
/// <param name="z">our existing ZipFile object</param>
private void GetFilesToZip(FileSystemInfo[] fileSystemInfosToZip, ZipFile z)
{
    //check whether the objects are null
    if (fileSystemInfosToZip != null && z != null)
    {
        //iterate thru all the filesystem info objects
        foreach (FileSystemInfo fi in fileSystemInfosToZip)
        {
            //check if it is a directory
            if (fi is DirectoryInfo)
            {
                DirectoryInfo di = (DirectoryInfo)fi;
                //add the directory
                z.AddDirectory(di.FullName);
                //drill thru the directory to get all
                //the files and folders inside it.
                GetFilesToZip(di.GetFileSystemInfos(), z);
            }
            else
            {
                //add it
                z.Add(fi.FullName);
            }
        }
    }
}

A sample usage of this function would be like this:

//sample usage for zipping a file
private void zipItButton_Click(object sender, EventArgs e)
{
    string fileToZip = fileToZipTextBox.Text;
    string zipFilename = Guid.NewGuid() + ".zip";

    //zip a file
    bool isCreated = CreateZipFile(
                                        CONST_ZIP_FILE_STORAGE
                                    ,   zipFilename
                                    ,   new FileInfo(fileToZip) );

    if (isCreated) {
        MessageBox.Show(zipFilename);
    }
    else {
        MessageBox.Show("Failed");
    }
}

//sample usage for zipping a directory
private void zipFolderButton_Click(object sender, EventArgs e)
{
    string directoryToZip = whereToZipTextBox.Text;
    string zipFilename = Guid.NewGuid() + ".zip";

    //zip a directory
    bool isCreated = CreateZipFile(
                            CONST_ZIP_FILE_STORAGE
                        , zipFilename
                        , new DirectoryInfo(directoryToZip) );

    if (isCreated){
        MessageBox.Show("Created " + zipFilename);
    }
    else{
        MessageBox.Show("Failed");
    }
}

And that's it. I hope i was able to shed light on you can create zip files in few easy steps with C#. If you are interested you can checkout this sample application that I built to demonstrate how to create zip files with C# and SharpZipLib.

Download the source code here. KeithRull.CreatingZipFiles.zip (19.15 KB)

Friday, January 25, 2008 8:59:16 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Fun Stuff | Tutorial
 Wednesday, January 23, 2008

Yesterday I wrote an article explaning what var means in .NET 3.x. Today lets talk about Anonymous Types.

Anonymous Types as describe by the C# 3.0 specification are tuple types automatically inferred and created from object initializers. Anonymous Types allows the new operator to be used with an anonymous object initializer to create an object at compile time. The format for an anonymous type declaration is a follows

var v = new { p1 = e1 , p2 = e2 , ... px = ex }

where v is the var variable, px denotes the property name and ex is equaivalent value.

Enough with the theory and lets look at some actual code. Lets assume that I have a class called Person with the following properties:

public class Person
{
    private string _name;
    private int _age;
    private bool _believesInJesus;

    public string Name
    {
        get { return _name; }
        set { _name = value; }
    }

    public int Age
    {
        get { return _age; }
        set { _age = value; }
    }

    public bool BelievesInJesus
    {
        get { return _believesInJesus; }
        set { _believesInJesus = value; }
    }
}

Let's say that I want to create an Anonymous Type that has a similar structure from what we have above, all I need to do is make this call:

var human = new { Name = "Keith", Age = 25, BelievesInJesus = true };

What happens in compile time is that the .NET compiler generates a class that represents the structure of your Anonymous Type.

public class __Anonymous1
{
    private string _name;
    private int _age;
    private bool _believesInJesus;

    public string Name { get { return _name; } set { _name = value; } }
    public int Age { get { return _age; } set { _age = value; } }
    public bool BelievesInJesus { get { return _believesInJesus; } set { _believesInJesus = value; } }
}

It's an  "Anonymous Type" because it a nameless class, it's generated by the compiler for you and it directly inherits from object.

To prove this let's look at this example:

class Program
{
    static void Main(string[] args)
    {
        var person = new { Name = "Keith", Age = 25, BelievesInJesus = true };

        Console.WriteLine(person.Name);
        Console.WriteLine(person.GetType());
        Console.ReadLine();
    }
}

Hovering at the person variable would give us some information about it's type:

The code above will have this output:

As you can see, the compiler created an Anonymous Type Called <>f__AnonymousType0`3. One thing to note about Anonymous Types is that the compiler is smart enough to figure out if an Anonynous Type has already been declared that meets the schema requirement of your new Anonymous Type.

    class Program
    {
        static void Main(string[] args)
        {
            var person1 = new { Name = "Keith", Age = 25, BelievesInJesus = true };
            var person2 = new { Name = "Charissa", Age = 23, BelievesInJesus = true };
            var person3 = new { Name = "Peter", Age = 23};

            Console.WriteLine(person1.Name);
            Console.WriteLine(person1.GetType());
            Console.WriteLine(person2.Name);
            Console.WriteLine(person2.GetType());
            Console.WriteLine(person3.Name);
            Console.WriteLine(person3.GetType());
            Console.ReadLine();
        }
    }

The result would be:

I hope I was able to show you what Anonymous Types are in C#. Next up is Extension Methods.

Wednesday, January 23, 2008 7:58:09 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Fun Stuff | Tutorial
 Tuesday, January 22, 2008

Finally i'm back after a month of crazyness due to my webhost not performing up to its promise of 99.9% uptime.

Enough with the rant and on with the article, today i'm going to talk about how to list databases in a SQL Server by just using T-SQL and then showing you how to truncate the logs on those databases in different ways.

First, let's look at the 5 different approaches that you can use to list down databases in SQL Server by just using plain old T-SQL.

The stored procedure approach ( sp_databases, sp_helpdb ) :

 
USE master;

-- Lists databases that either reside in an instance of the SQL Server 
-- 2005 Database Engine or are accessible through a database gateway.
EXEC sp_databases

-- Reports information about a specified database or all databases.
EXEC sp_helpdb

The sys tables approach ( sys.databases, sys.sysdatabases ):

USE master;

-- [SQL Server 2000/2005] Contains one row for each database in an instance of 
-- Microsoft SQL Server 2005. When SQL Server is first installed, sysdatabases 
-- contains entries for the master, model, msdb, and tempdb databases. 
SELECT NAME FROM sysdatabases

-- [SQL Server 2005] Contains one row per database in the instance of Microsoft SQL Server. 
SELECT NAME FROM sys.sysdatabases

The using the undocumented stored procedure sp_MsForEachDatabase approach

USE master;

-- Undocumented SQL Server stored procedure
EXEC sp_msForEachDB 'PRINT ''?''';

Simple huh? Now that we know how to list databases let's go back to the problem of truncating all of them in one query (in fact it's just one line!). Some people would suggest writing cursors that would loop thru all the rows returned by our sysdatabases query to do this task. Their solution might be similar to the one listed below:

[SOLUTION 1]

USE master;

DECLARE 
    DBNames CURSOR
FOR
    SELECT 
        NAME 
    FROM sysdatabases

OPEN DBNames

DECLARE @Name varchar(50)

FETCH NEXT FROM DBNames
INTO @Name

WHILE (@@FETCH_STATUS <> -1)
BEGIN

    DBCC SHRINKDATABASE( @Name , 0)

    FETCH NEXT FROM DBNames
    INTO @Name

END

CLOSE DBNames
DEALLOCATE DBNames

Others would suggest a more primitive approach which is building a simple query first that would list the names of the database appended with the DBCC SHRINKDATABASE command:

[SOLUTION 2]

USE master;

SELECT 
    'DBCC SHRINKDATABASE(' + NAME  + ', 0)'
FROM sysdatabases

Then they would change the output option of the query into "Results to Text", copy the result to a new query window and execute the query from there. Pretty primitive. Alot of steps. Same results.

My suggested solution is using the sp_MSForEachDatabase procedure in conjunction with the DBCC SHRINKDATABASE function. This would result into a 1 line query. Less code with less steps to do that creates the same results.

[MY RECOMMENDED SOLUTION]

USE master;

-- truncates all the logs of all database in the server
EXEC sp_msForEachDB 'DBCC SHRINKDATABASE( ''?'', 0)'

Simple and straight to the point.

I hope you learned something from our article today. You can also do this programmatically by using C# and VB.NET. I wrote two articles about that topic here and here. Interested in truncating tables using sp_MsForEachTable? You can checkout this post.

Thanks!

 

Tuesday, January 22, 2008 7:58:26 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Fun Stuff | Rant | SQL
 Wednesday, December 26, 2007

I was working on a .NET application that integrates with Gravatar today because I needed a quickway to fetch someone's photo based on their email address. One requirement when doing this type of integration with Gravatar is that the email should be encrypted into an MD5 hash. Luckily, .NET already has a library that can do this for me by just calling a few methods:

[C# Version]

public static string ToMD5(string stringToConvert)
{
   //create an instance of the MD5CryptoServiceProvider
   MD5CryptoServiceProvider md5Provider = new MD5CryptoServiceProvider();

   //convert our string into byte array
   byte[] byteArray = Encoding.UTF8.GetBytes(stringToConvert);

   //get the hashed values created by our MD5CryptoServiceProvider
   byte[] hashedByteArray = md5Provider.ComputeHash(byteArray);

   //create a StringBuilder object
   StringBuilder stringBuilder = new StringBuilder();

   //loop to each each byte
   foreach (byte b in hashedByteArray)
   {
      //append it to our StringBuilder
      stringBuilder.Append(b.ToString("x2").ToLower());
   }

   //return the hashed value
   return stringBuilder.ToString();
}

[VB.NET Version]

Public Shared Function ToMD5(ByVal stringToConvert As String) As String 
   'create an instance of the MD5CryptoServiceProvider 
   Dim md5Provider As New MD5CryptoServiceProvider() 

   'convert our string into byte array 
   Dim byteArray As Byte() = Encoding.UTF8.GetBytes(stringToConvert) 

   'get the hashed values created by our MD5CryptoServiceProvider 
   Dim hashedByteArray As Byte() = md5Provider.ComputeHash(byteArray) 

   'create a StringBuilder object 
   Dim stringBuilder As New StringBuilder() 

   'loop to each each byte 
   For Each b As Byte In hashedByteArray 
      'append it to our StringBuilder 
      stringBuilder.Append(b.ToString("x2").ToLower()) 
   Next 

   'return the hashed value 
   Return stringBuilder.ToString()
End Function

Now all I need to do is get the result of my function and pass it to the avatar page in the Gravatar website and it should return me my Gravatar image.

[C# Version]

string gravatarUrl = "http://www.gravatar.com/avatar.php?gravatar_id";
string gravatarID = Utilities.Strings.ToMD5("keith.rull@gmail.com");
Image1.ImageUrl = String.Format("{0}={1}",gravatarUrl,gravatarID);

[VB.NET Version]

Dim gravatarUrl As String = "http://www.gravatar.com/avatar.php?gravatar_id"
Dim gravatarID As String = Utilities.Strings.ToMD5("keith.rull@gmail.com")
Image1.ImageUrl = [String].Format("{0}={1}", gravatarUrl, gravatarID)

http://www.gravatar.com/avatar.php?gravatar_id=d7ae6b890f16ad7541732e0f38adcbf2

Awesome!

Wednesday, December 26, 2007 7:26:04 PM (GMT Standard Time, UTC+00:00)  #    Comments [1] -
.NET | Fun Stuff
 Tuesday, December 11, 2007

I just saw this from my URL reffer list and it made me laugh.

Heheheh! How do you expect to get a result from this? Does the person expect to automatically get a list of all the people who attended the wedding?

Tuesday, December 11, 2007 8:31:25 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Fun Stuff
I wrote an article a few years ago using SQL SMO and just realized today that I can also list SQL Severs without importing an additional assembly to my project(Microsoft.SqlServer.Management.Smo) by using the SqlDataSourceEnumerator class. SqlDataSourceEnumerator is a class that provides a mechanism for enumerating all intances of SQL Server in a given network. SqlDataSourceEnumerator exposes a method called GetDataSources() that returns a DataTable containing the list of SQL Servers and some basic information about the server
Tuesday, December 11, 2007 7:39:31 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET | Fun Stuff | SQL
 Wednesday, November 28, 2007

Somebody sent me an email today asking me about an article I wrote a few years ago detailing how to generate random strings and numbers in C# and VB.NET. He asked me if I could add function to the code that creates a random character set to be used as a base for the allowed characters in the random string. I went on and hammered the solution and this what I built for him. I don't have enough time to explain the whole thing but I hope the code comments I added would be good enough to understand what I did with the code.

[----------------- C# Version -----------------]

using System;
using System.Collections.Generic;
using System.Text;

namespace KeithRull.ConsoleCentral
{
   class RandomStrings
   {
      //our default string size
      private const int CONST_MaxStringLenght = 10;

      //our default character string set
      private const string CONST_AllowedCharacterLiterals 
         = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";

      //our randomizer
      Random randomNumber = new Random();

      /// <summary>
      /// Generate a random string using the default options
      /// </summary>
      /// <returns>the random string</returns>
      public string GenerateRandomString()
      {
         return GenerateRandomString(CONST_MaxStringLenght);
      }

      /// <summary>
      /// Create a random string based on a specified lenght
      /// </summary>
      /// <param name="lenght">the lenght of the desired lenght of the random string</param>
      /// <returns>the randomized string</returns>
      public string GenerateRandomString(int lenght)
      {
         return GenerateRandomString(lenght, CreateRandomStringSet());
      }

      /// <summary>
      /// Creates a random string based on a specific lenght and character set
      /// </summary>
      /// <param name="lenght">the lenght of the desired lenght of the random string</param>
      /// <param name="charsToUse">character set to use</param>
      /// <param name="randomizeSourceSet">defines whether the source set should be scrambled</param>
      /// <returns>the random string</returns>
      public string GenerateRandomString(int lenght, string charsToUse, bool randomizeSourceSet)
      {
         string randomString = String.Empty;

         if (randomizeSourceSet) {
            //scramble and jumble it
            randomString = GenerateRandomString(lenght, CreateRandomStringSet(charsToUse));
         }
         else {
            //use the default charset
            randomString = GenerateRandomString(lenght, charsToUse);
         }

         return randomString;
      }

      /// <summary>
      /// Creates a random string based on a specific lenght and character set
      /// </summary>
      /// <param name="lenght">the lenght of the desired lenght of the random string</param>
      /// <param name="charsToUse">character set to use</param>
      /// <returns>the random string</returns>
      public string GenerateRandomString(int lenght, string charsToUse)
      {
         //Create a new StringBuilder that would hold the random string.
         StringBuilder randomString = new StringBuilder();

         //Create a variable to hold the generated charater.
         char appendedChar;

         //Create a loop that would iterate from 0 to the specified value of intLenghtOfString
         for (int i = 0; i <= lenght; ++i)
         {
            int characterIndex = Convert.ToInt32(randomNumber.Next(i, charsToUse.Length - i));
            //Generate the char and assign it to appendedChar
            appendedChar = charsToUse[characterIndex];
            //Append appendedChar to randomString
            randomString.Append(appendedChar);
         }
         //Convert randomString to String and return the result.
         return randomString.ToString();
      }

      /// <summary>
      /// Returns a random set of characters based on the default literal set
      /// </summary>
      /// <returns>the random string</returns>
      private string CreateRandomStringSet()
      {
         //just use the default character set
         return CreateRandomStringSet(CONST_AllowedCharacterLiterals);
      }

      /// <summary>
   &n