Added container accessor to Castle.Core
[castle.git] / InversionOfControl / Castle.MicroKernel / SubSystems / Naming / INamingSubSystem.cs
blob7980a16628e66e89a5c4849402c9818fc0a3b83a
1 // Copyright 2004-2007 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
17 using System;
18 using System.Collections;
20 /// <summary>
21 /// Contract for SubSystem that wishes to keep and coordinate
22 /// component registration.
23 /// </summary>
24 public interface INamingSubSystem : ISubSystem
26 /// <summary>
27 /// Implementors should register the key and service pointing
28 /// to the specified handler
29 /// </summary>
30 /// <param name="key"></param>
31 /// <param name="handler"></param>
32 void Register(String key, IHandler handler);
34 /// <summary>
35 /// Unregister the handler by the given key
36 /// </summary>
37 /// <param name="key"></param>
38 void UnRegister(String key);
40 /// <summary>
41 /// Unregister the handler by the given service
42 /// </summary>
43 /// <param name="service"></param>
44 void UnRegister(Type service);
46 /// <summary>
47 /// Returns true if there is a component registered
48 /// for the specified key
49 /// </summary>
50 /// <param name="key"></param>
51 /// <returns></returns>
52 bool Contains(String key);
54 /// <summary>
55 /// Returns true if there is a component registered
56 /// for the specified service
57 /// </summary>
58 /// <param name="service"></param>
59 /// <returns></returns>
60 bool Contains(Type service);
62 /// <summary>
63 /// Returns the number of components registered.
64 /// </summary>
65 int ComponentCount { get; }
67 /// <summary>
68 /// Returns the <see cref="IHandler"/> associated with
69 /// the specified key.
70 /// </summary>
71 /// <param name="key"></param>
72 /// <returns></returns>
73 IHandler GetHandler(String key);
75 /// <summary>
76 /// Returns an array of <see cref="IHandler"/> that
77 /// satisfies the specified query.
78 /// </summary>
79 /// <param name="query"></param>
80 /// <returns></returns>
81 IHandler[] GetHandlers(String query);
83 /// <summary>
84 /// Returns the <see cref="IHandler"/> associated with
85 /// the specified service.
86 /// </summary>
87 IHandler GetHandler(Type service);
89 /// <summary>
90 /// Returns the <see cref="IHandler"/> associated with
91 /// the specified key with the service type.
92 /// <remarks>
93 /// It is expected that this will be used mainly to resolve a generic service
94 /// by its key.
95 /// </remarks>
96 /// </summary>
97 IHandler GetHandler(string key, Type service);
99 /// <summary>
100 /// Returns an array of <see cref="IHandler"/> associated with
101 /// the specified service.
102 /// </summary>
103 /// <param name="service"></param>
104 /// <returns></returns>
105 IHandler[] GetHandlers(Type service);
107 /// <summary>
108 /// Returns all <see cref="IHandler"/> registered.
109 /// </summary>
110 /// <returns></returns>
111 IHandler[] GetHandlers();
113 /// <summary>
114 /// Return <see cref="IHandler"/>s where components are compatible
115 /// with the specified service.
116 /// </summary>
117 /// <param name="service"></param>
118 /// <returns></returns>
119 IHandler[] GetAssignableHandlers(Type service);
121 /// <summary>
122 /// Associates a <see cref="IHandler"/> with
123 /// the specified service
124 /// </summary>
125 IHandler this[Type service] { set; }
127 /// <summary>
128 /// Associates a <see cref="IHandler"/> with
129 /// the specified key
130 /// </summary>
131 IHandler this[String key] { set; }
133 /// <summary>
134 /// List of handler by key
135 /// </summary>
136 IDictionary GetKey2Handler();
138 /// <summary>
139 /// List of handler by service
140 /// </summary>
141 IDictionary GetService2Handler();