Added container accessor to Castle.Core
[castle.git] / Core / Castle.Core / Attributes / CastleComponent.cs
blob99c8db8f6435548a89e6fb6f38b3e3dd06f1a7eb
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.Core
17 using System;
19 /// <summary>
20 /// This attribute is usefull only when you want to register all components
21 /// on an assembly as a batch process.
22 /// By doing so, the batch register will look
23 /// for this attribute to distinguish components from other classes.
24 /// </summary>
25 [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)]
26 public class CastleComponentAttribute : LifestyleAttribute
28 private readonly Type service;
29 private readonly string key;
31 /// <summary>
32 /// Initializes a new instance of the <see cref="CastleComponentAttribute"/> class.
33 /// </summary>
34 /// <param name="key">The key.</param>
35 public CastleComponentAttribute(String key) : this(key, null)
39 /// <summary>
40 /// Initializes a new instance of the <see cref="CastleComponentAttribute"/> class.
41 /// </summary>
42 /// <param name="key">The key.</param>
43 /// <param name="service">The service.</param>
44 public CastleComponentAttribute(String key, Type service) : this(key, service, LifestyleType.Undefined)
48 /// <summary>
49 /// Initializes a new instance of the <see cref="CastleComponentAttribute"/> class.
50 /// </summary>
51 /// <param name="key">The key.</param>
52 /// <param name="service">The service.</param>
53 /// <param name="lifestyle">The lifestyle.</param>
54 public CastleComponentAttribute(String key, Type service, LifestyleType lifestyle) : base(lifestyle)
56 this.key = key;
57 this.service = service;
60 /// <summary>
61 /// Gets the service.
62 /// </summary>
63 /// <value>The service.</value>
64 public Type Service
66 get { return service; }
69 /// <summary>
70 /// Gets the key.
71 /// </summary>
72 /// <value>The key.</value>
73 public String Key
75 get { return key; }