Smrf.NodeXL.ExcelTemplate.ColumnGroupManager.GetOtherColumnNames C# (CSharp) Method

GetOtherColumnNames() private static method

private static GetOtherColumnNames ( Microsoft oWorkbook, ColumnGroups eOtherColumnGroup ) : String[]
oWorkbook Microsoft
eOtherColumnGroup ColumnGroups
return String[]
    GetOtherColumnNames
    (
        Microsoft.Office.Interop.Excel.Workbook oWorkbook,
        ColumnGroups eOtherColumnGroup
    )
    {
        Debug.Assert(oWorkbook != null);

        List<String> oOtherColumnNames = new List<String>();
        ListObject oTable;

        if ( TryGetColumnGroupTable(oWorkbook, eOtherColumnGroup, out oTable) )
        {
            // Create a HashSet of the column names that are included in all
            // the non-other column groups in the table.

            HashSet<String> oColumnNamesInNonOtherGroups =
                new HashSet<String>();

            // All column groups in the edge table start with "Edge", all
            // column groups in the vertex table start with "Vertex", and all
            // column groups in the group table start with "Group".

            String sStartsWith = null;

            switch (eOtherColumnGroup)
            {
                case ColumnGroups.EdgeOtherColumns:

                    sStartsWith = "Edge";
                    break;

                case ColumnGroups.VertexOtherColumns:

                    sStartsWith = "Vertex";
                    break;

                case ColumnGroups.GroupOtherColumns:

                    sStartsWith = "Group";
                    break;

                default:

                    Debug.Assert(false);
                    break;
            }

            foreach ( ColumnGroups eColumnGroup in
                Enum.GetValues(typeof(ColumnGroups) ) )
            {
                if (
                    eColumnGroup != eOtherColumnGroup
                    &&
                    eColumnGroup.ToString().StartsWith(sStartsWith)
                    )
                {
                    foreach ( String sColumnNameInNonOtherGroup in 
                        GetColumnNames(oWorkbook, eColumnGroup) )
                    {
                        oColumnNamesInNonOtherGroups.Add(
                            sColumnNameInNonOtherGroup);
                    }
                }
            }

            // Any column not included in one of the non-other column groups is
            // an "other" column.

            foreach (ListColumn oColumn in oTable.ListColumns)
            {
                String sColumnName = oColumn.Name;

                if ( !oColumnNamesInNonOtherGroups.Contains(sColumnName) )
                {
                    oOtherColumnNames.Add(sColumnName);
                }
            }
        }
        
        return ( oOtherColumnNames.ToArray() );
    }
}