Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / AspectSharp / AspectSharp.Lang / AST / Visitors / DepthFirstVisitor.cs
blob37e972f1a26afc79aa66d085a546185a2553847a
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace AspectSharp.Lang.AST.Visitors
17 using System;
19 /// <summary>
20 /// Summary description for AbstractDepthFirstVisitor.
21 /// </summary>
22 public class DepthFirstVisitor : IVisitor
24 public void Visit(INode node)
26 node.Accept(this);
29 public void Visit(INode[] nodes)
31 foreach(INode node in nodes)
33 Visit(node);
37 #region Depth Control Members
39 protected virtual bool EnterEngineConfiguration(EngineConfiguration conf)
41 return true;
44 protected virtual void LeaveEngineConfiguration(EngineConfiguration conf)
48 protected virtual bool EnterAspectDefinition(AspectDefinition aspect)
50 return true;
53 protected virtual void LeaveAspectDefinition(AspectDefinition aspect)
57 #endregion
59 #region IVisitor Members
61 public virtual void OnEngineConfiguration(EngineConfiguration conf)
63 if (EnterEngineConfiguration(conf))
65 conf.Imports.Accept(this);
66 conf.Mixins.Accept(this);
67 conf.Interceptors.Accept(this);
68 conf.Aspects.Accept(this);
70 LeaveEngineConfiguration(conf);
74 public virtual void OnImportDirective(ImportDirective import)
76 if (import.AssemblyReference != null)
78 OnAssemblyReference(import.AssemblyReference);
82 public virtual void OnGlobalInterceptorDeclaration(NodeCollectionBase dict)
84 Visit(dict.ToNodeArray());
87 public virtual void OnGlobalMixinDeclaration(NodeCollectionBase dict)
89 Visit(dict.ToNodeArray());
93 public virtual void OnExcludedTypes(TypeReferenceCollection types)
95 if (types.Count != 0)
97 Visit(types.ToNodeArray());
101 public virtual void OnAspectDefinition(AspectDefinition aspect)
103 if (EnterAspectDefinition(aspect))
105 OnTargetTypeDefinition(aspect.TargetType);
106 aspect.Mixins.Accept(this);
107 aspect.PointCuts.Accept(this);
109 LeaveAspectDefinition(aspect);
113 public virtual void OnTargetNamespace(String nameSpace)
117 public virtual void OnTargetTypeDefinition(TargetTypeDefinition targetType)
119 if (targetType.TargetStrategy == TargetStrategyEnum.SingleType)
121 OnTypeReferenceDefinition( targetType.SingleType );
123 else if (targetType.TargetStrategy == TargetStrategyEnum.Assignable)
125 OnTypeReferenceDefinition( targetType.AssignType );
127 else if (targetType.TargetStrategy == TargetStrategyEnum.Namespace)
129 OnTargetNamespace( targetType.NamespaceRoot );
130 OnExcludedTypes( targetType.Excludes );
132 else if (targetType.TargetStrategy == TargetStrategyEnum.Custom)
134 OnTypeReferenceDefinition( targetType.CustomMatcherType );
138 public virtual void OnPointCutDefinition(PointCutDefinition pointcut)
140 pointcut.Advices.Accept(this);
143 public virtual void OnTypeReferenceDefinition(TypeReference type)
145 if (type.AssemblyReference != null)
147 OnAssemblyReference(type.AssemblyReference);
151 public virtual void OnMixinDefinition(MixinDefinition mixin)
153 OnTypeReferenceDefinition(mixin.TypeReference);
156 public virtual void OnInterceptorDefinition(InterceptorDefinition interceptor)
158 OnTypeReferenceDefinition(interceptor.TypeReference);
161 public virtual void OnMixinEntryDefinition(MixinEntryDefinition mixin)
163 OnTypeReferenceDefinition(mixin.TypeReference);
166 public virtual void OnInterceptorEntryDefinition(InterceptorEntryDefinition interceptor)
168 OnTypeReferenceDefinition(interceptor.TypeReference);
171 public virtual void OnAssemblyReference(AssemblyReference assemblyReference)
176 #endregion