Пример #1
0
        public MemberSDPModel FormatSingleMember(Member m)
        {
            var sdpMember = InitWithBasicProperties <MemberSDPModel>(m);

            sdpMember.TypeParameters        = ConvertTypeParameters(m);
            sdpMember.ThreadSafety          = ConvertThreadSafety(m);
            sdpMember.ImplementsWithMoniker = m.Implements?.Select(impl => new VersionedString(impl.Monikers, DocIdToTypeMDString(impl.Value, _store)))
                                              .Where(impl => impl.Value != null)
                                              .ToList().NullIfEmpty();
            sdpMember.ImplementsMonikers = ConverterHelper.ConsolidateVersionedValues(sdpMember.ImplementsWithMoniker, m.Monikers);

            var knowTypeParams = m.Parent.TypeParameters.ConcatList(m.TypeParameters);

            if (m.ReturnValueType != null)
            {
                var returns = m.ReturnValueType;
                var r       = returns.VersionedTypes
                              .Where(v => !string.IsNullOrWhiteSpace(v.Value) && v.Value != "System.Void").ToArray();
                if (r.Any())
                {
                    foreach (var t in returns.VersionedTypes)
                    {
                        t.Value = SDPYamlConverter.TypeStringToTypeMDString(t.Value, _store);
                    }
                    var returnType = new ReturnValue
                    {
                        VersionedTypes = r,
                        Description    = returns.Description
                    };
                    sdpMember.ReturnsWithMoniker = returnType;
                }
            }

            sdpMember.Parameters = m.Parameters?.Select(p => ConvertNamedParameter(p, knowTypeParams))
                                   .ToList().NullIfEmpty();

            sdpMember.Exceptions = m.Docs.Exceptions?.Select(
                p => new TypeReference()
            {
                Description = p.Description,
                Type        = UidToTypeMDString(p.Uid, _store)
            }).ToList().NullIfEmpty();

            sdpMember.Permissions = m.Docs.Permissions?.Select(
                p => new TypeReference()
            {
                Description = p.Description,
                Type        = DocIdToTypeMDString(p.CommentId, _store)
            }).ToList().NullIfEmpty();

            if (m.Attributes != null &&
                m.Attributes.Any(attr => attr.Declaration == "System.CLSCompliant(false)"))
            {
                sdpMember.IsNotClsCompliant = true;
            }
            sdpMember.AltCompliant = m.Docs.AltCompliant.ResolveCommentId(_store)?.Uid;

            return(sdpMember);
        }
        public DelegateSDPModel FormatDelegate(Type t)
        {
            var sdpDelegate = InitWithBasicProperties <DelegateSDPModel>(t);

            sdpDelegate.TypeParameters = ConvertTypeParameters(t);
            sdpDelegate.Inheritances   = t.InheritanceChains?.LastOrDefault().Values.Select(uid => UidToTypeMDString(uid, _store)).ToList();

            if (t.ReturnValueType != null)
            {
                var returns = t.ReturnValueType;
                var r       = returns.VersionedTypes
                              .Where(v => !string.IsNullOrWhiteSpace(v.Value) && v.Value != "System.Void");
                if (r.Any())
                {
                    foreach (var vt in returns.VersionedTypes)
                    {
                        vt.Value = SDPYamlConverter.TypeStringToTypeMDString(vt.Value, _store);
                    }
                    sdpDelegate.ReturnsWithMoniker = returns;
                }
            }

            sdpDelegate.Parameters = t.Parameters?.Select(p => ConvertNamedParameter(p, t.TypeParameters))
                                     .ToList().NullIfEmpty();

            if (t.Attributes != null &&
                t.Attributes.Any(attr => attr.Declaration == "System.CLSCompliant(false)"))
            {
                sdpDelegate.IsNotClsCompliant = true;
            }
            sdpDelegate.AltCompliant = t.Docs.AltCompliant.ResolveCommentId(_store)?.Uid;

            if (t.ExtensionMethods?.Count > 0)
            {
                sdpDelegate.ExtensionMethods = t.ExtensionMethods.Select(im => ExtensionMethodToTypeMemberLink(t, im))
                                               .Where(ext => ext != null).ToList();
            }

            return(sdpDelegate);
        }