コード例 #1
0
        private static Profile BuildProfile(string name)
        {
            var _reg = new RegistryEditor(false);

              _reg.ProfileName = name; //todo this is bad, make this thread-safe
              return new Profile
              {
            Directory = _reg.Read(Directory),
            Name = _reg.Read(Name),
            Order = _reg.ReadInt(Order) ?? 0,
              };
        }
コード例 #2
0
        public static void Save(IList<Profile> profiles)
        {
            var reg = new RegistryEditor(false);
              reg.DeleteSubKeyTree();

              var order = 0;

              foreach (var profile in profiles)
              {
            reg.ProfileName = profile.Name;  //todo this is bad, make this thread-safe
            reg.Write(Name, profile.Name);
            reg.Write(Directory, profile.Directory);
            reg.Write(Order, order++);
              }
        }
コード例 #3
0
        public static IList<Profile> Load()
        {
            var profiles = new List<Profile>();

              var reg = new RegistryEditor(false);
              try
              {
            foreach (var name in reg.ReadKeys())
            {
              profiles.Add(BuildProfile(name));
            }
              }
              catch (Exception)
              {
            return new List<Profile>();
              }

              return profiles.OrderBy(x => x.Order).ToList();
        }