本文整理汇总了C#中TypeDeclaration.AcceptChildren方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDeclaration.AcceptChildren方法的具体用法?C# TypeDeclaration.AcceptChildren怎么用?C# TypeDeclaration.AcceptChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeDeclaration
的用法示例。
在下文中一共展示了TypeDeclaration.AcceptChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitTypeDeclaration
public virtual object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) {
Debug.Assert((typeDeclaration != null));
Debug.Assert((typeDeclaration.Attributes != null));
Debug.Assert((typeDeclaration.BaseTypes != null));
Debug.Assert((typeDeclaration.Templates != null));
foreach (AttributeSection o in typeDeclaration.Attributes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
foreach (TypeReference o in typeDeclaration.BaseTypes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
foreach (TemplateDefinition o in typeDeclaration.Templates) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
return typeDeclaration.AcceptChildren(this, data);
}
示例2: VisitTypeDeclaration
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
if (this.CurrentType != null)
{
this.NestedTypes = this.NestedTypes ?? new List<Tuple<TypeDeclaration, ITypeInfo>>();
this.NestedTypes.Add(new Tuple<TypeDeclaration, ITypeInfo>(typeDeclaration, this.CurrentType));
return;
}
ValidateNamespace(typeDeclaration);
if (this.HasIgnore(typeDeclaration))
{
return;
}
var rr = this.Resolver.ResolveNode(typeDeclaration, null);
var fullName = rr.Type.ReflectionName;
var partialType = this.Types.FirstOrDefault(t => t.Key == fullName);
var add = true;
if (partialType == null)
{
ITypeInfo parentTypeInfo = null;
var parentTypeDeclaration = typeDeclaration.GetParent<TypeDeclaration>();
if (parentTypeDeclaration != null)
{
var rr1 = this.Resolver.ResolveNode(parentTypeDeclaration, null);
var parentName = rr1.Type.ReflectionName;
parentTypeInfo = this.Types.FirstOrDefault(t => t.Key == parentName);
}
this.CurrentType = new TypeInfo()
{
Key = rr.Type.ReflectionName,
TypeDeclaration = typeDeclaration,
ParentType = parentTypeInfo,
Name = typeDeclaration.Name,
ClassType = typeDeclaration.ClassType,
Namespace = this.Namespace,
Usings = new HashSet<string>(Usings),
IsEnum = typeDeclaration.ClassType == ClassType.Enum,
IsStatic = typeDeclaration.ClassType == ClassType.Enum || typeDeclaration.HasModifier(Modifiers.Static),
IsObjectLiteral = this.IsObjectLiteral(typeDeclaration),
Type = rr.Type
};
if (parentTypeInfo != null && Emitter.reservedStaticNames.Any(n => String.Equals(this.CurrentType.Name, n, StringComparison.InvariantCultureIgnoreCase)))
{
throw new EmitterException(typeDeclaration, "Nested class cannot have such name: " + this.CurrentType.Name + ". Please rename it.");
}
}
else
{
this.CurrentType = partialType;
add = false;
}
if (typeDeclaration.ClassType != ClassType.Interface)
{
typeDeclaration.AcceptChildren(this);
}
else
{
typeDeclaration.AcceptChildren(this);
}
if (add)
{
this.Types.Add(this.CurrentType);
}
this.CurrentType = null;
while (this.NestedTypes != null && this.NestedTypes.Count > 0)
{
var types = this.NestedTypes;
this.NestedTypes = null;
foreach (var nestedType in types)
{
this.VisitTypeDeclaration(nestedType.Item1);
}
}
}
示例3: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
TypeDeclaration oldTypeDeclaration = currentTypeDeclaration;
currentTypeDeclaration = typeDeclaration;
CodeTypeDeclaration codeTypeDeclaration = new CodeTypeDeclaration(typeDeclaration.Name);
codeTypeDeclaration.TypeAttributes = ConvTypeAttributes(typeDeclaration.Modifier);
codeTypeDeclaration.IsClass = typeDeclaration.Type == ClassType.Class;
codeTypeDeclaration.IsEnum = typeDeclaration.Type == ClassType.Enum;
codeTypeDeclaration.IsInterface = typeDeclaration.Type == ClassType.Interface;
codeTypeDeclaration.IsStruct = typeDeclaration.Type == ClassType.Struct;
codeTypeDeclaration.IsPartial = (typeDeclaration.Modifier & Modifiers.Partial) != 0;
if (typeDeclaration.BaseTypes != null) {
foreach (TypeReference typeRef in typeDeclaration.BaseTypes) {
codeTypeDeclaration.BaseTypes.Add(ConvType(typeRef));
}
}
if (typeDeclaration.Templates != null) {
foreach (TemplateDefinition templateDefinition in typeDeclaration.Templates) {
codeTypeDeclaration.TypeParameters.Add(templateDefinition.Name);
}
}
typeDeclarations.Push(codeTypeDeclaration);
typeDeclaration.AcceptChildren(this, data);
typeDeclarations.Pop();
if (typeDeclarations.Count > 0) {
typeDeclarations.Peek().Members.Add(codeTypeDeclaration);
} else {
namespaceDeclarations.Peek().Types.Add(codeTypeDeclaration);
}
currentTypeDeclaration = oldTypeDeclaration;
return null;
}