private IEnumerable <XElement> GetAllElementsCore(DataProtection entity) { // Note: Inability to read any value is considered a fatal error (since the file may contain // revocation information), and we'll fail the entire operation rather than return a partial // set of elements. If a value contains well-formed XML but its contents are meaningless, we // won't fail that operation here. The caller is responsible for failing as appropriate given // that scenario. foreach (var value in entity.Elements) { yield return(XElement.Parse(value)); } }
/// <inheritdoc /> public void StoreElement(XElement element, string friendlyName) { using (var session = _store.OpenSession()) { session.Advanced.UseOptimisticConcurrency = true; var dataProtection = session.Load <DataProtection>(_key); if (dataProtection == null) { dataProtection = new DataProtection() { Id = _key }; session.Store(dataProtection); } dataProtection.Elements.Add(element.ToString(SaveOptions.DisableFormatting)); session.SaveChanges(); } }