public XmlStorageSection(StorageManagerImplementation manager, StorageEntry entry, string key, ulong additionalNumericKey, StorageSectionOpenFlag openFlags) : base(manager, entry, key, additionalNumericKey, KeyPrefix, openFlags) { if ((openFlags & StorageSectionOpenFlag.ClearOnOpen) == 0) { using (var s = manager.FileSystem.OpenFile(Path, true)) { try { if (s != null) { data = XDocument.Load(s); } } catch (XmlException) { data = null; } } } if (data == null) { data = new XDocument(); } }
public BinaryStorageSection(StorageManagerImplementation manager, StorageEntry entry, string key, ulong additionalNumericKey, StorageSectionOpenFlag openFlags) : base(manager, entry, key, additionalNumericKey, KeyPrefix, openFlags) { if ((openFlags & StorageSectionOpenFlag.ClearOnOpen) == 0) { using (var s = manager.FileSystem.OpenFile(Path, true)) if (s != null) { s.CopyTo(data); data.Position = 0; } } }
public StorageSectionBase(StorageManagerImplementation manager, StorageEntry entry, string key, ulong additionalNumericKey, string pathPrefix, StorageSectionOpenFlag openFlags) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentException("Wrong key"); } this.manager = manager; this.entry = entry; this.key = key; this.path = entry.Path + System.IO.Path.DirectorySeparatorChar + StorageManagerImplementation.NormalizeKey(key, additionalNumericKey, pathPrefix); this.openFlags = openFlags; this.commitOnDispose = (openFlags & StorageSectionOpenFlag.AccessMask) == StorageSectionOpenFlag.ReadWrite; }
public SaxXmlStorageSection(StorageManagerImplementation manager, StorageEntry entry, string key, ulong additionalNumericKey, StorageSectionOpenFlag openFlags) : base(manager, entry, key, additionalNumericKey, XmlStorageSection.KeyPrefix, openFlags) { if ((openFlags & StorageSectionOpenFlag.ReadWrite) == 0) { throw new NotSupportedException("Sax xml section can be open for writing"); } if ((openFlags & StorageSectionOpenFlag.ClearOnOpen) == 0) { fileSystemStream = manager.FileSystem.OpenFile(Path, true); if (fileSystemStream != null) { reader = XmlReader.Create(fileSystemStream); streamLen = fileSystemStream.Length != 0 ? fileSystemStream.Length : new double?(); } } }
private IStorageEntry GetEntryById(string id) { StorageEntry entry; lock (sync) { if (!entriesCache.TryGetValue(id, out entry)) { trace.Info("Entry with key {0} does not exist in the cache. Creating.", id); entry = new StorageEntry(this, id); entriesCache.Add(id, entry); } entry.EnsureCreated(); entry.ReadCleanupInfo(); entry.WriteCleanupInfoIfCleanupAllowed(); } return(entry); }