本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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
)
)
)
);
}
示例5: RemoveBase
public static ClassDeclarationSyntax RemoveBase(ClassDeclarationSyntax type, string baseName)
{
if (type.BaseList == null)
{
return type;
}
return type.WithBaseList(RemoveBase(type.BaseList, baseName));
}