@@ -24,6 +24,7 @@ public class ConfigurationReader
2424 /// <exception cref="Exception">Thrown when the configuration file cannot be loaded.</exception>
2525 private static void LoadConfig ( )
2626 {
27+ // Lazy loading pattern - only load once
2728 if ( _xmlDoc == null )
2829 {
2930 try
@@ -52,17 +53,19 @@ public static Dictionary<string, ColumnMapping> GetSelectedColumns(string listNa
5253
5354 try
5455 {
55- // Primeiro verifica configurações específicas da lista
56+ // List-specific configurations take precedence over global settings
5657 if ( ! string . IsNullOrEmpty ( listName ) )
5758 {
5859 var listConfigs = GetListConfigurations ( ) ;
5960 if ( listConfigs != null && listConfigs . TryGetValue ( listName , out var listConfig ) )
6061 {
62+ // Skip ignored lists entirely
6163 if ( listConfig . Ignore )
6264 {
6365 Console . WriteLine ( $ "List { listName } is configured to be ignored.") ;
6466 return null ;
6567 }
68+ // Use list-specific column configuration if available
6669 if ( listConfig . Columns != null )
6770 {
6871 Console . WriteLine ( $ "Using specific configuration for list: { listName } ") ;
@@ -71,15 +74,17 @@ public static Dictionary<string, ColumnMapping> GetSelectedColumns(string listNa
7174 }
7275 }
7376
74- // Se não encontrar configuração específica, usa as configurações globais
77+ // Fall back to global column configuration
7578 var columnNodes = _xmlDoc . SelectNodes ( "//Configuration/ReplicationConfiguration/SelectColumns/column" ) ;
7679
80+ // No specific columns configured = include all columns
7781 if ( columnNodes == null || columnNodes . Count == 0 )
7882 {
7983 Console . WriteLine ( "No specific columns configured. All columns will be included." ) ;
8084 return null ;
8185 }
8286
87+ // Build case-insensitive column mappings dictionary
8388 var columnMappings = new Dictionary < string , ColumnMapping > ( StringComparer . OrdinalIgnoreCase ) ;
8489
8590 foreach ( XmlNode node in columnNodes )
@@ -93,7 +98,7 @@ public static Dictionary<string, ColumnMapping> GetSelectedColumns(string listNa
9398 var mapping = new ColumnMapping
9499 {
95100 Source = sourceAttr . Value ,
96- Destination = destAttr ? . Value ?? sourceAttr . Value ,
101+ Destination = destAttr ? . Value ?? sourceAttr . Value , // Default to source name if no destination
97102 Ignore = ignoreAttr != null && bool . Parse ( ignoreAttr . Value )
98103 } ;
99104
@@ -257,6 +262,7 @@ public static IEnumerable<SharePointListConfig> GetSharePointListConfigurations(
257262 Disabled = GetNodeValueBool ( listNode , "Disabled" , false )
258263 } ;
259264
265+ // Only add valid configurations
260266 if ( IsValidListConfig ( config ) )
261267 {
262268 configurations . Add ( config ) ;
@@ -298,6 +304,7 @@ private static bool GetNodeValueBool(XmlNode parentNode, string nodeName, bool d
298304 /// </summary>
299305 private static bool IsValidListConfig ( SharePointListConfig config )
300306 {
307+ // All three fields are required for proper replication
301308 if ( string . IsNullOrEmpty ( config . SiteUrl ) )
302309 {
303310 Console . WriteLine ( "Invalid configuration: SiteUrl is required." ) ;
@@ -329,6 +336,7 @@ public static Dictionary<string, ListConfiguration> GetListConfigurations()
329336 if ( listNodes == null || listNodes . Count == 0 )
330337 return null ;
331338
339+ // Case-insensitive dictionary for list name lookups
332340 var listConfigs = new Dictionary < string , ListConfiguration > ( StringComparer . OrdinalIgnoreCase ) ;
333341
334342 foreach ( XmlNode listNode in listNodes )
@@ -344,7 +352,7 @@ public static Dictionary<string, ListConfiguration> GetListConfigurations()
344352 Name = nameAttr . Value ,
345353 Context = contextAttr ? . Value ,
346354 Ignore = ignoreAttr != null && bool . Parse ( ignoreAttr . Value ) ,
347- Columns = GetListColumns ( listNode )
355+ Columns = GetListColumns ( listNode ) // Get list-specific column mappings
348356 } ;
349357
350358 listConfigs [ listConfig . Name ] = listConfig ;
@@ -362,6 +370,7 @@ public static Dictionary<string, ListConfiguration> GetListConfigurations()
362370
363371 private static Dictionary < string , ColumnMapping > GetListColumns ( XmlNode listNode )
364372 {
373+ // Use relative XPath to find columns within this specific list
365374 var columnNodes = listNode . SelectNodes ( ".//Columns/column" ) ;
366375 if ( columnNodes == null || columnNodes . Count == 0 )
367376 return null ;
@@ -379,7 +388,7 @@ private static Dictionary<string, ColumnMapping> GetListColumns(XmlNode listNode
379388 var mapping = new ColumnMapping
380389 {
381390 Source = sourceAttr . Value ,
382- Destination = destAttr ? . Value ?? sourceAttr . Value ,
391+ Destination = destAttr ? . Value ?? sourceAttr . Value , // Default to source if no destination specified
383392 Ignore = ignoreAttr != null && bool . Parse ( ignoreAttr . Value )
384393 } ;
385394
@@ -403,13 +412,15 @@ public class SharePointListConfig
403412 public bool Disabled { get ; set ; }
404413 }
405414
415+ // Represents mapping between source and destination columns with ignore capability
406416 public class ColumnMapping
407417 {
408418 public string Source { get ; set ; }
409419 public string Destination { get ; set ; }
410420 public bool Ignore { get ; set ; }
411421 }
412422
423+ // List-specific configuration that can override global settings
413424 public class ListConfiguration
414425 {
415426 public string Name { get ; set ; }
0 commit comments