public Stream OpenWrite(Type configType, ConfigurationOptionsAttribute options) { ObservableMemoryStream stream = new ObservableMemoryStream(configType); stream.Disposed += WriteStream_Disposed; return stream; }
public override Stream OpenWrite(Type configType, ConfigurationOptionsAttribute options) { if (Store == null) throw new InvalidOperationException(); return new IsolatedStorageFileStream(GetFileName(configType, options), FileMode.Create, Store); }
public override void Delete(Type configType, ConfigurationOptionsAttribute options) { string path = GetPath(configType, options); if (File.Exists(path)) File.Delete(path); }
public Stream OpenRead(Type configType, ConfigurationOptionsAttribute options) { if (!Exists(configType, options)) throw new FileNotFoundException(); return new MemoryStream(Storage[configType]); }
public override void Delete(Type configType, ConfigurationOptionsAttribute options) { if (!Exists(configType, options)) return; string path = GetFileName(configType, options); Store.DeleteFile(path); }
private string GetPath(Type configType, ConfigurationOptionsAttribute options) { string configDirectory = Path.Combine(MirandaEnvironment.MirandaFolderPath, "Configuration"); if (!Directory.Exists(configDirectory)) Directory.CreateDirectory(configDirectory); return Path.Combine(configDirectory, GetFileName(configType, options)); }
protected virtual string GetFileName(Type configType, ConfigurationOptionsAttribute options) { if (configType == null) throw new ArgumentNullException("configType"); if (options == null) throw new ArgumentNullException("options"); string versionSuffix = (options.Version != null ? options.Version.ToString() : String.Empty); string profileBoundSuffix = String.Empty; if (options.ProfileBound) { if (!MirandaContext.Initialized) throw new InvalidOperationException(); profileBoundSuffix = Path.GetFileNameWithoutExtension(MirandaContext.Current.MirandaDatabase.ProfileName); } if (!String.IsNullOrEmpty(options.StaticFileName)) return options.StaticFileName; return String.Format("{0}_{1}_{2}", configType.FullName, versionSuffix, profileBoundSuffix).Replace('.', '-') + ".dat"; }
public override bool Exists(Type configType, ConfigurationOptionsAttribute options) { return Store.GetFileNames(GetFileName(configType, options)).Length != 0; }
public abstract void Delete(Type configType, ConfigurationOptionsAttribute options);
public abstract bool Exists(Type configType, ConfigurationOptionsAttribute options);
public abstract Stream OpenWrite(Type configType, ConfigurationOptionsAttribute options);
public void Delete(Type configType, ConfigurationOptionsAttribute options) { Storage.Remove(configType); }
public bool Exists(Type configType, ConfigurationOptionsAttribute options) { return Storage.ContainsKey(configType); }
public override bool Exists(Type configType, ConfigurationOptionsAttribute options) { return File.Exists(GetPath(configType, options)); }
public override Stream OpenWrite(Type configType, ConfigurationOptionsAttribute options) { return File.OpenWrite(GetPath(configType, options)); }