Added testcase for generic registrations and a workaround for the CLR GetInterfaces...
[castle.git] / InversionOfControl / Castle.MicroKernel / Registration / Parameter.cs
blob3c40e88a0006b3a9f584eab41f5d59cdc642f77a
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 Castle.MicroKernel.Registration
17 using System;
18 using Castle.Core.Configuration;
20 /// <summary>
21 /// Represents a configuration parameter.
22 /// </summary>
23 public class Parameter
25 private readonly String key;
26 private readonly String value;
27 private readonly IConfiguration configNode;
29 internal Parameter(String key, String value)
31 this.key = key;
32 this.value = value;
35 internal Parameter(String key, IConfiguration configNode)
37 this.key = key;
38 this.configNode = configNode;
41 /// <summary>
42 /// Gets the parameter key.
43 /// </summary>
44 public string Key
46 get { return key; }
49 /// <summary>
50 /// Gets the parameter value.
51 /// </summary>
52 public String Value
54 get { return value; }
57 /// <summary>
58 /// Gets the parameter configuration.
59 /// </summary>
60 public IConfiguration ConfigNode
62 get { return configNode; }
65 /// <summary>
66 /// Create a <see cref="ParameterKey"/> with key.
67 /// </summary>
68 /// <param name="key">The parameter key.</param>
69 /// <returns>The new <see cref="ParameterKey"/></returns>
70 public static ParameterKey ForKey(String key)
72 return new ParameterKey(key);
76 /// <summary>
77 /// Represents a parameter key.
78 /// </summary>
79 public class ParameterKey
81 private readonly String name;
83 internal ParameterKey(String name)
85 this.name = name;
88 /// <summary>
89 /// The parameter key name.
90 /// </summary>
91 public string Name
93 get { return name; }
96 /// <summary>
97 /// Builds the <see cref="Parameter"/> with key/value.
98 /// </summary>
99 /// <param name="value">The parameter value.</param>
100 /// <returns>The new <see cref="Parameter"/></returns>
101 public Parameter Eq(String value)
103 return new Parameter(name, value);
106 /// <summary>
107 /// Builds the <see cref="Parameter"/> with key/config.
108 /// </summary>
109 /// <param name="configNode">The parameter configuration.</param>
110 /// <returns>The new <see cref="Parameter"/></returns>
111 public Parameter Eq(IConfiguration configNode)
113 return new Parameter(name, configNode);