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
.Generic
;
21 /// Represents a service override.
23 public class ServiceOverride
: Property
25 private readonly Type type
;
27 internal ServiceOverride(String key
, object value)
32 internal ServiceOverride(String key
, object value, Type type
)
39 /// Gets the optional value type specifier.
47 /// Creates a <see cref="ServiceOverrideKey"/> with key.
49 /// <param name="key">The service override key.</param>
50 /// <returns>The new <see cref="ServiceOverrideKey"/></returns>
51 public new static ServiceOverrideKey
ForKey(String key
)
53 return new ServiceOverrideKey(key
);
58 /// Represents a service override key.
60 public class ServiceOverrideKey
62 private readonly String name
;
64 internal ServiceOverrideKey(String name
)
70 /// Gets the service override key name.
78 /// Builds the <see cref="ServiceOverride"/> with key/value.
80 /// <param name="value">The service overeride value.</param>
81 /// <returns>The new <see cref="ServiceOverride"/></returns>
82 public ServiceOverride
Eq(String
value)
84 return new ServiceOverride(name
, value);
88 /// Builds the <see cref="ServiceOverride"/> with key/values.
90 /// <param name="value">The service overeride values.</param>
91 /// <returns>The new <see cref="ServiceOverride"/></returns>
92 public ServiceOverride
Eq(params String
[] value)
94 return new ServiceOverride(name
, value);
98 /// Builds the <see cref="ServiceOverride"/> with key/values.
100 /// <param name="value">The service overeride values.</param>
101 /// <returns>The new <see cref="ServiceOverride"/></returns>
102 /// <typeparam name="V">The value type.</typeparam>
103 public ServiceOverride Eq
<V
>(params String
[] value)
105 return new ServiceOverride(name
, value, typeof(V
));
109 /// Builds the <see cref="ServiceOverride"/> with key/values.
111 /// <param name="value">The service overeride values.</param>
112 /// <returns>The new <see cref="ServiceOverride"/></returns>
113 public ServiceOverride
Eq(IEnumerable
<String
> value)
115 return new ServiceOverride(name
, value);
119 /// Builds the <see cref="ServiceOverride"/> with key/values.
121 /// <param name="value">The service overeride values.</param>
122 /// <returns>The new <see cref="ServiceOverride"/></returns>
123 /// <typeparam name="V">The value type.</typeparam>
124 public ServiceOverride Eq
<V
>(IEnumerable
<String
> value)
126 return new ServiceOverride(name
, value, typeof(V
));