Added ability to order the execution of dictionary adapter behaviors.
[castle.git] / Experiments / Attic / MVC / Castle.MVC / Resource.cs
blob8b6eecbf4800c0367661de36e6bc051666dcd949
1 #region Apache Notice
2 /*****************************************************************************
3 *
4 * Castle.MVC
5 *
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
9 *
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 ********************************************************************************/
19 #endregion
21 #region Autors
23 /************************************************
24 * Gilles Bayon (Inspired by the UIP V2)
25 *************************************************/
26 #endregion
28 #region Using
30 using System;
31 using System.Resources;
32 using System.Reflection;
33 using System.IO;
34 #endregion
37 namespace Castle.MVC
39 /// <summary>
40 /// Access to resource data.
41 /// </summary>
42 public class Resource
45 #region Fields
47 private const string RESOURCE_FILENAME = ".castle.mvc";//RESOURCE_FILENAME = "Castle.MVC";
49 private static Resource _internalResource = new Resource();
50 private ResourceManager _resourceManager= null;
52 #endregion
54 #region Constructor
56 /// <summary>
57 /// Constructor.
58 /// </summary>
59 public Resource()
61 _resourceManager = new ResourceManager(this.GetType().Namespace + RESOURCE_FILENAME, Assembly.GetExecutingAssembly());
63 #endregion
65 #region Properties
67 /// <summary>
68 /// Gets a resource manager for the assembly resource file.
69 /// </summary>
70 public static Resource ResourceManager
72 get
74 return _internalResource;
80 /// <summary>
81 /// Gets the message with the specified key from the assembly resource file.
82 /// </summary>
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 ]
87 get
89 return _resourceManager.GetString( key, System.Globalization.CultureInfo.CurrentUICulture );
92 #endregion
94 #region Methods
96 /// <summary>
97 /// Gets a resource stream.
98 /// </summary>
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);
106 /// <summary>
107 /// Formats a message stored in the assembly resource file.
108 /// </summary>
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 );
116 #endregion
119 /// <summary>
120 /// Class used to expose constants that represent keys in the resource file.
121 /// </summary>
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";