Class describing methods.
Internal members protected for testability.
Inheritance: MethodSignatureDeclarationTranslationUnit
示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MethodASTWalker"/> class.
        /// </summary>
        protected MethodASTWalker(CSharpSyntaxNode node)
        {
            var methodDeclarationSyntaxNode = node as MethodDeclarationSyntax;
            if (methodDeclarationSyntaxNode == null)
            {
                throw new ArgumentException(
                    string.Format("Specified node is not of type {0}",
                    typeof(MethodDeclarationSyntax).Name));
            }

            this.node = node;
            MethodDeclaration methodHelper = new MethodDeclaration(methodDeclarationSyntaxNode);

            this.methodDeclaration = MethodDeclarationTranslationUnit.Create(
                methodHelper.Visibility,
                IdentifierTranslationUnit.Create(methodHelper.ReturnType),
                IdentifierTranslationUnit.Create(methodHelper.Name));

            foreach (TypedIdentifier parameter in methodHelper.Parameters)
            {
                this.methodDeclaration.AddArgument(ArgumentDefinitionTranslationUnit.Create(
                    IdentifierTranslationUnit.Create(parameter.TypeName),
                    IdentifierTranslationUnit.Create(parameter.IdentifierName)));
            }
        }
 /// <summary>
 /// Copy initializes a new instance of the <see cref="MethodDeclarationTranslationUnit"/> class.
 /// </summary>
 /// <param name="other"></param>
 /// <remarks>
 /// For testability.
 /// </remarks>
 public MethodDeclarationTranslationUnit(MethodDeclarationTranslationUnit other)
     : base(other)
 {
     this.statements = other.statements;
 }
 /// <summary>
 /// Copy initializes a new instance of the <see cref="MethodDeclarationTranslationUnit"/> class.
 /// </summary>
 /// <param name="other"></param>
 /// <remarks>
 /// For testability.
 /// </remarks>
 public MethodDeclarationTranslationUnit(MethodDeclarationTranslationUnit other)
     : base(other)
 {
     this.statements = other.statements;
 }