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
.SubSystems
.Naming
20 /// Alternative <see cref="INamingSubSystem"/> implementation.
21 /// Extends the default implementation replacing the
22 /// key support with a more complete ComponentName. Supports
26 /// The user must register components using the following construction
28 /// service:properties
30 /// Where properties is a list of key value pairs (comma separated). Example:
32 /// protocol:secure=true,version=1.2
34 /// The user can then query for components using the same construction:
36 /// protocol:secure=true
44 public class NamingPartsSubSystem
: DefaultNamingSubSystem
46 private BinaryTreeComponentName tree
;
48 public NamingPartsSubSystem()
50 tree
= new BinaryTreeComponentName();
53 private ComponentName
ToComponentName(String key
)
55 return new ComponentName(key
);
58 public override bool Contains(String key
)
60 return tree
.Contains(ToComponentName(key
));
63 public override void UnRegister(String key
)
65 tree
.Remove(ToComponentName(key
));
68 public override IHandler
GetHandler(String key
)
70 return tree
.GetHandler(ToComponentName(key
));
73 public override IHandler
[] GetHandlers(String query
)
75 return tree
.GetHandlers(ToComponentName(query
));
78 public override IHandler
[] GetHandlers()
83 public override IHandler
this[String key
]
85 set { tree.Add(ToComponentName(key), value); }
88 public override int ComponentCount
90 get { return tree.Count; }