当前位置: 首页>>代码示例>>C#>>正文


C# System.Collections.IDictionary.Find方法代码示例

本文整理汇总了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;
        }
开发者ID:ramsenthil18,项目名称:elmah,代码行数:38,代码来源:SqlErrorLog.cs

示例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;
        }
开发者ID:clearwavebuild,项目名称:elmah,代码行数:47,代码来源:ConnectionStringHelper.cs

示例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;
        }
开发者ID:AkosLukacs,项目名称:ElmahMod,代码行数:28,代码来源:XmlFileErrorLog.cs

示例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);
        }
开发者ID:boena,项目名称:elmah-with-custom-data,代码行数:25,代码来源:SQLiteErrorLog.cs

示例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));
                }
            }
        }
开发者ID:tomstaijen,项目名称:Elmah,代码行数:25,代码来源:MemoryErrorLog.cs

示例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;
        }
开发者ID:clearwavebuild,项目名称:elmah,代码行数:26,代码来源:ConnectionStringHelper.cs


注:本文中的System.Collections.IDictionary.Find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。