Esempio n. 1
0
        public Stream OpenWrite(Type configType, ConfigurationOptionsAttribute options)
        {
            ObservableMemoryStream stream = new ObservableMemoryStream(configType);
            stream.Disposed += WriteStream_Disposed;

            return stream;
        }
Esempio n. 2
0
        public override Stream OpenWrite(Type configType, ConfigurationOptionsAttribute options)
        {
            if (Store == null)
                throw new InvalidOperationException();

            return new IsolatedStorageFileStream(GetFileName(configType, options), FileMode.Create, Store);
        }
Esempio n. 3
0
        public override void Delete(Type configType, ConfigurationOptionsAttribute options)
        {
            string path = GetPath(configType, options);

            if (File.Exists(path))
                File.Delete(path);
        }
Esempio n. 4
0
        public Stream OpenRead(Type configType, ConfigurationOptionsAttribute options)
        {
            if (!Exists(configType, options))
                throw new FileNotFoundException();

            return new MemoryStream(Storage[configType]);
        }
Esempio n. 5
0
        public override void Delete(Type configType, ConfigurationOptionsAttribute options)
        {
            if (!Exists(configType, options))
                return;

            string path = GetFileName(configType, options);
            Store.DeleteFile(path);
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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";
        }
Esempio n. 8
0
 public override bool Exists(Type configType, ConfigurationOptionsAttribute options)
 {
     return Store.GetFileNames(GetFileName(configType, options)).Length != 0;
 }
Esempio n. 9
0
 public abstract void Delete(Type configType, ConfigurationOptionsAttribute options);
Esempio n. 10
0
 public abstract bool Exists(Type configType, ConfigurationOptionsAttribute options);
Esempio n. 11
0
 public abstract Stream OpenWrite(Type configType, ConfigurationOptionsAttribute options);
Esempio n. 12
0
 public void Delete(Type configType, ConfigurationOptionsAttribute options)
 {
     Storage.Remove(configType);
 }
Esempio n. 13
0
 public bool Exists(Type configType, ConfigurationOptionsAttribute options)
 {
     return Storage.ContainsKey(configType);
 }
Esempio n. 14
0
 public override bool Exists(Type configType, ConfigurationOptionsAttribute options)
 {
     return File.Exists(GetPath(configType, options));
 }
Esempio n. 15
0
 public override Stream OpenWrite(Type configType, ConfigurationOptionsAttribute options)
 {
     return File.OpenWrite(GetPath(configType, options));
 }