internal static void CheckArrayParameter( ref string[] param, bool checkForNull, bool checkIfEmpty, bool checkForCommas, int maxSize, string paramName) { if (param == null) { throw new ArgumentNullException(paramName); } if (param.Length < 1) { throw new ArgumentException(MsgManager.GetMsg(ErrRes.PROVIDER_PARAMETER_ARRAY_EMPTY, paramName)); } Hashtable hashtable = new Hashtable(param.Length); for (int index = param.Length - 1; index >= 0; --index) { Util.CheckParameter(ref param[index], checkForNull, checkIfEmpty, checkForCommas, maxSize, paramName + "[ " + index.ToString((IFormatProvider)CultureInfo.InvariantCulture) + " ]"); if (hashtable.Contains((object)param[index])) { throw new ArgumentException(MsgManager.GetMsg(ErrRes.PROVIDER_PARAMETER_DUPLICATE_ARRAY_ELEMENT, paramName)); } hashtable.Add((object)param[index], (object)param[index]); } }
internal static void CheckParameter( ref string param, bool checkForNull, bool checkIfEmpty, bool checkForCommas, int maxSize, string paramName) { if (param == null) { if (checkForNull) { throw new ArgumentNullException(paramName); } } else { if (checkIfEmpty && param.Length < 1) { throw new ArgumentException(MsgManager.GetMsg(ErrRes.PROVIDER_PARAMETER_CANNOT_BE_EMPTY, paramName)); } if (maxSize > 0 && param.Length > maxSize) { throw new ArgumentException(MsgManager.GetMsg(ErrRes.PROVIDER_PARAMETER_TOO_LONG, paramName, maxSize.ToString((IFormatProvider)CultureInfo.InvariantCulture))); } if (checkForCommas && param.Contains(",")) { throw new ArgumentException(MsgManager.GetMsg(ErrRes.PROVIDER_PARAMETER_CANNOT_CONTAIN_COMMA, paramName)); } } }
internal OracleConnectionHolder(string connectionString) { try { this.m_Connection = new OracleConnection(connectionString); } catch (ArgumentException ex) { throw new ArgumentException(MsgManager.GetMsg(ErrRes.PROVIDER_ODP_CONNECTION_STRING_ERROR), nameof(connectionString), (Exception)ex); } }
private static string GetResourceStringForCultureName(string key, string cultureName) { if (!MsgManager.m_CultureToResourceStringMap.ContainsKey(cultureName)) { return((string)null); } if (MsgManager.m_CultureToResourceStringMap[cultureName] == null) { MsgManager.ExtractEmbeddedResourceStringsForCultureName(cultureName); } return(MsgManager.m_CultureToResourceStringMap[cultureName]?.GetString(key)); }
internal static void CheckForUnrecognizedAttribute(NameValueCollection config) { if (config.Count <= 0) { return; } string key = config.GetKey(0); if (!string.IsNullOrEmpty(key)) { throw new ProviderException(MsgManager.GetMsg(ErrRes.PROVIDER_UNRECOGNIZED_ATTRIBUTE, key)); } }
internal static string ReadAndVerifyApplicationName(NameValueCollection config) { string defaultAppName = config["applicationName"]; if (string.IsNullOrEmpty(defaultAppName)) { defaultAppName = Util.GetDefaultAppName(); } if (defaultAppName.Length > 256) { throw new ProviderException(MsgManager.GetMsg(ErrRes.PROVIDER_APPLICATION_NAME_TOO_LONG)); } return(defaultAppName); }
internal static string GetMsg(int errorcode, params string[] args) { string str = (string)null; string format1 = MsgManager.GetString(Convert.ToString(errorcode), Thread.CurrentThread.CurrentCulture); if (format1 != null) { str = string.Format(format1, (object[])args); } else { string format2; if ((format2 = MsgManager.GetString(MsgManager.DEFAULT_MESSAGE_NUMBER, Thread.CurrentThread.CurrentCulture)) != null) { str = string.Format(format2, (object)errorcode); } } return(str); }
internal static string GetString(string key, CultureInfo culture) { try { foreach (string cultureName in culture.NextMatchingNonInvariantCulture().Where <string>((Func <string, bool>)(cultureName => MsgManager.m_CultureToResourceStringMap.ContainsKey(cultureName)))) { string stringForCultureName = MsgManager.GetResourceStringForCultureName(key, cultureName); if (stringForCultureName != null) { return(stringForCultureName); } } return(MsgManager.GetResourceStringForCultureName(key, MsgManager.DFEAULT_RESOURCE_NAME)); } catch { return((string)null); } }
internal static string ReadConnectionString(NameValueCollection config) { string index = config["connectionStringName"]; if (string.IsNullOrEmpty(index)) { throw new ProviderException(MsgManager.GetMsg(ErrRes.PROVIDER_CONNECTION_NAME_NOT_SPECIFIED)); } ConnectionStringSettings connectionString = (WebConfigurationManager.GetSection("connectionStrings") as ConnectionStringsSection).ConnectionStrings[index]; string str = string.Empty; if (connectionString != null) { str = connectionString.ConnectionString; } if (string.IsNullOrEmpty(str)) { throw new ProviderException(MsgManager.GetMsg(ErrRes.PROVIDER_CONNECTION_STRING_NOT_FOUND, index)); } return(str); }