本文整理汇总了C#中ITypeDeclaration.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDeclaration.ToString方法的具体用法?C# ITypeDeclaration.ToString怎么用?C# ITypeDeclaration.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDeclaration
的用法示例。
在下文中一共展示了ITypeDeclaration.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNewObject
/// <summary>
/// Adds the new object.
/// </summary>
/// <param name="typeDeclaration">The type declaration.</param>
/// <param name="startType">The start type.</param>
/// <param name="includeBase">if set to <c>true</c> include base type info.</param>
/// <returns>
/// The base type declaration of the given type declaration; null if not within the same namespace or not found.
/// </returns>
internal ITypeDeclaration AddNewObject(ITypeDeclaration typeDeclaration, string startType, bool includeBase)
{
// Remove the current type from the additional load list.
if (this.AdditionalLoadList.Find(typeInfo => typeInfo == typeDeclaration) != null)
{
this.AdditionalLoadList.Remove(typeDeclaration);
}
if (this.TypeDataList.Find(typeInfo => string.Compare(typeInfo.TypeName, typeDeclaration.Name, StringComparison.Ordinal) == 0) != null)
{
// Type already added
Logger.Current.Info("The type has already been added to the list..." + typeDeclaration.ToString());
return null;
}
ITypeDeclaration baseType = null;
ClassTypeInfo typeData = new ClassTypeInfo
{
StartTypeName = startType,
Namespace = typeDeclaration.Namespace,
TypeName = typeDeclaration.Name,
Modifier = ReflectorHelper.DetermineModifier(typeDeclaration)
};
// base type
if (typeDeclaration.BaseType != null && string.Compare(ReflectorHelper.GetNameWithResolutionScope(typeDeclaration.BaseType), "System.Object", StringComparison.Ordinal) != 0)
{
baseType = typeDeclaration.BaseType.Resolve();
ClassTypeInfo baseTypeData = new ClassTypeInfo
{
StartTypeName = startType,
Namespace = baseType.Namespace,
TypeName = baseType.Name,
Modifier = ReflectorHelper.DetermineModifier(baseType),
};
if (baseType.GenericType != null)
{
ITypeReference genericBaseType = baseType.GenericType;
if (baseType.GenericArguments != null)
{
foreach (IType item in baseType.GenericArguments)
{
baseTypeData.GenericParameters.Add(new ClassTypeInfo
{
StartTypeName = startType,
Namespace = typeDeclaration.Namespace,
TypeName = item.ToString(),
Modifier = ReflectorHelper.DetermineModifier(null)
});
}
}
baseType = genericBaseType.Resolve();
}
typeData.BaseType = baseTypeData;
}
// interfaces
foreach (ITypeReference item in typeDeclaration.Interfaces)
{
ITypeDeclaration interfaceDeclaration = item.Resolve();
typeData.Interfaces.Add(new ClassTypeInfo
{
StartTypeName = startType,
Namespace = interfaceDeclaration.Namespace,
TypeName = ReflectorHelper.GetName(interfaceDeclaration),
Modifier = ReflectorHelper.DetermineModifier(interfaceDeclaration)
});
}
// generic parameters
foreach (var item in typeDeclaration.GenericArguments)
{
ITypeReference reference = item as ITypeReference;
if (reference != null)
{
typeData.GenericParameters.Add(new ClassTypeInfo
{
StartTypeName = startType,
Namespace = reference.Namespace,
TypeName = reference.Name,
Modifier = ReflectorHelper.DetermineModifier(reference.Resolve())
});
}
else
{
typeData.GenericParameters.Add(new ClassTypeInfo
{
StartTypeName = startType,
//.........这里部分代码省略.........
示例2: ToDomType
public static IReturnType ToDomType(ITypeDeclaration td)
{
return td == null ? null : new DomReturnType(td.ToString());
}
示例3: ResolveType
public static ResolveResult[] ResolveType(ITypeDeclaration declaration,
ResolverContext ctxt,
IBlockNode currentScopeOverride = null)
{
if (ctxt == null)
return null;
var ctxtOverride=ctxt;
if(currentScopeOverride!=null && currentScopeOverride!=ctxt.ScopedBlock){
ctxtOverride=new ResolverContext();
ctxtOverride.ApplyFrom(ctxt);
ctxtOverride.ScopedBlock = currentScopeOverride;
ctxtOverride.ScopedStatement = null;
}
if(ctxtOverride.ScopedBlock!=null &&( ctxtOverride.ImportCache==null || ctxtOverride.ScopedBlock.NodeRoot!=ctxt.ScopedBlock.NodeRoot))
{
ctxtOverride.ImportCache=ResolveImports(ctxtOverride.ScopedBlock.NodeRoot as DModule,ctxt.ParseCache);
}
if (currentScopeOverride == null)
currentScopeOverride = ctxt.ScopedBlock;
if (ctxt == null || declaration == null)
return null;
ResolveResult[] preRes = null;
object scopeObj = null;
if (ctxtOverride.ScopedStatement != null)
{
var curStmtLevel=ctxtOverride.ScopedStatement;
while (curStmtLevel != null && !(curStmtLevel is BlockStatement))
curStmtLevel = curStmtLevel.Parent;
if(curStmtLevel is BlockStatement)
scopeObj = curStmtLevel;
}
if (scopeObj == null)
scopeObj = ctxtOverride.ScopedBlock;
// Check if already resolved once
if (ctxtOverride.TryGetAlreadyResolvedType(declaration.ToString(), out preRes, scopeObj))
return preRes;
var returnedResults = new List<ResolveResult>();
// Walk down recursively to resolve everything from the very first to declaration's base type declaration.
ResolveResult[] rbases = null;
if (declaration.InnerDeclaration != null)
rbases = ResolveType(declaration.InnerDeclaration, ctxtOverride);
// If it's a template, resolve the template id first
if (declaration is TemplateInstanceExpression)
declaration = (declaration as TemplateInstanceExpression).TemplateIdentifier;
/*
* If there is no parent resolve context (what usually means we are searching the type named like the first identifier in the entire declaration),
* search the very first type declaration by walking along the current block scope hierarchy.
* If there wasn't any item found in that procedure, search in the global parse cache
*/
#region Search initial member/type/module/whatever
if (rbases == null)
{
#region IdentifierDeclaration
if (declaration is IdentifierDeclaration)
{
string searchIdentifier = (declaration as IdentifierDeclaration).Value as string;
if (string.IsNullOrEmpty(searchIdentifier))
return null;
// Try to convert the identifier into a token
int searchToken = string.IsNullOrEmpty(searchIdentifier) ? 0 : DTokens.GetTokenID(searchIdentifier);
// References current class scope
if (searchToken == DTokens.This)
{
var classDef = ctxt.ScopedBlock;
while (!(classDef is DClassLike) && classDef != null)
classDef = classDef.Parent as IBlockNode;
if (classDef is DClassLike)
{
var res = HandleNodeMatch(classDef, ctxtOverride, typeBase: declaration);
if (res != null)
returnedResults.Add(res);
}
}
// References super type of currently scoped class declaration
else if (searchToken == DTokens.Super)
{
var classDef = currentScopeOverride;
while (!(classDef is DClassLike) && classDef != null)
//.........这里部分代码省略.........