当前位置: 首页>>代码示例>>C#>>正文


C# ConstructorInitializerSyntax类代码示例

本文整理汇总了C#中ConstructorInitializerSyntax的典型用法代码示例。如果您正苦于以下问题:C# ConstructorInitializerSyntax类的具体用法?C# ConstructorInitializerSyntax怎么用?C# ConstructorInitializerSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConstructorInitializerSyntax类属于命名空间,在下文中一共展示了ConstructorInitializerSyntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Go

        public static void Go(OutputWriter writer, ConstructorInitializerSyntax method)
        {
            writer.WriteIndent();
            //    var symbl = TypeProcessor.GetSymbolInfo(method);
            //	var mysymbl = TypeProcessor.GetSymbolInfo(method.Parent);

            //   var className = symbl.Symbol.ContainingType;
            if (method.ThisOrBaseKeyword.RawKind == (int) SyntaxKind.ThisKeyword)
                writer.Write("this");
            else
                writer.Write("super");
//                writer.Write(TypeProcessor.ConvertType(className));

            writer.Write("(");
            bool first = true;
            foreach (var expression in method.ArgumentList.Arguments)
            {
                if (first)
                    first = false;
                else
                    writer.Write(", ");

                Core.Write(writer, expression.Expression);
            }
            writer.Write(")");
        }
开发者ID:mortezabarzkar,项目名称:SharpNative,代码行数:26,代码来源:WriteConstructorInitializer.cs

示例2: TryGetConstructorInitializer

        private bool TryGetConstructorInitializer(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, out ConstructorInitializerSyntax expression)
        {
            if (!CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, IsTriggerToken, IsArgumentListToken, cancellationToken, out expression))
            {
                return false;
            }

            return expression.ArgumentList != null;
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:9,代码来源:ConstructorInitializerSignatureHelpProvider.cs

示例3: ConstructorDeclaration

 public static ConstructorDeclarationSyntax ConstructorDeclaration(
     SyntaxList<AttributeListSyntax> attributeLists,
     SyntaxTokenList modifiers,
     SyntaxToken identifier,
     ParameterListSyntax parameterList,
     ConstructorInitializerSyntax initializer,
     ArrowExpressionClauseSyntax expressionBody)
     => ConstructorDeclaration(
         attributeLists,
         modifiers,
         identifier,
         parameterList,
         initializer,
         default(BlockSyntax),
         expressionBody,
         default(SyntaxToken));
开发者ID:XieShuquan,项目名称:roslyn,代码行数:16,代码来源:ConstructorDeclarationSyntax.cs

示例4: Update

 public ConstructorDeclarationSyntax Update(
     SyntaxList<AttributeListSyntax> attributeLists,
     SyntaxTokenList modifiers, 
     SyntaxToken identifier,
     ParameterListSyntax parameterList, 
     ConstructorInitializerSyntax initializer, 
     BlockSyntax body, 
     SyntaxToken semicolonToken)
     => Update(
         attributeLists, 
         modifiers, 
         identifier, 
         parameterList, 
         initializer, 
         body, 
         default(ArrowExpressionClauseSyntax), 
         semicolonToken);
开发者ID:XieShuquan,项目名称:roslyn,代码行数:17,代码来源:ConstructorDeclarationSyntax.cs

示例5: PropagateConstructorParams

        private async Task<Document> PropagateConstructorParams(
            Document document, 
            ConstructorInitializerSyntax constructorInitializerNode, 
            ImmutableArray<IParameterSymbol> baseConstrParams, 
            CancellationToken cancellationToken)
        {
            var semanticModel = await document.GetSemanticModelAsync();
            var classDecl = constructorInitializerNode.FirstAncestorOrSelf<ClassDeclarationSyntax>();
            var classSymbol = semanticModel.GetDeclaredSymbol(classDecl);
            var constructorDecl = constructorInitializerNode.FirstAncestorOrSelf<ConstructorDeclarationSyntax>();

            var constructorSymbol = classSymbol.Constructors
                .Where(p => p.Parameters.Count() == constructorDecl.ParameterList.Parameters.Count)
                .FirstOrDefault();

            var invArgList = constructorInitializerNode.ArgumentList;
            var declParamList = constructorDecl.ParameterList;

            int idx = -1;
            foreach(var baseP in baseConstrParams)
            {
                idx++;

                if (constructorSymbol.Parameters.Any(p => p.Type.Name == baseP.Type.Name))
                    continue;

                declParamList = declParamList.AddParameters(
                    SyntaxFactory.Parameter(
                        SyntaxFactory.Identifier(baseP.Name))
                    .WithType(
                        SyntaxFactory.IdentifierName(baseP.Type.Name)));

                invArgList = SyntaxFactory.ArgumentList(invArgList.Arguments.Insert(idx, SyntaxFactory.Argument(SyntaxFactory.IdentifierName(baseP.Name))));
            }

            var root = await document.GetSyntaxRootAsync();

            var newConstructor = constructorDecl.WithParameterList(declParamList)
                .WithInitializer(constructorInitializerNode.WithArgumentList(invArgList));

            root = root.ReplaceNode(constructorDecl, newConstructor);


            return document.WithSyntaxRoot(root);
        }
开发者ID:yohney,项目名称:common-refactorings-plugin,代码行数:45,代码来源:PropagateConstructorParamCodeFix.cs

