Пример #1
0
        /// <summary>
        /// Totally removes user profile
        /// </summary>
        public void RemoveProfile(Profile profile)
        {
            string path = Path.GetDirectoryName(CreatePath(profile));

            if (Directory.Exists(path))
                Directory.Delete(path, true);
        }
Пример #2
0
 private Profile CreateFakeProfile(string name)
 {
     Profile profile = new Profile
                           {
                               Name = name,
                               ConnectionConfig = new ConnectionConfig
                                                      {
                                                          Server = "jabber.uruchie.org",
                                                          User = name,
                                                          Password = name,
                                                          Port = 5222
                                                      }
                           };
     return profile;
 }
Пример #3
0
        /// <summary>
        /// Save new or changed profile to the specific folder
        /// </summary>
        public void SaveProfile(Profile profile)
        {
            string path = CreatePath(profile);
            string directory = Path.GetDirectoryName(path);

            if (!Directory.Exists(directory))
                Directory.CreateDirectory(directory);

            if (File.Exists(path))
                File.Delete(path);

            using (FileStream stream = File.Create(path))
                xmlSerializer.Serialize(stream, profile);
        }
Пример #4
0
        private string CreatePath(Profile profile)
        {
            if (Path.GetInvalidFileNameChars().Any(i => profile.Name.Contains(i)))
                throw new ArgumentException("Profile name contains invalid symbol(s)");

            string path = Path.Combine(profilesFolder, profile.Name, profile.Name + ProfileExtensions);
            return path;
        }