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

            return stream;
        }
示例#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);
        }
示例#3
0
        public override void Delete(Type configType, ConfigurationOptionsAttribute options)
        {
            string path = GetPath(configType, options);

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

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

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