コード例 #1
0
        static EnvShowFormater()
        {
            m_NumberConvertMethods = new Hashtable();
            m_NumberConvertMethods.Add(typeof(double), new GetNumberStringHandler(GetDoubleString));
            m_NumberConvertMethods.Add(typeof(decimal), new GetNumberStringHandler(GetDecimalString));
            m_NumberConvertMethods.Add(typeof(Int16), new GetNumberStringHandler(GetInt16String));
            m_NumberConvertMethods.Add(typeof(Int32), new GetNumberStringHandler(GetInt32String));
            m_NumberConvertMethods.Add(typeof(Int64), new GetNumberStringHandler(GetInt64String));
            m_NumberConvertMethods.Add(typeof(float), new GetNumberStringHandler(GetFloatString));
            m_NumberConvertMethods.Add(typeof(ushort), new GetNumberStringHandler(GetUShortString));
            m_NumberConvertMethods.Add(typeof(ulong), new GetNumberStringHandler(GetULongString));
            m_NumberConvertMethods.Add(typeof(uint), new GetNumberStringHandler(GetUIntString));

            m_CurrencyConvertMethods = new Hashtable();
            m_CurrencyConvertMethods.Add(typeof(double), new GetCurrencyStringHandler(GetDoubleCurrencyString));
            m_CurrencyConvertMethods.Add(typeof(decimal), new GetCurrencyStringHandler(GetDecimalCurrencyString));
            m_CurrencyConvertMethods.Add(typeof(Int16), new GetCurrencyStringHandler(GetInt16CurrencyString));
            m_CurrencyConvertMethods.Add(typeof(Int32), new GetCurrencyStringHandler(GetInt32CurrencyString));
            m_CurrencyConvertMethods.Add(typeof(Int64), new GetCurrencyStringHandler(GetInt64CurrencyString));
            m_CurrencyConvertMethods.Add(typeof(float), new GetCurrencyStringHandler(GetFloatCurrencyString));
            m_CurrencyConvertMethods.Add(typeof(ushort), new GetCurrencyStringHandler(GetUshortCurrencyString));
            m_CurrencyConvertMethods.Add(typeof(ulong), new GetCurrencyStringHandler(GetULongCurrencyString));
            m_CurrencyConvertMethods.Add(typeof(uint), new GetCurrencyStringHandler(GetUintCurrencyString));

            m_NumberFormatProvider = FormatManager.GetFormatProvider();
            m_DateFormatProvider   = FormatManager.GetFormatProvider("DateTimeFormatProvider");
        }
コード例 #2
0
        private static IEnvFormatProvider GetProvider(String configSection, string providerName)
        {
            String nameOfProviderToFetch = providerName.ToLower(System.Globalization.CultureInfo.CurrentCulture);
            //ConfigurationSettings.GetConfig(configSection);
            IDictionary providers = ConfigurationManager.GetSection(configSection) as IDictionary;

            if (providers == null)
            {
                throw new ConfigurationErrorsException("配置文件有误");
            }
            XmlProvider provider = providers[nameOfProviderToFetch] as XmlProvider;

            if (provider == null)
            {
                throw new ConfigurationErrorsException("没有所要求的Provider");
            }

            try
            {
                IEnvFormatProvider providerType = Activator.CreateInstance(provider.ProviderType) as IEnvFormatProvider;

                if (providerType == null)
                {
                    throw new ConfigurationErrorsException("无法创建provider");
                }
                providerType.Initialize(provider.Properties);
                return(providerType);
            }
            catch (TargetInvocationException tiEx)
            {
                throw new ConfigurationErrorsException(tiEx.Message, tiEx);
            }
        }
コード例 #3
0
 public static IEnvFormatProvider GetFormatProvider()
 {
     if (object.Equals(m_Instance, null))
     {
         m_Instance = GetProvider("FormatProviders", "NumberProvider");
     }
     return(m_Instance);
 }
コード例 #4
0
ファイル: EnvConverter.cs プロジェクト: radtek/PhysicalCheck
 static EnvConverter()
 {
     m_NumberFormatProvider = FormatManager.GetFormatProvider();
     m_DateFormatProvider   = FormatManager.GetFormatProvider("DateTimeFormatProvider");
 }