public void Add(StoredString storedString) { if (!this._isInit) { throw new NotInitializedException(typeof(DefaultLocalizationSet)); } if (string.IsNullOrEmpty(storedString.Id)) { throw new NullReferenceException(nameof(StoredString.Id)); } if (storedString.Strings == null) { throw new NullReferenceException($"LocalizableString with ID:'{storedString.Id}' is not contain DefaultStrings."); } if (this._ids.Contains(storedString.Id)) { this.Strings.First(s => s.Id == storedString.Id).Strings = storedString.Strings; return; } this.Strings.Add(storedString); this._ids.Add(storedString.Id); }
public void DeleteItem(string item) { using (var db = _storageContextFactory()) { var i = new StoredString() { stringToStore = item }; db.Remove(i); db.SaveChanges(); } }
public void AddItem(string item) { using (var db = _storageContextFactory()) { var i = new StoredString() { stringToStore = item }; try { db.Add(i); db.SaveChanges(); } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { // swallow this exception, this seems like the recommended way to do this so we don't get race conditions between checking an item exists and writing it... Console.WriteLine($"{item} already exists in DB."); } } }
private void ProcessUnit(List <string> unit, ref Translation translation) { var storedString = new StoredString { Id = unit[0].Substring(3) }; if (unit.Count > 2) { storedString.Strings = new string[this._pluralsCount]; for (int i = 0; i < this._pluralsCount; i++) { storedString.Strings[i] = unit[i + 1].Substring(10); } } else { storedString.Strings = new string[1]; storedString.Strings[0] = unit[1].Substring(6); } translation.Strings.Add(storedString); }
public void RemoveInlineString(StoredString inlineString) { InlineStringEditor editor = this._inlineStringEditorsPool.First(e => e.InlineString.Equals(inlineString)); editor.InlineString = null; }