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
.MonoRail
.Framework
18 using Castle
.MonoRail
.Framework
.Descriptors
;
21 /// Declares that for the specified class or method, the given resource file should be
22 /// loaded and set available in the PropertyBag with the specified name.
24 [AttributeUsage(AttributeTargets
.Class
| AttributeTargets
.Method
, AllowMultiple
=true, Inherited
=true), Serializable
]
25 public class ResourceAttribute
: Attribute
, IResourceDescriptorBuilder
27 private String name
, resourceName
, cultureName
, assemblyName
;
28 private Type resourceType
;
31 /// Constructs a resource attribute, with the specified name, based
32 /// on the resource in a satellite assembly.
34 /// <param name="name">Name the resource will be available as in the PropertyBag</param>
35 /// <param name="resourceName">Fully qualified name of the resource in the sattelite assembly</param>
36 public ResourceAttribute(String name
, String resourceName
)
39 this.resourceName
= resourceName
;
41 if (resourceName
.IndexOf(',') > 0)
43 String
[] pair
= resourceName
.Split(',');
44 this.resourceName
= pair
[0].Trim();
45 assemblyName
= pair
[1].Trim();
50 /// Gets or sets the Name the of resource that will be available in the PropertyBag.
52 /// <value>The name.</value>
60 /// Gets or sets the Fully qualified name of the resource in the sattelite assembly.
62 /// <value>The name of the resource.</value>
63 public String ResourceName
65 get { return resourceName; }
66 set { resourceName = value; }
70 /// Gets or sets the name of the culture.
72 /// <value>The name of the culture.</value>
73 public String CultureName
75 get { return cultureName; }
76 set { cultureName = value; }
80 /// Gets or sets the name of the assembly.
82 /// <value>The name of the assembly.</value>
83 public String AssemblyName
85 get { return assemblyName; }
86 set { assemblyName = value; }
90 /// Gets or sets the type of the resource.
92 /// <value>The type of the resource.</value>
93 public Type ResourceType
95 get { return resourceType; }
96 set { resourceType = value; }
100 /// <see cref="IResourceDescriptorBuilder"/> implementation.
101 /// Builds the resource descriptors.
103 /// <returns></returns>
104 public ResourceDescriptor
[] BuildResourceDescriptors()
106 return new ResourceDescriptor
[]
108 new ResourceDescriptor(resourceType
,