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
.Descriptors
20 /// Represents a resource configuration associated with a controller.
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
;
31 /// Initializes a new instance of the <see cref="ResourceDescriptor"/> class.
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
;
43 this.resourceName
= resourceName
;
44 this.cultureName
= cultureName
;
45 this.assemblyName
= assemblyName
;
49 /// Gets the type that has the resource.
51 /// <value>The type that has the resource.</value>
52 public Type ResourceType
54 get { return resourceType; }
60 /// <value>The name.</value>
67 /// Gets the name of the resource.
69 /// <value>The name of the resource.</value>
70 public string ResourceName
72 get { return resourceName; }
76 /// Gets the name of the culture.
78 /// <value>The name of the culture.</value>
79 public string CultureName
81 get { return cultureName; }
85 /// Gets the name of the assembly.
87 /// <value>The name of the assembly.</value>
88 public string AssemblyName
90 get { return assemblyName; }
94 /// Equalses the specified resource descriptor.
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;
110 /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
112 /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
114 /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
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
);
124 /// Serves as a hash function for a particular type.
127 /// A hash code for the current <see cref="T:System.Object"/>.
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);