Пример #1
0
        /// <summary>
        /// Met à jour l'entrée correspondante
        /// </summary>
        /// <param name="editedEntry">Entrée modifiée</param>
        /// <returns>entry after update. Contents may be modified for compatibility reasons</returns>
        public Entry UpdateEntry(Entry editedEntry)
        {
            Entry newEntry = new Entry();

            // Parcours des entrées
            for (int i = 0; i < _Entries.Count; i++)
            {
                newEntry = _Entries[i];

                if (newEntry.index == editedEntry.index)
                {
                    ResourceIdentifier oldId = newEntry.id;

                    // Process value to replace forbidden characters
                    Couple <char> couple1 = new Couple <char>(DB._CHAR_START_TEXT, '(');
                    Couple <char> couple2 = new Couple <char>(DB._CHAR_END_TEXT, ')');

                    newEntry.id = editedEntry.id.Clone() as ResourceIdentifier;

                    if (newEntry.id != null)
                    {
                        newEntry.value = String2.ReplaceChars(editedEntry.value, couple1, couple2);
                        _Entries[i]    = newEntry;

                        // Accelerator update !
                        entriesById.Remove(oldId);
                        entriesById.Add(newEntry.id, newEntry);
                    }

                    break;
                }
            }

            return(newEntry);
        }