本文整理汇总了C#中System.Collections.IDictionary.Find方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.IDictionary.Find方法的具体用法?C# System.Collections.IDictionary.Find怎么用?C# System.Collections.IDictionary.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.IDictionary
的用法示例。
在下文中一共展示了System.Collections.IDictionary.Find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlErrorLog
/// <summary>
/// Initializes a new instance of the <see cref="SqlErrorLog"/> class
/// using a dictionary of configured settings.
/// </summary>
public SqlErrorLog(IDictionary config)
{
if (config == null)
throw new ArgumentNullException("config");
var connectionString = ConnectionStringHelper.GetConnectionString(config);
//
// If there is no connection string to use then throw an
// exception to abort construction.
//
if (connectionString.Length == 0)
throw new ApplicationException("Connection string is missing for the SQL error log.");
_connectionString = connectionString;
//
// Set the application name as this implementation provides
// per-application isolation over a single store.
//
var appName = config.Find("applicationName", string.Empty);
if (appName.Length > _maxAppNameLength)
{
throw new ApplicationException(string.Format(
"Application name is too long. Maximum length allowed is {0} characters.",
_maxAppNameLength.ToString("N0")));
}
ApplicationName = appName;
}
示例2: GetConnectionString
/// <summary>
/// Gets the connection string from the given configuration
/// dictionary.
/// </summary>
public static string GetConnectionString(IDictionary config)
{
Debug.Assert(config != null);
//
// First look for a connection string name that can be
// subsequently indexed into the <connectionStrings> section of
// the configuration to get the actual connection string.
//
string connectionStringName = config.Find("connectionStringName", string.Empty);
if (connectionStringName.Length > 0)
{
ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[connectionStringName];
if (settings == null)
return string.Empty;
return settings.ConnectionString ?? string.Empty;
}
//
// Connection string name not found so see if a connection
// string was given directly.
//
var connectionString = config.Find("connectionString", string.Empty);
if (connectionString.Length > 0)
return connectionString;
//
// As a last resort, check for another setting called
// connectionStringAppKey. The specifies the key in
// <appSettings> that contains the actual connection string to
// be used.
//
var connectionStringAppKey = config.Find("connectionStringAppKey", string.Empty);
return connectionStringAppKey.Length > 0
? ConfigurationManager.AppSettings[connectionStringAppKey]
: string.Empty;
}
示例3: XmlFileErrorLog
/// <summary>
/// Initializes a new instance of the <see cref="XmlFileErrorLog"/> class
/// using a dictionary of configured settings.
/// </summary>
public XmlFileErrorLog(IDictionary config)
{
if (config == null) throw new ArgumentNullException("config");
var logPath = config.Find("logPath", string.Empty);
if (logPath.Length == 0)
{
//
// For compatibility reasons with older version of this
// implementation, we also try "LogPath".
//
logPath = config.Find("LogPath", string.Empty);
if (logPath.Length == 0)
throw new ApplicationException("Log path is missing for the XML file-based error log.");
}
if (logPath.StartsWith("~/"))
logPath = MapPath(logPath);
_logPath = logPath;
}
示例4: SQLiteErrorLog
/// <summary>
/// Initializes a new instance of the <see cref="SQLiteErrorLog"/> class
/// using a dictionary of configured settings.
/// </summary>
public SQLiteErrorLog(IDictionary config)
{
if (config == null)
throw new ArgumentNullException("config");
string connectionString = ConnectionStringHelper.GetConnectionString(config, true);
//
// If there is no connection string to use then throw an
// exception to abort construction.
//
if (connectionString.Length == 0)
throw new ApplicationException("Connection string is missing for the SQLite error log.");
_connectionString = connectionString;
InitializeDatabase();
ApplicationName = config.Find("applicationName", string.Empty);
}
示例5: MemoryErrorLog
/// <summary>
/// Initializes a new instance of the <see cref="MemoryErrorLog"/> class
/// using a dictionary of configured settings.
/// </summary>
public MemoryErrorLog(IDictionary config)
{
if (config == null)
{
_size = DefaultSize;
}
else
{
var sizeString = config.Find("size", string.Empty);
if (sizeString.Length == 0)
{
_size = DefaultSize;
}
else
{
_size = Convert.ToInt32(sizeString, CultureInfo.InvariantCulture);
_size = Math.Max(0, Math.Min(MaximumSize, _size));
}
}
}
示例6: GetConnectionStringProviderName
/// <summary>
/// Gets the provider name from the named connection string (if supplied)
/// from the given configuration dictionary.
/// </summary>
public static string GetConnectionStringProviderName(IDictionary config)
{
Debug.Assert(config != null);
//
// First look for a connection string name that can be
// subsequently indexed into the <connectionStrings> section of
// the configuration to get the actual connection string.
//
var connectionStringName = config.Find("connectionStringName", string.Empty);
if (connectionStringName.Length == 0)
return string.Empty;
var settings = ConfigurationManager.ConnectionStrings[connectionStringName];
if (settings == null)
return string.Empty;
return settings.ProviderName ?? string.Empty;
}