Tag Archives: dictionary

Cinchoo – Collections, NestedDictionary, Part 1

ChoNestedDictionary

.NET provides standard Dictionary<> collection class that represents strongly typed collection of key, value pairs. But lacks to store and access another Dictionary<> object as an item. Cinchoo provides this feature through ChoNestedDictionary<> collection class, where you can store another Dictionary<> or ChoNestedDictionary<> object as an item along with other strongly typed key-value pairs. It provides endless nested opportunity to store items. It exposes most of the Dictionary<> object members.

How to use

1. Add reference to Cinchoo.Core.dll assembly

2. Namespace Cinchoo.Core.Collections.Generic

Sample code,

static void Main(string[] args)
{
    ChoNestedDictionary outerDict = new ChoNestedDictionary();

    outerDict.Add(1, "outerDict-Tom");
    outerDict.Add(2, "outerDict-Mark");

    ChoNestedDictionary innerDict1 = new ChoNestedDictionary();
    innerDict1.Add(11, "innerDict1-Raj");
    innerDict1.Add(12, "innerDict1-Paul");
    outerDict.Add(innerDict1);

    Dictionary innerDict2 = new Dictionary();
    innerDict2.Add(21, "innerDict2-Mick");
    innerDict2.Add(22, "innerDict2-Donald");
    outerDict.Add(innerDict2);

    outerDict.Add(3, "Daniel");
    outerDict.Add(4, "Pamila");

    foreach (KeyValuePair keyValuePair in outerDict)
        Console.WriteLine(String.Format("Key: {0}, Value: {1}", keyValuePair.Key, keyValuePair.Value));
}

When you run the above code, the output will be

Key: 1, Value: outerDict-Tom
Key: 2, Value: outerDict-Mark
Key: 11, Value: innerDict1-Raj
Key: 12, Value: innerDict1-Paul
Key: 21, Value: innerDict2-Mick
Key: 22, Value: innerDict2-Donald
Key: 3, Value: Daniel
Key: 4, Value: Pamila
Press any key to continue . . .
Advertisements

Cinchoo – Command Line Argument Parser, Part 11

Inside Command Line Argument Parser – Available Properties

In here I’ll list all the available properties in Cinchoo framework.

Properties can be specified with % delimiters as below

%NOW%

1. Add a reference to Cinchoo.Core.dll

2. Namespace: Cinchoo.Core.Shell

Cinchoo framework allows you to pass property as command line argument. At run time, the framework replaces with property value.

Global Properties

Below are the list of global properties available for use as command line arguments

  • %APPLICATION_NAME% – Application Name.
  • %PROCESS_ID% – Process Identifier.
  • %THREAD_ID% – Thread Identifier.
  • %THREAD_NAME% – Managed .NET Thread Name, if any.
  • %RANDOM_NO% – Random integer value.
  • %TODAY% – Current Date.
  • %NOW% – The current date and time on this computer, expressed as the local time.

Environment Properties

Below are the list of Environment properties available for use as command line arguments

  • %CURRENT_DIRECTORY% – The fully qualified path of the current directory; that is, the directory from which this process starts.
  • %MACHINE_NAME% – The NetBIOS name of this local computer
  • %OS_VERSION% – An OperatingSystem object that contains the current platform identifier and version number.
  • %PROCESSOR_COUNT% – The number of processors on the current machine.
  • %SYSTEM_DIRECTORY% – The fully qualified path of the system directory.
  • %SYSTEM_PAGE_SIZE% – The amount of memory for an operating system’s page file.
  • %TICK_COUNT% – The number of milliseconds elapsed since the system started.
  • %USER_DOMAIN_NAME% – The network domain name associated with the current user.
  • %USER_NAME% – The user name of the person who is currently logged on to the Windows operating system.
  • %VERSION% – A Version object that describes the major, minor, build, and revision numbers of the common language runtime.
  • %WORKING_SET% – The amount of physical memory mapped to the process context.

Please visit PropertyReplacer section for more information about Property re-placers.