示例6: ConstructorInitializerTranslation

        public ConstructorInitializerTranslation(ConstructorInitializerSyntax syntax, SyntaxTranslation parent) : base(syntax, parent)
        {

            ThisOrBaseKeyword = syntax.ThisOrBaseKeyword.Get(this);
            ArgumentList = syntax.ArgumentList.Get<ArgumentListTranslation>(this);
        }
开发者ID:asthomas,项目名称:TypescriptSyntaxPaste,代码行数:6,代码来源:ConstructorInitializerTranslation.cs

示例7: InferTypeInConstructorInitializer

 private IEnumerable<ITypeSymbol> InferTypeInConstructorInitializer(ConstructorInitializerSyntax initializer, int index, ArgumentSyntax argument = null)
 {
     var info = this.semanticModel.GetSymbolInfo(initializer, cancellationToken);
     var methods = info.GetBestOrAllSymbols().OfType<IMethodSymbol>();
     return InferTypeInArgument(index, methods, argument);
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:6,代码来源:CSharpTypeInferenceService.TypeInferrer.cs

示例8: VisitConstructorInitializer

 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitConstructorInitializer(ConstructorInitializerSyntax node)
 {
     this.OnNodeVisited(node);
     if (!this.traverseRootOnly) base.VisitConstructorInitializer(node);
 }
开发者ID:andry-tino,项目名称:Rosetta,代码行数:9,代码来源:MultiPurposeASTWalker.cs

示例9: RegisterActionForBaseCall

        private static void RegisterActionForBaseCall(CodeFixContext context, SyntaxNode root, ConstructorInitializerSyntax initializer)
        {
            var constructor = initializer.Parent as ConstructorDeclarationSyntax;
            if (constructor == null)
            {
                return;
            }

            context.RegisterCodeFix(
                CodeAction.Create(
                    TitleRemoveBaseCall,
                    c =>
                    {
                        var newRoot = RemoveInitializer(root, constructor);
                        return Task.FromResult(context.Document.WithSyntaxRoot(newRoot));
                    },
                    TitleRemoveBaseCall),
                context.Diagnostics);
        }
开发者ID:duncanpMS,项目名称:sonarlint-vs,代码行数:19,代码来源:RedundancyInConstructorDestructorDeclarationCodeFixProvider.cs

示例10: IsInitializerRedundant

 private static bool IsInitializerRedundant(ConstructorInitializerSyntax initializer)
 {
     return initializer.IsKind(SyntaxKind.BaseConstructorInitializer) &&
         initializer.ArgumentList != null &&
         !initializer.ArgumentList.Arguments.Any();
 }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:6,代码来源:RedundancyInConstructorDestructorDeclaration.cs

示例11: VisitConstructorInitializer

            public override void VisitConstructorInitializer(ConstructorInitializerSyntax node)
            {
                base.VisitConstructorInitializer(node);

                var method = context.SemanticModel.GetSymbolInfo(node).Symbol as IMethodSymbol;
                if (method != null)
                {
                    CheckArguments(node.ArgumentList.Arguments, method.Parameters);
                }
            }
开发者ID:uxsoft,项目名称:nullaby,代码行数:10,代码来源:NullAnalyzer.cs

示例12: IsInitializerEmptyOrRedundant

        private static bool IsInitializerEmptyOrRedundant(ConstructorInitializerSyntax initializer)
        {
            if (initializer == null)
            {
                return true;
            }

            return initializer.ArgumentList != null &&
                !initializer.ArgumentList.Arguments.Any() &&
                initializer.ThisOrBaseKeyword.IsKind(SyntaxKind.BaseKeyword);
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:11,代码来源:RedundancyInConstructorDestructorDeclaration.cs

示例13: VisitConstructorInitializer

        public void VisitConstructorInitializer(ConstructorInitializerSyntax node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            node.Validate();

            if (_writer.Configuration.LineBreaksAndWrapping.Other.PlaceConstructorInitializerOnSameLine)
            {
                _writer.WriteSpace();
            }
            else
            {

                _writer.WriteLine();

                _writer.PushIndent();
                _writer.WriteIndent();
            }

            _writer.WriteSyntax(Syntax.Colon);
            _writer.WriteSpace();
            _writer.WriteKeyword(node.Kind == ThisOrBase.This ? PrinterKeyword.This : PrinterKeyword.Base);
            node.ArgumentList.Accept(this);

            if (!_writer.Configuration.LineBreaksAndWrapping.Other.PlaceConstructorInitializerOnSameLine)
                _writer.PopIndent();
        }
开发者ID:modulexcite,项目名称:CSharpSyntax,代码行数:28,代码来源:SyntaxPrinter.cs

示例14: VisitConstructorInitializer

 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitConstructorInitializer(ConstructorInitializerSyntax node)
 {
     this.OnNodeVisited(node, this.type.IsInstanceOfType(node));
     base.VisitConstructorInitializer(node);
 }
开发者ID:andry-tino,项目名称:Rosetta,代码行数:9,代码来源:ASTWalkerNodeTypeOperationExecutor.cs

示例15: IsArgumentListToken

 private static bool IsArgumentListToken(ConstructorInitializerSyntax expression, SyntaxToken token)
 {
     return expression.ArgumentList != null &&
         expression.ArgumentList.Span.Contains(token.SpanStart) &&
         token != expression.ArgumentList.CloseParenToken;
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:6,代码来源:ConstructorInitializerSignatureHelpProvider.cs


注:本文中的ConstructorInitializerSyntax类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。