Esempio n. 1
0
 private void RefreshProfileListCallback()
 {
     ProfileListView.SuspendLayout();
     ProfileListView.Clear();
     string[] profiles = Directory.GetFiles(ProfessionbuddyBot.ProfilePath, "*.xml", SearchOption.TopDirectoryOnly).
                         Select(Path.GetFileName).Union(
         Directory.GetFiles(
             ProfessionbuddyBot.ProfilePath,
             "*.package",
             SearchOption.TopDirectoryOnly)).
                         Select(Path.GetFileName).ToArray();
     // remove all profile names from ListView that are not in the 'profile' array
     for (int i = 0; i < ProfileListView.Items.Count; i++)
     {
         if (!profiles.Contains(ProfileListView.Items[i].Name))
         {
             ProfileListView.Items.RemoveAt(i);
         }
     }             // Add all profiles that are not in ListView
     foreach (string profile in profiles)
     {
         if (!ProfileListView.Items.ContainsKey(profile))
         {
             ProfileListView.Items.Add(profile, profile, null);
         }
     }
     ProfileListView.ResumeLayout();
 }
        private void GetRequiremetProfile(ProfileListView listView, int index, ref int count, ref List <Profile> profile)
        {
            if (index == count)
            {
                profile = JsonSerializer.Deserialize <List <Profile> >(listView.Profile);
            }

            foreach (var requirement in listView.Requirements)
            {
                if (!string.IsNullOrEmpty(requirement.Profile))
                {
                    ++count;
                }
                GetRequiremetProfile(requirement, index, ref count, ref profile);
            }
        }
        public ProfileConverter(ProfileListView profileListView, string index)
        {
            var profile = JsonSerializer.Deserialize <List <Profile> >(profileListView.Profile);

            this.repository      = new ProfileRepository(profile);
            this.profileListView = profileListView;
            if (Int32.TryParse(index.Replace("I", ""), out this.index.Item1))
            {
                this.index.Item2 = index;
                if (this.index.Item1 >= 1 && this.index.Item1 <= 8)
                {
                    connector = new BaseConnectorProfile();
                }
                else
                {
                    connector = new ConnectorProfile();
                }
            }
        }