Exemplo n.º 1
0
		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);
		}
Exemplo n.º 2
0
		public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
		{
			TypeDeclaration oldTypeDeclaration = currentTypeDeclaration;
			this.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));
				}
			}
			
			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;
		}