MessageManager.cs :  » Persistence-Frameworks » iBATIS.NET » IBatisNet » DataAccess » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Persistence Frameworks » iBATIS.NET 
iBATIS.NET » IBatisNet » DataAccess » MessageManager.cs
#region Apache Notice
/*****************************************************************************
 * $Header: $
 * $Revision: 383115 $
 * $Date: 2006-03-04 15:21:51 +0100 (sam., 04 mars 2006) $
 * 
 * iBATIS.NET Data Mapper
 * Copyright (C) 2004 - Gilles Bayon
 *  
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 ********************************************************************************/
#endregion

#region Autors

/************************************************
* Gilles Bayon 
*************************************************/
#endregion 

#region Using

using System;
using System.Resources;
using System.Reflection; 
using System.IO;
#endregion 

namespace IBatisNet.DataAccess{
  /// <summary>
  /// Summary description for MessageManager.
  /// </summary>
  public class MessageManager
  {
    #region Fields

    private const string RESOURCE_FILENAME = "IBatisNet.DataAccess";
    private static MessageManager _internalManager = new MessageManager();
    private ResourceManager _resourceManager= null;

    #endregion 

    #region Constructor

    /// <summary>
    /// Constructor.
    /// </summary>
    public MessageManager()
    {
      _resourceManager = new ResourceManager(this.GetType().Namespace + RESOURCE_FILENAME, Assembly.GetExecutingAssembly());            
    }
    #endregion 

    #region Properties

    /// <summary>
    /// Gets a message manager for the assembly resource file.
    /// </summary>
    public static MessageManager Instance
    {
      get
      {
        return _internalManager;
      }
    }



    /// <summary>
    /// Gets the message with the specified key from the assembly resource file.
    /// </summary>
    /// <param name="key">Key of the item to retrieve from the resource file.</param>
    /// <returns>Value from the resource file identified by the key.</returns>
    public string this [ string key ]
    {
      get
      {
        return _resourceManager.GetString( key, System.Globalization.CultureInfo.CurrentUICulture );                                
      }
    }
    #endregion 

    #region Methods

    /// <summary>
    /// Gets a resource stream.
    /// </summary>
    /// <param name="name">The resource key.</param>
    /// <returns>A resource stream.</returns>
    public Stream GetStream( string name )
    {
      return Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType().Namespace + "." + name); 
    }

    /// <summary>
    /// Formats a message stored in the assembly resource file.
    /// </summary>
    /// <param name="key">The resource key.</param>
    /// <param name="format">The format arguments.</param>
    /// <returns>A formatted string.</returns>
    public string FormatMessage( string key, params object[] format )
    {
      return String.Format( System.Globalization.CultureInfo.CurrentCulture, this[key], format );  
    }
    #endregion 


    /// <summary>
    /// Class used to expose constants that represent keys in the resource file.
    /// </summary>
    internal abstract class MessageKeys
    {    
      internal const string ViewAlreadyConfigured = "ViewAlreadyConfigured";  
      internal const string CantFindCommandMapping = "CantFindCommandMapping";  
      internal const string CantGetNextView = "CantGetNextView";  
      internal const string DocumentNotValidated = "DocumentNotValidated";


    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.