Beispiel #1
0
        public static TypeMemberLink ConvertTypeMemberLink(Models.Type t, Member m)
        {
            if (m == null)
            {
                return(null);
            }
            var             monikers        = m.Monikers;
            VersionedString inheritanceInfo = null;

            if (t?.InheritedMembers != null &&
                t.InheritedMembers.TryGetValue(m.Uid, out inheritanceInfo) &&
                inheritanceInfo.Monikers != null)
            {
                monikers = inheritanceInfo.Monikers;
            }
            if (monikers.Any())
            {
                return(new TypeMemberLink()
                {
                    Uid = m.Uid,
                    InheritedFrom = inheritanceInfo != null ? m.Parent.Uid : null,
                    Monikers = monikers
                });
            }
            return(null);
        }
Beispiel #2
0
        public TypeMemberLink ExtensionMethodToTypeMemberLink(Models.Type t, VersionedString vs)
        {
            HashSet <string> monikers = vs.Monikers;

            if (_store.MembersByUid.TryGetValue(vs.Value, out var m))
            {
                if (monikers == null)
                {
                    monikers = m.Monikers;
                }
                else
                {
                    monikers = monikers.Intersect(m.Monikers).ToHashSet();
                }
            }
            if (monikers != null)
            {
                if (monikers.Count > t.Monikers.Count)
                {
                    monikers = monikers.Intersect(t.Monikers).ToHashSet();
                }
                //don't move same monikers for now, for less diff
                //if (monikers.SetEquals(t.Monikers))
                //{
                //    monikers = null;
                //}
            }
            if (monikers != null && monikers.Count == 0)
            {
                return(null);
            }
            return(new TypeMemberLink()
            {
                Uid = vs.Value,
                Monikers = monikers
            });
        }