Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / Descriptors / ResourceDescriptor.cs
blob96d88f2d2f202c6cfbb40dc63ee13fac27a30124
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.Descriptors
17 using System;
19 /// <summary>
20 /// Represents a resource configuration associated with a controller.
21 /// </summary>
22 public class ResourceDescriptor : IEquatable<ResourceDescriptor>
24 private readonly Type resourceType;
25 private readonly string name;
26 private readonly string resourceName;
27 private readonly string cultureName;
28 private readonly string assemblyName;
30 /// <summary>
31 /// Initializes a new instance of the <see cref="ResourceDescriptor"/> class.
32 /// </summary>
33 /// <param name="resourceType">Type that has the resource.</param>
34 /// <param name="name">The name.</param>
35 /// <param name="resourceName">Name of the resource.</param>
36 /// <param name="cultureName">Name of the culture.</param>
37 /// <param name="assemblyName">Name of the assembly.</param>
38 public ResourceDescriptor(Type resourceType, string name, string resourceName,
39 string cultureName, string assemblyName)
41 this.resourceType = resourceType;
42 this.name = name;
43 this.resourceName = resourceName;
44 this.cultureName = cultureName;
45 this.assemblyName = assemblyName;
48 /// <summary>
49 /// Gets the type that has the resource.
50 /// </summary>
51 /// <value>The type that has the resource.</value>
52 public Type ResourceType
54 get { return resourceType; }
57 /// <summary>
58 /// Gets the name.
59 /// </summary>
60 /// <value>The name.</value>
61 public string Name
63 get { return name; }
66 /// <summary>
67 /// Gets the name of the resource.
68 /// </summary>
69 /// <value>The name of the resource.</value>
70 public string ResourceName
72 get { return resourceName; }
75 /// <summary>
76 /// Gets the name of the culture.
77 /// </summary>
78 /// <value>The name of the culture.</value>
79 public string CultureName
81 get { return cultureName; }
84 /// <summary>
85 /// Gets the name of the assembly.
86 /// </summary>
87 /// <value>The name of the assembly.</value>
88 public string AssemblyName
90 get { return assemblyName; }
93 /// <summary>
94 /// Equalses the specified resource descriptor.
95 /// </summary>
96 /// <param name="resourceDescriptor">The resource descriptor.</param>
97 /// <returns></returns>
98 public bool Equals(ResourceDescriptor resourceDescriptor)
100 if (resourceDescriptor == null) return false;
101 if (!Equals(resourceType, resourceDescriptor.resourceType)) return false;
102 if (!Equals(name, resourceDescriptor.name)) return false;
103 if (!Equals(resourceName, resourceDescriptor.resourceName)) return false;
104 if (!Equals(cultureName, resourceDescriptor.cultureName)) return false;
105 if (!Equals(assemblyName, resourceDescriptor.assemblyName)) return false;
106 return true;
109 /// <summary>
110 /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
111 /// </summary>
112 /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
113 /// <returns>
114 /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
115 /// </returns>
116 /// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
117 public override bool Equals(object obj)
119 if (ReferenceEquals(this, obj)) return true;
120 return Equals(obj as ResourceDescriptor);
123 /// <summary>
124 /// Serves as a hash function for a particular type.
125 /// </summary>
126 /// <returns>
127 /// A hash code for the current <see cref="T:System.Object"/>.
128 /// </returns>
129 public override int GetHashCode()
131 int result = resourceType != null ? resourceType.GetHashCode() : 0;
132 result = 29 * result + name.GetHashCode();
133 result = 29 * result + resourceName.GetHashCode();
134 result = 29 * result + (cultureName != null ? cultureName.GetHashCode() : 0);
135 result = 29 * result + (assemblyName != null ? assemblyName.GetHashCode() : 0);
136 return result;