1 // Copyright 2004-2007 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
18 using System
.Collections
;
21 /// Contract for SubSystem that wishes to keep and coordinate
22 /// component registration.
24 public interface INamingSubSystem
: ISubSystem
27 /// Implementors should register the key and service pointing
28 /// to the specified handler
30 /// <param name="key"></param>
31 /// <param name="handler"></param>
32 void Register(String key
, IHandler handler
);
35 /// Unregister the handler by the given key
37 /// <param name="key"></param>
38 void UnRegister(String key
);
41 /// Unregister the handler by the given service
43 /// <param name="service"></param>
44 void UnRegister(Type service
);
47 /// Returns true if there is a component registered
48 /// for the specified key
50 /// <param name="key"></param>
51 /// <returns></returns>
52 bool Contains(String key
);
55 /// Returns true if there is a component registered
56 /// for the specified service
58 /// <param name="service"></param>
59 /// <returns></returns>
60 bool Contains(Type service
);
63 /// Returns the number of components registered.
65 int ComponentCount { get; }
68 /// Returns the <see cref="IHandler"/> associated with
69 /// the specified key.
71 /// <param name="key"></param>
72 /// <returns></returns>
73 IHandler
GetHandler(String key
);
76 /// Returns an array of <see cref="IHandler"/> that
77 /// satisfies the specified query.
79 /// <param name="query"></param>
80 /// <returns></returns>
81 IHandler
[] GetHandlers(String query
);
84 /// Returns the <see cref="IHandler"/> associated with
85 /// the specified service.
87 IHandler
GetHandler(Type service
);
90 /// Returns the <see cref="IHandler"/> associated with
91 /// the specified key with the service type.
93 /// It is expected that this will be used mainly to resolve a generic service
97 IHandler
GetHandler(string key
, Type service
);
100 /// Returns an array of <see cref="IHandler"/> associated with
101 /// the specified service.
103 /// <param name="service"></param>
104 /// <returns></returns>
105 IHandler
[] GetHandlers(Type service
);
108 /// Returns all <see cref="IHandler"/> registered.
110 /// <returns></returns>
111 IHandler
[] GetHandlers();
114 /// Return <see cref="IHandler"/>s where components are compatible
115 /// with the specified service.
117 /// <param name="service"></param>
118 /// <returns></returns>
119 IHandler
[] GetAssignableHandlers(Type service
);
122 /// Associates a <see cref="IHandler"/> with
123 /// the specified service
125 IHandler
this[Type service
] { set; }
128 /// Associates a <see cref="IHandler"/> with
129 /// the specified key
131 IHandler
this[String key
] { set; }
134 /// List of handler by key
136 IDictionary
GetKey2Handler();
139 /// List of handler by service
141 IDictionary
GetService2Handler();