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


C# ClassDeclarationSyntax.WithBaseList方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax.WithBaseList方法的典型用法代码示例。如果您正苦于以下问题:C# ClassDeclarationSyntax.WithBaseList方法的具体用法?C# ClassDeclarationSyntax.WithBaseList怎么用?C# ClassDeclarationSyntax.WithBaseList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax的用法示例。


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

示例1: AddBase

 public static ClassDeclarationSyntax AddBase(ClassDeclarationSyntax type, string baseName)
 {
     if (type.BaseList == null)
     {
         type = type.WithBaseList(SF.BaseList());
     }
     return type.WithBaseList(AddBase(type.BaseList, baseName));
 }
开发者ID:cdsalmons,项目名称:OrleansTemplates,代码行数:8,代码来源:RoslynUtils.cs

示例2: ChangeComponentBaseType

		/// <summary>
		///   Changes the base type of the derived component declaration.
		/// </summary>
		private ClassDeclarationSyntax ChangeComponentBaseType(INamedTypeSymbol classSymbol, ClassDeclarationSyntax classDeclaration)
		{
			if (classDeclaration.BaseList == null)
				return classDeclaration;

			if (classSymbol.BaseType.Equals(SemanticModel.GetTypeSymbol<Component>()))
				return classDeclaration;

			var baseTypeName = classSymbol.BaseType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
			INamedTypeSymbol[] faults;

			if (!_faults.TryGetValue(_typeLookup[baseTypeName], out faults) || faults.Length == 0)
				return classDeclaration;

			var baseType = Syntax.TypeExpression(faults[faults.Length - 1]).WithTrivia(classDeclaration.BaseList.Types[0]);
			var baseTypeSyntax = (BaseTypeSyntax)SyntaxFactory.SimpleBaseType((TypeSyntax)baseType);

			var baseList = classDeclaration.BaseList.ReplaceNode(classDeclaration.BaseList.Types[0], baseTypeSyntax);
			return classDeclaration.WithBaseList(baseList);
		}
开发者ID:isse-augsburg,项目名称:ssharp,代码行数:23,代码来源:FaultEffectNormalizer.cs

示例3: ChangeFaultEffectBaseType

		/// <summary>
		///   Changes the base type of the fault effect declaration based on its location in the fault effect list.
		/// </summary>
		private ClassDeclarationSyntax ChangeFaultEffectBaseType(INamedTypeSymbol classSymbol, ClassDeclarationSyntax classDeclaration)
		{
			var baseTypeName = classSymbol.BaseType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
			var faultEffectSymbol = _typeLookup[classSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)];
			var faultIndex = Array.IndexOf(_faults[_typeLookup[baseTypeName]], faultEffectSymbol);
			if (faultIndex == 0)
				return classDeclaration;

			var baseType = Syntax.TypeExpression(_faults[_typeLookup[baseTypeName]][faultIndex - 1]).WithTrivia(classDeclaration.BaseList.Types[0]);
			var baseTypes = SyntaxFactory.SingletonSeparatedList((BaseTypeSyntax)SyntaxFactory.SimpleBaseType((TypeSyntax)baseType));
			var baseList = SyntaxFactory.BaseList(classDeclaration.BaseList.ColonToken, baseTypes).WithTrivia(classDeclaration.BaseList);
			return classDeclaration.WithBaseList(baseList);
		}
开发者ID:isse-augsburg,项目名称:ssharp,代码行数:16,代码来源:FaultEffectNormalizer.cs

示例4: CreateClassSyntax

        private void CreateClassSyntax()
        {
            var baseType = SyntaxFactory.IdentifierName("IMyLevelScript");

            if(!(m_objectBuilder is MyObjectBuilder_VisualLevelScript))
                baseType = string.IsNullOrEmpty(m_objectBuilder.Interface) ? null : SyntaxFactory.IdentifierName(m_baseType.Name);

            m_scriptClassDeclaration = MySyntaxFactory.PublicClass(m_scriptName);
                
            if(baseType != null)
            m_scriptClassDeclaration = m_scriptClassDeclaration 
                                        .WithBaseList(
                                                SyntaxFactory.BaseList(
                                                    SyntaxFactory.SingletonSeparatedList<BaseTypeSyntax>(
                                                        SyntaxFactory.SimpleBaseType(
                                                            baseType
                                                        )
                                                    )
                                                )
                                            );
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:21,代码来源:MyVisualScriptBuilder.cs

示例5: RemoveBase

 public static ClassDeclarationSyntax RemoveBase(ClassDeclarationSyntax type, string baseName)
 {
     if (type.BaseList == null)
     {
         return type;
     }
     return type.WithBaseList(RemoveBase(type.BaseList, baseName));
 }
开发者ID:cdsalmons,项目名称:OrleansTemplates,代码行数:8,代码来源:RoslynUtils.cs


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