NArrange.VisualBasic.VBParser.ParseTypeParameters C# (CSharp) Method

ParseTypeParameters() private method

Parses type parameters.
private ParseTypeParameters ( IGenericElement genericElement ) : void
genericElement IGenericElement The generic element.
return void
        private void ParseTypeParameters(IGenericElement genericElement)
        {
            EatWhiteSpace();

            if (NextChar == VBSymbol.EndParameterList ||
                NextChar == EmptyChar)
            {
                this.OnParseError("Expected type parameter");
            }

            do
            {
                if (genericElement.TypeParameters.Count > 0)
                {
                    if (NextChar == VBSymbol.AliasSeparator)
                    {
                        TryReadChar();
                    }
                    else
                    {
                        this.OnParseError("Expected , or )");
                    }
                }

                string typeParameterName = CaptureWord();

                EatWhiteSpace();

                if (NextChar == EmptyChar)
                {
                    break;
                }

                TypeParameter typeParameter = new TypeParameter();
                typeParameter.Name = typeParameterName;

                if (NextChar != VBSymbol.AliasSeparator &&
                    NextChar != VBSymbol.EndParameterList)
                {
                    if (char.ToLower(NextChar) == char.ToLower(VBKeyword.As[0]))
                    {
                        TryReadChar();

                        if (char.ToLower(NextChar) == char.ToLower(VBKeyword.As[1]))
                        {
                            TryReadChar();

                            EatWhiteSpace();

                            if (NextChar == VBSymbol.EndParameterList)
                            {
                                this.OnParseError("Expected type parameter constraint");
                            }

                            if (NextChar == VBSymbol.BeginTypeConstraintList)
                            {
                                TryReadChar();

                                while (NextChar != VBSymbol.EndTypeConstraintList &&
                                       NextChar != EmptyChar)
                                {
                                    string typeParameterConstraint;
                                    typeParameterConstraint = ParseTypeParameterConstraint();
                                    typeParameter.AddConstraint(typeParameterConstraint);

                                    if (NextChar != VBSymbol.EndTypeConstraintList)
                                    {
                                        if (NextChar == VBSymbol.AliasSeparator)
                                        {
                                            TryReadChar();
                                        }
                                        else
                                        {
                                            this.OnParseError("Expected , or }");
                                        }
                                    }
                                }

                                EatChar(VBSymbol.EndTypeConstraintList);
                            }
                            else
                            {
                                string typeParameterConstraint;
                                typeParameterConstraint = ParseTypeParameterConstraint();
                                typeParameter.AddConstraint(typeParameterConstraint);
                            }
                        }
                    }
                }

                genericElement.AddTypeParameter(typeParameter);

                EatWhiteSpace();
            } while (NextChar != VBSymbol.EndParameterList && NextChar != EmptyChar);

            EatChar(VBSymbol.EndParameterList);
        }