Ejemplo n.º 1
0
        /// <summary>
        /// Renders the method XML to the <paramref name="writer."/>
        /// </summary>
        /// <param name="writer">The open valid writer to write to.</param>
        public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath       crefPath    = new CRefPath(_member);
            XmlCodeComment comment     = _xmlComments.GetComment(crefPath);
            string         displayName = _member.GetDisplayName(false);

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", AssociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", AssociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            writer.WriteAttributeString("cref", crefPath.ToString());
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(displayName));
            writer.WriteString(_member.GetDisplayName(false));
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = AssociatedEntry.FindNamespace(_member.Type.Namespace);

            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.Type.Namespace}");
            writer.WriteString(_member.Type.Namespace);
            writer.WriteEndElement();
            writer.WriteStartElement("assembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.Assembly.FileName));
            writer.WriteString(_member.Assembly.Name);
            writer.WriteEndElement();

            if (_member.IsGeneric)
            {
                RenderGenericTypeParameters(_member.GetGenericTypes(), writer, comment);
            }

            RenderParameters(writer, comment);
            RenderExceptionBlock(_member, writer, comment);
            RenderPermissionBlock(_member, writer, comment);

            if (comment != XmlCodeComment.Empty)
            {
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement));
            }

            RenderSyntaxBlocks(_member, writer);
            RenderReturnsBlock(writer, comment);

            if (comment != XmlCodeComment.Empty)
            {
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement));
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement));
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is SeeAlsoXmlCodeElement));
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            writer.WriteEndElement();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Obtains a collection of <see cref="GenericTypeRef"/> instances detailing
 /// the generic types for this method.
 /// </summary>
 /// <returns>The collection of generic parameters for the method.</returns>
 /// <remarks>
 /// This method is only valid when the <see cref="MethodDef.IsGeneric"/> property
 /// has been set to true.
 /// </remarks>
 public List <GenericTypeRef> GetGenericParameters()
 {
     return(_method.GetGenericTypes());
 }
Ejemplo n.º 3
0
        private void ConvertAndIncludeParameters(StringBuilder converted)
        {
            if (_method != null)
            {
                if (_method.IsConstructor && _property == null)
                {
                    GetTypeName(converted, _type);
                }
                else if (_method.IsOperator && _property == null)
                {
                    if (_method.IsConversionOperator)
                    {
                        Signature sig            = _method.Signiture;
                        TypeRef   convertToRef   = sig.GetReturnTypeToken().ResolveType(_method.Assembly, _method);
                        TypeRef   convertFromRef = sig.GetParameterTokens()[0].ResolveParameter(_method.Assembly, _method.Parameters[0]);

                        converted.Append(_method.Name.Substring(3));
                        converted.Append("(");
                        converted.Append(convertToRef.GetDisplayName(false));
                        converted.Append(" to ");
                        converted.Append(convertFromRef.GetDisplayName(false));
                        converted.Append(")");
                    }
                    else
                    {
                        converted.Append(_method.Name.Substring(3));
                    }
                }
                else if (_property == null)
                {
                    converted.Append(_method.Name);
                }
                else
                {
                    converted.Append(_property.Name);
                }

                if (_method.IsGeneric)
                {
                    converted.Append(GenericStart);
                    bool first = true;
                    foreach (GenericTypeRef type in _method.GetGenericTypes())
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            converted.Append(", ");
                        }
                        converted.Append(type.Name);
                    }
                    converted.Append(GenericEnd);
                }

                if (ShouldIncludeParameters())
                {
                    string parameters = "()";
                    if (ShouldConvertParameters())
                    {
                        parameters = Convert(_method);
                    }
                    converted.Append(parameters);
                }
            }
        }