Пример #1
0
        /// <summary>
        /// Parses a constructor.
        /// </summary>
        /// <param name="memberName">Member name.</param>
        /// <param name="access">Member accessibility.</param>
        /// <param name="memberAttributes">Member attributes.</param>
        /// <returns>Constructor code element.</returns>
        private ConstructorElement ParseConstructor(string memberName, CodeAccess access, MemberModifiers memberAttributes)
        {
            ConstructorElement constructor = new ConstructorElement();
            constructor.Name = memberName;
            constructor.Access = access;
            constructor.MemberModifiers = memberAttributes;

            constructor.Parameters = this.ParseParameters();

            EatWhiteSpace();

            List<ICommentElement> extraComments = new List<ICommentElement>();
            extraComments.AddRange(ParseComments());

            EatWhiteSpace();

            bool hasReference = TryReadChar(CSharpSymbol.TypeImplements);
            if (hasReference)
            {
                EatWhiteSpace();

                extraComments.AddRange(ParseComments());

                StringBuilder referenceBuilder = new StringBuilder(DefaultWordLength);

                EatWhiteSpace();
                referenceBuilder.Append(CaptureWord());

                EatWhiteSpace();
                string referenceParams =
                    ParseNestedText(CSharpSymbol.BeginParameterList, CSharpSymbol.EndParameterList, true, true);
                referenceBuilder.Append(CSharpSymbol.BeginParameterList);
                referenceBuilder.Append(referenceParams);
                referenceBuilder.Append(CSharpSymbol.EndParameterList);

                constructor.Reference = referenceBuilder.ToString();
            }

            constructor.BodyText = this.ParseBlock(true, constructor);

            foreach (ICommentElement comment in extraComments)
            {
                constructor.AddHeaderComment(comment);
            }

            return constructor;
        }