Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / Attributes / ResourceAttribute.cs
blobb2dac6247f83bafcc9131e56d053e0df4cefb23a
1 // Copyright 2004-2008 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.MonoRail.Framework
17 using System;
18 using Castle.MonoRail.Framework.Descriptors;
20 /// <summary>
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.
23 /// </summary>
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;
30 /// <summary>
31 /// Constructs a resource attribute, with the specified name, based
32 /// on the resource in a satellite assembly.
33 /// </summary>
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)
38 this.name = name;
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();
49 /// <summary>
50 /// Gets or sets the Name the of resource that will be available in the PropertyBag.
51 /// </summary>
52 /// <value>The name.</value>
53 public String Name
55 get { return name; }
56 set { name = value; }
59 /// <summary>
60 /// Gets or sets the Fully qualified name of the resource in the sattelite assembly.
61 /// </summary>
62 /// <value>The name of the resource.</value>
63 public String ResourceName
65 get { return resourceName; }
66 set { resourceName = value; }
69 /// <summary>
70 /// Gets or sets the name of the culture.
71 /// </summary>
72 /// <value>The name of the culture.</value>
73 public String CultureName
75 get { return cultureName; }
76 set { cultureName = value; }
79 /// <summary>
80 /// Gets or sets the name of the assembly.
81 /// </summary>
82 /// <value>The name of the assembly.</value>
83 public String AssemblyName
85 get { return assemblyName; }
86 set { assemblyName = value; }
89 /// <summary>
90 /// Gets or sets the type of the resource.
91 /// </summary>
92 /// <value>The type of the resource.</value>
93 public Type ResourceType
95 get { return resourceType; }
96 set { resourceType = value; }
99 /// <summary>
100 /// <see cref="IResourceDescriptorBuilder"/> implementation.
101 /// Builds the resource descriptors.
102 /// </summary>
103 /// <returns></returns>
104 public ResourceDescriptor[] BuildResourceDescriptors()
106 return new ResourceDescriptor[]
108 new ResourceDescriptor(resourceType,
109 name,
110 resourceName,
111 cultureName,
112 assemblyName)