1
// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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 Castle
.ActiveRecord
.Framework
.Internal
18 using System
.Collections
.Generic
;
19 using System
.Reflection
;
22 /// Dispatches the extension invocations to the inner extension list.
24 public sealed class ModelBuilderExtensionComposite
: IModelBuilderExtension
26 private readonly IList
<IModelBuilderExtension
> extensions
;
29 /// Initializes a new instance of the <see cref="ModelBuilderExtensionComposite"/> class.
31 /// <param name="extensions">The extensions.</param>
32 public ModelBuilderExtensionComposite(IList
<IModelBuilderExtension
> extensions
)
34 this.extensions
= extensions
;
38 /// Dispatches the call to the extensions.
40 /// <param name="type">The type.</param>
41 /// <param name="model">The model.</param>
42 public void ProcessClass(Type type
, ActiveRecordModel model
)
44 foreach(IModelBuilderExtension extension
in extensions
)
46 extension
.ProcessClass(type
, model
);
51 /// Dispatches the call to the extensions.
53 /// <param name="pi">The property info reflection object.</param>
54 /// <param name="model">The model.</param>
55 public void ProcessProperty(PropertyInfo pi
, ActiveRecordModel model
)
57 foreach(IModelBuilderExtension extension
in extensions
)
59 extension
.ProcessProperty(pi
, model
);
64 /// Dispatches the call to the extensions.
66 /// <param name="fi">The field info reflection object.</param>
67 /// <param name="model">The model.</param>
68 public void ProcessField(FieldInfo fi
, ActiveRecordModel model
)
70 foreach(IModelBuilderExtension extension
in extensions
)
72 extension
.ProcessField(fi
, model
);
77 /// Dispatches the call to the extensions.
79 /// <param name="pi">The property info reflection object.</param>
80 /// <param name="belongsToModel">The belongs to model.</param>
81 /// <param name="model">The model.</param>
82 public void ProcessBelongsTo(PropertyInfo pi
, BelongsToModel belongsToModel
, ActiveRecordModel model
)
84 foreach(IModelBuilderExtension extension
in extensions
)
86 extension
.ProcessBelongsTo(pi
, belongsToModel
, model
);
91 /// Dispatches the call to the extensions.
93 /// <param name="pi">The property info reflection object.</param>
94 /// <param name="hasManyModel">The has many model.</param>
95 /// <param name="model">The model.</param>
96 public void ProcessHasMany(PropertyInfo pi
, HasManyModel hasManyModel
, ActiveRecordModel model
)
98 foreach(IModelBuilderExtension extension
in extensions
)
100 extension
.ProcessHasMany(pi
, hasManyModel
, model
);
105 /// Dispatches the call to the extensions.
107 /// <param name="pi">The property info reflection object.</param>
108 /// <param name="hasManyModel">The has many model.</param>
109 /// <param name="model">The model.</param>
110 public void ProcessHasManyToAny(PropertyInfo pi
, HasManyToAnyModel hasManyModel
, ActiveRecordModel model
)
112 foreach(IModelBuilderExtension extension
in extensions
)
114 extension
.ProcessHasManyToAny(pi
, hasManyModel
, model
);
119 /// Dispatches the call to the extensions.
121 /// <param name="pi">The property info reflection object.</param>
122 /// <param name="hasAndBelongManyModel">The has and belong many model.</param>
123 /// <param name="model">The model.</param>
124 public void ProcessHasAndBelongsToMany(PropertyInfo pi
, HasAndBelongsToManyModel hasAndBelongManyModel
,
125 ActiveRecordModel model
)
127 foreach(IModelBuilderExtension extension
in extensions
)
129 extension
.ProcessHasAndBelongsToMany(pi
, hasAndBelongManyModel
, model
);