Exemplo n.º 1
0
        private void BtnOk_Click(object sender, RoutedEventArgs e)
        {
            //Member
            var member = (MemberReference)this.SelectedMember;

            //Checks if the selected member has some generic parameters
            var generic = member as IGenericParameterProvider;

            if (generic != null && generic.HasGenericParameters)
            {
                var genericWindow = new GenericResolutionWindow(generic, _enclosingType);
                if (genericWindow.ShowDialog().GetValueOrDefault(false))
                {
                    this.SelectedMember = (MemberReference)genericWindow.ResolvedGeneric;
                }
                else
                {
                    return;
                }
            }

            //Computes the key for the selected member
            var key = ICSharpCode.ILSpy.XmlDoc.XmlDocKeyProvider.GetKey(member);

            //Removes it (if present) fro the recent list
            var recentNode = _recentMembersNode.Elements().FirstOrDefault(x => x.Attribute("Key").Value == key);

            if (recentNode != null)
            {
                recentNode.Remove();
            }

            //Creates a new node and adds it to the list
            recentNode =
                new XElement("Member",
                             new XAttribute("Assembly", member.Module.Assembly.FullName),
                             new XAttribute("Module", member.Module.Name),
                             new XAttribute("Key", key)
                             );
            _recentMembersNode.AddFirst(recentNode);

            //Checks if the list has excedeed the maximum allowed size
            if (_recentMembersNode.Elements().Count() > maxRecentMembersCount)
            {
                _recentMembersNode.Elements().Last().Remove();
            }

            //Saves the settings
            GlobalContainer.SettingsManager.Instance.Save();

            //Returns to the caller
            this.DialogResult = true;
            this.Close();
        }
Exemplo n.º 2
0
        private void BtnOk_Click(object sender, RoutedEventArgs e)
        {
            //Member
            var member = (MemberReference)this.SelectedMember;

            //Checks if the selected member has some generic parameters
            var generic = member as IGenericParameterProvider;
            if (generic != null && generic.HasGenericParameters)
            {
                var genericWindow = new GenericResolutionWindow(generic, _enclosingType);
                if (genericWindow.ShowDialog().GetValueOrDefault(false))
                {
                    this.SelectedMember = (MemberReference)genericWindow.ResolvedGeneric;
                }
                else
                {
                    return;
                }
            }

            //Computes the key for the selected member
            var key = ICSharpCode.ILSpy.XmlDoc.XmlDocKeyProvider.GetKey(member);

            //Removes it (if present) fro the recent list
            var recentNode = _recentMembersNode.Elements().FirstOrDefault(x => x.Attribute("Key").Value == key);
            if (recentNode != null)
                recentNode.Remove();

            //Creates a new node and adds it to the list
            recentNode =
                new XElement("Member",
                    new XAttribute("Assembly", member.Module.Assembly.FullName),
                    new XAttribute("Module", member.Module.Name),
                    new XAttribute("Key", key)
                );
            _recentMembersNode.AddFirst(recentNode);

            //Checks if the list has excedeed the maximum allowed size
            if (_recentMembersNode.Elements().Count() > maxRecentMembersCount)
                _recentMembersNode.Elements().Last().Remove();

            //Saves the settings
            GlobalContainer.SettingsManager.Instance.Save();

            //Returns to the caller
            this.DialogResult = true;
            this.Close();
        }