コード例 #1
0
            public ObservableCollection <ContextActionViewModel> BuildTreeViewModel(IEnumerable <ITreeNode <ITypeDefinition> > classTree)
            {
                ObservableCollection <ContextActionViewModel> c = new ObservableCollection <ContextActionViewModel>();

                foreach (var node in classTree)
                {
                    var childNodes = BuildTreeViewModel(node.Children);

                    // the derived class might be in a different compilation:
                    IMember importedMember = node.Content.Compilation.Import(member);
                    IMember derivedMember  = importedMember != null?InheritanceHelper.GetDerivedMember(importedMember, node.Content) : null;

                    if (derivedMember != null)
                    {
                        c.Add(GoToEntityAction.MakeViewModel(derivedMember, childNodes));
                    }
                    else
                    {
                        // If the member doesn't exist in the derived class, directly append the
                        // children of that derived class here.
                        c.AddRange(childNodes);
                        // This is necessary so that the method C.M() is shown in the case
                        // "class A { virtual void M(); } class B : A {} class C : B { override void M(); }"
                    }
                }
                return(c);
            }
コード例 #2
0
        static ObservableCollection <ContextActionViewModel> BuildBaseMemberListViewModel(IMember member)
        {
            var c = new ObservableCollection <ContextActionViewModel>();
            ObservableCollection <ContextActionViewModel> lastBase = c;

            IMember thisMember = member;

            while (thisMember != null)
            {
                IMember baseMember = InheritanceHelper.GetBaseMembers(thisMember, true).FirstOrDefault();
                if (baseMember != null)
                {
                    // Only allow this base member, if overriding a virtual/abstract member of a class
                    // or implementing a member of an interface.
                    if ((baseMember.DeclaringTypeDefinition.Kind == TypeKind.Interface) || (baseMember.IsOverridable && thisMember.IsOverride))
                    {
                        var newChild = new ObservableCollection <ContextActionViewModel>();
                        lastBase.Add(GoToEntityAction.MakeViewModel(baseMember, newChild));
                        lastBase = newChild;
                    }
                    else
                    {
                        thisMember = null;
                    }
                }
                thisMember = baseMember;
            }

            return(c);
        }
コード例 #3
0
 static ObservableCollection <ContextActionViewModel> BuildTreeViewModel(IEnumerable <ITreeNode <ITypeDefinition> > classTree)
 {
     return(new ObservableCollection <ContextActionViewModel>(
                classTree.Select(
                    node => GoToEntityAction.MakeViewModel(node.Content, BuildTreeViewModel(node.Children)))));
 }
コード例 #4
0
 static ObservableCollection <ContextActionViewModel> BuildListViewModel(IEnumerable <ITypeDefinition> classList)
 {
     return(new ObservableCollection <ContextActionViewModel>(
                classList.Select(@class => GoToEntityAction.MakeViewModel(@class, null))));
 }