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
.MonoRail
.Framework
19 using Castle
.MonoRail
.Framework
.Internal
;
22 /// Declares that for the specified class or method, the given resource file should be
23 /// loaded and set available in the PropertyBag with the specified name.
25 [AttributeUsage(AttributeTargets
.Class
| AttributeTargets
.Method
, AllowMultiple
=true, Inherited
=true), Serializable
]
26 public class ResourceAttribute
: Attribute
, IResourceDescriptorBuilder
28 private String name
, resourceName
, cultureName
, assemblyName
;
29 private Type resourceType
;
32 /// Constructs a resource attribute, with the specified name, based
33 /// on the resource in a satellite assembly.
35 /// <param name="name">Name the resource will be available as in the PropertyBag</param>
36 /// <param name="resourceName">Fully qualified name of the resource in the sattelite assembly</param>
37 public ResourceAttribute( String name
, String resourceName
)
40 this.resourceName
= resourceName
;
42 if (resourceName
.IndexOf(',') > 0)
44 String
[] pair
= resourceName
.Split(',');
45 this.resourceName
= pair
[0].Trim();
46 this.assemblyName
= pair
[1].Trim();
51 /// Gets or sets the Name the of resource that will be available in the PropertyBag.
53 /// <value>The name.</value>
61 /// Gets or sets the Fully qualified name of the resource in the sattelite assembly.
63 /// <value>The name of the resource.</value>
64 public String ResourceName
66 get { return resourceName; }
67 set { resourceName = value; }
71 /// Gets or sets the name of the culture.
73 /// <value>The name of the culture.</value>
74 public String CultureName
76 get { return cultureName; }
77 set { cultureName = value; }
81 /// Gets or sets the name of the assembly.
83 /// <value>The name of the assembly.</value>
84 public String AssemblyName
86 get { return assemblyName; }
87 set { assemblyName = value; }
91 /// Gets or sets the type of the resource.
93 /// <value>The type of the resource.</value>
94 public Type ResourceType
96 get { return resourceType; }
97 set { resourceType = value; }
101 /// <see cref="IResourceDescriptorBuilder"/> implementation.
102 /// Builds the resource descriptors.
104 /// <returns></returns>
105 public ResourceDescriptor
[] BuildResourceDescriptors()
107 return new ResourceDescriptor
[] { new ResourceDescriptor(resourceType
,