Ejemplo n.º 1
0
        private void WriteMethod(MethodTarget target, DisplayOptions options, XmlWriter writer, Dictionary <IndexedTemplateTypeReference, TypeReference> dictionary)
        {
            WriteProcedureName(target, writer);

            if ((options & DisplayOptions.ShowTemplates) > 0)
            {
                // if this is a generic method, write any template params or args
                if (target.TemplateArgs != null && target.TemplateArgs.Count > 0)
                {
                    WriteTemplateArguments(target.TemplateArgs, writer);
                }
            }

            if ((options & DisplayOptions.ShowParameters) > 0)
            {
                if (target.IsConversionOperator)
                {
                    WriteConversionOperatorParameters(target.Parameters, target.ReturnType, writer, dictionary);
                }
                else
                {
                    WriteMethodParameters(target.Parameters, writer, dictionary);
                }
            }
        }
Ejemplo n.º 2
0
        private string GetTemplateName(string templateId, int position)
        {
            Target target = targets[templateId];

            if (target != null)
            {
                TypeTarget type = target as TypeTarget;

                if (type != null)
                {
                    IList <string> templates = type.Templates;

                    if (templates.Count > position)
                    {
                        return(templates[position]);
                    }
                }
                else
                {
                    MethodTarget method = target as MethodTarget;

                    if (method != null)
                    {
                        IList <string> templates = method.Templates;

                        if (templates.Count > position)
                        {
                            return(templates[position]);
                        }
                    }
                }
            }

            return("UTT");
        }
        private static MethodTarget CreateMethodTarget(XPathNavigator api)
        {
            MethodTarget target = new MethodTarget(CreateParameterList(api), CreateReturnType(api));

            target.IsConversionOperator = (bool)api.Evaluate(apiIsConversionOperatorExpression);

            if ((bool)api.Evaluate(apiIsExplicitImplementationExpression))
            {
                target.ExplicitlyImplements = CreateMemberReference(api.SelectSingleNode(apiImplementedMembersExpression));
            }

            // This selects templates/template or templates/type, because extension methods can have a mix of
            // generic and specialization.
            XPathNodeIterator templateArgNodes = api.Select(methodTemplateArgsExpression);

            TypeReference[] templateArgumentReferences = null;

            if (templateArgNodes != null && templateArgNodes.Count > 0)
            {
                templateArgumentReferences = new TypeReference[templateArgNodes.Count];
                int i = 0;

                foreach (XPathNavigator templateArgNode in templateArgNodes)
                {
                    templateArgumentReferences[i] = CreateTypeReference(templateArgNode);
                    i++;
                }
            }

            target.TemplateArgs = templateArgumentReferences;

            // Get the short name of each template param
            target.Templates = GetTemplateNames(api);

            return(target);
        }
Ejemplo n.º 4
0
        private void WriteMemberTarget(MemberTarget target, DisplayOptions options, XmlWriter writer, Dictionary <IndexedTemplateTypeReference, TypeReference> dictionary)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            MethodTarget method = target as MethodTarget;

            if ((options & DisplayOptions.ShowContainer) > 0)
            {
                WriteType(target.ContainingType, options & ~DisplayOptions.ShowContainer, writer);

                if (method != null && method.IsConversionOperator)
                {
                    writer.WriteString(" ");
                }
                else
                {
                    WriteSeparator(writer);
                }
            }

            // special logic for writing methods
            if (method != null)
            {
                WriteMethod(method, options, writer, dictionary);
                return;
            }

            // special logic for writing properties
            PropertyTarget property = target as PropertyTarget;

            if (property != null)
            {
                WriteProperty(property, options, writer);
                return;
            }

            // special logic for writing constructors
            ConstructorTarget constructor = target as ConstructorTarget;

            if (constructor != null)
            {
                WriteConstructor(constructor, options, writer);
                return;
            }

            // special logic for writing events
            EventTarget trigger = target as EventTarget;

            if (trigger != null)
            {
                WriteEvent(trigger, writer);
                return;
            }

            // by default, just write name
            writer.WriteString(target.Name);
        }
        private static MethodTarget CreateMethodTarget(XPathNavigator api)
        {
            MethodTarget target = new MethodTarget(CreateParameterList(api), CreateReturnType(api));

            target.IsConversionOperator = (bool)api.Evaluate(apiIsConversionOperatorExpression);

            if((bool)api.Evaluate(apiIsExplicitImplementationExpression))
                target.ExplicitlyImplements = CreateMemberReference(api.SelectSingleNode(apiImplementedMembersExpression));

            // This selects templates/template or templates/type, because extension methods can have a mix of
            // generic and specialization.
            XPathNodeIterator templateArgNodes = api.Select(methodTemplateArgsExpression);
            TypeReference[] templateArgumentReferences = null;

            if(templateArgNodes != null && templateArgNodes.Count > 0)
            {
                templateArgumentReferences = new TypeReference[templateArgNodes.Count];
                int i = 0;

                foreach(XPathNavigator templateArgNode in templateArgNodes)
                {
                    templateArgumentReferences[i] = CreateTypeReference(templateArgNode);
                    i++;
                }
            }

            target.TemplateArgs = templateArgumentReferences;

            // Get the short name of each template param
            target.Templates = GetTemplateNames(api);

            return target;
        }
Ejemplo n.º 6
0
        private void WriteMethod(MethodTarget target, DisplayOptions options, XmlWriter writer, Dictionary<IndexedTemplateTypeReference, TypeReference> dictionary)
        {
            WriteProcedureName(target, writer);

            if((options & DisplayOptions.ShowTemplates) > 0)
            {
                // if this is a generic method, write any template params or args
                if(target.TemplateArgs != null && target.TemplateArgs.Count > 0)
                    WriteTemplateArguments(target.TemplateArgs, writer);
            }

            if((options & DisplayOptions.ShowParameters) > 0)
            {
                if(target.IsConversionOperator)
                    WriteConversionOperatorParameters(target.Parameters, target.ReturnType, writer, dictionary);
                else
                    WriteMethodParameters(target.Parameters, writer, dictionary);
            }
        }