2 /*****************************************************************************
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ********************************************************************************/
23 /************************************************
24 * Gilles Bayon (Inspired by the UIP V2)
25 *************************************************/
31 using System
.Resources
;
32 using System
.Reflection
;
40 /// Access to resource data.
47 private const string RESOURCE_FILENAME
= ".castle.mvc";//RESOURCE_FILENAME = "Castle.MVC";
49 private static Resource _internalResource
= new Resource();
50 private ResourceManager _resourceManager
= null;
61 _resourceManager
= new ResourceManager(this.GetType().Namespace
+ RESOURCE_FILENAME
, Assembly
.GetExecutingAssembly());
68 /// Gets a resource manager for the assembly resource file.
70 public static Resource ResourceManager
74 return _internalResource
;
81 /// Gets the message with the specified key from the assembly resource file.
83 /// <param name="key">Key of the item to retrieve from the resource file.</param>
84 /// <returns>Value from the resource file identified by the key.</returns>
85 public string this [ string key
]
89 return _resourceManager
.GetString( key
, System
.Globalization
.CultureInfo
.CurrentUICulture
);
97 /// Gets a resource stream.
99 /// <param name="name">The resource key.</param>
100 /// <returns>A resource stream.</returns>
101 public Stream
GetStream( string name
)
103 return Assembly
.GetExecutingAssembly().GetManifestResourceStream(this.GetType().Namespace
+ "." + name
);
107 /// Formats a message stored in the assembly resource file.
109 /// <param name="key">The resource key.</param>
110 /// <param name="format">The format arguments.</param>
111 /// <returns>A formatted string.</returns>
112 public string FormatMessage( string key
, params object[] format
)
114 return String
.Format( System
.Globalization
.CultureInfo
.CurrentCulture
, this[key
], format
);
120 /// Class used to expose constants that represent keys in the resource file.
122 internal abstract class MessageKeys
124 internal const string ViewAlreadyConfigured
= "ViewAlreadyConfigured";
125 internal const string CantFindCommandMapping
= "CantFindCommandMapping";
126 internal const string CantGetNextView
= "CantGetNextView";
127 internal const string DocumentNotValidated
= "DocumentNotValidated";