本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax.IsStatic方法的典型用法代码示例。如果您正苦于以下问题:C# ConstructorDeclarationSyntax.IsStatic方法的具体用法?C# ConstructorDeclarationSyntax.IsStatic怎么用?C# ConstructorDeclarationSyntax.IsStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax
的用法示例。
在下文中一共展示了ConstructorDeclarationSyntax.IsStatic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtendExistingConstructor
/// <summary>
/// if the child class already has a constructor,
/// a new parameter will be added to the constructor
/// </summary>
/// <param name="oldConstructor">constructor to which
/// we are going to add the new parameter</param>
/// <returns>the constructor with the additional new parameter</returns>
public ConstructorDeclarationSyntax ExtendExistingConstructor(
ConstructorDeclarationSyntax oldConstructor)
{
if (oldConstructor.IsStatic())
return oldConstructor;
var parameterName = _mixin.Name.ConvertFieldNameToParameterName();
// if there is already a parameter with the same name, skip further processing
var alreadyHasParameter = oldConstructor.ParameterList.Parameters.Any(x => x.Identifier.Text == parameterName);
if (alreadyHasParameter)
return oldConstructor;
// first rule: extend the constructors parameter list
var parameter = CreateConstructorParameterForMixin(parameterName);
var newConstructor = oldConstructor.AddParameterListParameters(parameter);
// second rule: check for initializer
// if we have no initializer or a base initializer, do the assignment in this constructor
// but do not delegate the parameter to further constructors
var initializer = oldConstructor.Initializer;
if(initializer == null || initializer.IsKind(SyntaxKind.BaseConstructorInitializer))
{
newConstructor = newConstructor
.AddBodyStatements(CreateAssigmentStatementForConstructorBody(parameterName));
}
return newConstructor;
}
示例2: VisitConstructorDeclaration
public override SyntaxNode VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
{
node = (ConstructorDeclarationSyntax)base.VisitConstructorDeclaration(node);
if(!node.IsStatic()) // ignore static constructors
node = _injectMixinIntoConstructor.ExtendExistingConstructor(node);
// remember that class already has a constructor,
// so no need to create a new one
_SourceClassHasConstructor = true;
return node;
}
示例3: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
{
// ignore static constructors
if (node.IsStatic())
return;
var constructor = new Constructor();
// read parameters
var parameterSyntaxReader = new ParameterSyntaxReader(constructor, _semantic);
parameterSyntaxReader.Visit(node);
_constructors.AddConstructor(constructor);
base.VisitConstructorDeclaration(node);
}