示例#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;
        }