Пример #1
0
        /// <summary>
        /// Applies a modification to an item in a table of modifications.
        /// If the item already exists in the table, merges in the modifications; if there is a conflict
        /// the mergeType indicates which should win.
        /// </summary>
        private void MergeModificationsIntoModificationTable(Dictionary <BuildItem, Dictionary <string, string> > modifiesOfType,
                                                             KeyValuePair <BuildItem, Dictionary <string, string> > modify,
                                                             ModifyMergeType mergeType)
        {
            Dictionary <string, string> existingMetadataChanges;

            if (modifiesOfType.TryGetValue(modify.Key, out existingMetadataChanges))
            {
                // There's already modifications for this item; merge with those
                foreach (KeyValuePair <string, string> metadataChange in modify.Value)
                {
                    if (mergeType == ModifyMergeType.SecondWins)
                    {
                        existingMetadataChanges[metadataChange.Key] = metadataChange.Value;
                    }
                    else
                    {
                        // Any existing value wins
                        if (!existingMetadataChanges.ContainsKey(metadataChange.Key))
                        {
                            existingMetadataChanges[metadataChange.Key] = metadataChange.Value;
                        }
                    }
                }
            }
            else
            {
                modifiesOfType.Add(modify.Key, modify.Value);
            }
        }
Пример #2
0
 /// <summary>
 /// Applies a modification to an item in a table of modifications.
 /// If the item already exists in the table, merges in the modifications; if there is a conflict
 /// the mergeType indicates which should win.
 /// </summary>
 private void MergeModificationsIntoModificationTable(Dictionary<BuildItem, Dictionary<string, string>> modifiesOfType,
                                                      KeyValuePair<BuildItem, Dictionary<string, string>> modify,
                                                      ModifyMergeType mergeType)
 {
     Dictionary<string, string> existingMetadataChanges;
     if (modifiesOfType.TryGetValue(modify.Key, out existingMetadataChanges))
     {
         // There's already modifications for this item; merge with those
         foreach (KeyValuePair<string, string> metadataChange in modify.Value)
         {
             if (mergeType == ModifyMergeType.SecondWins)
             {
                 existingMetadataChanges[metadataChange.Key] = metadataChange.Value;
             }
             else
             {
                 // Any existing value wins
                 if (!existingMetadataChanges.ContainsKey(metadataChange.Key))
                 {
                     existingMetadataChanges[metadataChange.Key] = metadataChange.Value;
                 }
             }
         }
     }
     else
     {
         modifiesOfType.Add(modify.Key, modify.Value);
     }
 }