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
.MicroKernel
.Registration
18 using System
.Collections
;
21 public abstract class AbstractPropertyDescriptor
<S
> : ComponentDescriptor
<S
>
23 private readonly Property
[] properties
;
24 private readonly IDictionary dictionary
;
26 protected AbstractPropertyDescriptor(params Property
[] properties
)
28 this.properties
= properties
;
31 protected AbstractPropertyDescriptor(IDictionary dictionary
)
33 this.dictionary
= dictionary
;
36 protected internal override void ApplyToModel(IKernel kernel
, ComponentModel model
)
38 if (dictionary
!= null)
40 foreach(DictionaryEntry property
in dictionary
)
42 ApplyProperty(kernel
, model
, property
.Key
.ToString(), property
.Value
, null);
45 else if (properties
!= null)
47 foreach(Property property
in properties
)
49 ApplyProperty(kernel
, model
, property
.Key
, property
.Value
, property
);
54 protected abstract void ApplyProperty(IKernel kernel
, ComponentModel model
,
55 String key
, Object
value, Property property
);