System.Data.Common.DbConnectionStringBuilder.ContainsKey(string)

Here are the examples of the csharp api class System.Data.Common.DbConnectionStringBuilder.ContainsKey(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

26 Examples 7

1. Example

View license
private T DefaultIfNotExists<T>(string name, T def)
        {
            if (!base.ContainsKey(name))
                return def;
            return (T) Convert.ChangeType(base[name], typeof (T));
        }

2. Example

View license
private T ThrowIfNotExists<T>(string name)
        {
            if (!base.ContainsKey(name))
                throw new FormatException(name + " value are missing in connection string");
            return (T) Convert.ChangeType(base[name], typeof (T));
        }

3. Example

View license
private string GetValueOrDefault(string key, string defaultValue = "")
        {
            key = key.ToLower();
            if (ContainsKey(key))
            {
                return (string) this[key];
            }

            return defaultValue;
        }

4. Example

View license
public static string GetConnectionStringWithoutProvider(string connStr)
        {
            var builder = new DbConnectionStringBuilder();
            builder.ConnectionString = connStr;
            if (builder.ContainsKey("provider"))
                builder.Remove("provider");
            return builder.ConnectionString;
        }

5. Example

Project: ALinq
Source File: Sql2000Provider.cs
View license
private string GetDatabaseName(string constr)
        {
            var builder = new DbConnectionStringBuilder { ConnectionString = constr };
            if (builder.ContainsKey("Initial Catalog"))
            {
                return (string)builder["Initial Catalog"];
            }
            if (builder.ContainsKey("Database"))
            {
                return (string)builder["Database"];
            }
            if (builder.ContainsKey("AttachDBFileName"))
            {
                return (string)builder["AttachDBFileName"];
            }
            if (builder.ContainsKey("Data Source") &&
                ((string)builder["Data Source"]).EndsWith(".sdf", StringComparison.OrdinalIgnoreCase))
            {
                return (string)builder["Data Source"];
            }
            return this.services.Model.DatabaseName;
        }

6. Example

Project: ALinq
Source File: Sql2005Provider.cs
View license
private string GetDatabaseName(string constr)
        {
            DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
            builder.ConnectionString = constr;
            if (builder.ContainsKey("Initial Catalog"))
            {
                return (string)builder["Initial Catalog"];
            }
            if (builder.ContainsKey("Database"))
            {
                return (string)builder["Database"];
            }
            if (builder.ContainsKey("AttachDBFileName"))
            {
                return (string)builder["AttachDBFileName"];
            }
            if (builder.ContainsKey("Data Source") &&
                ((string)builder["Data Source"]).EndsWith(".sdf", StringComparison.OrdinalIgnoreCase))
            {
                return (string)builder["Data Source"];
            }
            return services.Model.DatabaseName;
        }

7. Example

View license
bool System.Collections.IDictionary.Contains(object keyword) {
            return ContainsKey(ObjectToString(keyword));
        }

8. Example

View license
public bool ContainsKey(Keywords keyword)
		{
			return base.ContainsKey(GetKeyName(keyword));
		}

9. Example

Project: Elmah
Source File: ConnectionStringHelper.cs
View license
private static string GetDataSourceFilePath(DbConnectionStringBuilder builder, string connectionString)
        {
            builder.ConnectionString = connectionString;
            if (!builder.ContainsKey("Data Source"))
                throw new ArgumentException("A 'Data Source' parameter was expected in the supplied connection string, but it was not found.");
            string dataSource = builder["Data Source"].ToString();
            return ResolveDataSourceFilePath(dataSource);
        }

10. Example

Project: Elmah
Source File: ConnectionStringHelper.cs
View license
static string GetDataSourceFilePath(DbConnectionStringBuilder builder, string connectionString)
        {
            builder.ConnectionString = connectionString;
            if (!builder.ContainsKey("Data Source"))
                throw new ArgumentException("A 'Data Source' parameter was expected in the supplied connection string, but it was not found.");
            var dataSource = builder["Data Source"].ToString();
            return ResolveDataSourceFilePath(dataSource);
        }

11. Example

View license
private static string GetProvider(DbConnectionStringBuilder csb)
        {
            const string key = "provider";
            string provider = "System.Data.SqlClient"; // default factory provider

            if (csb.ContainsKey(key))
            {
                provider = csb[key].ToString();
                csb.Remove(key);
            }

            return provider;
        }

12. Example

View license
public override bool ContainsKey(string keyword)
		{
			keyword = keyword.ToUpper().Trim();
			if(_keywords.ContainsKey(keyword))
				return base.ContainsKey(_keywords[keyword]);
			return false;
		}

13. Example

View license
private static int? GetCommandTimeout(DbConnectionStringBuilder csb)
        {
            const string key = "CommandTimeout";

            int? value = null;
            if (csb.ContainsKey(key))
            {
                int iValue;
                if (Int32.TryParse(csb[key].ToString(), out iValue))
                {
                    // ignore negative values
                    if (iValue >= 0)
                    {
                        value = iValue;
                    }
                }
                csb.Remove(key);
            }
            
            return value;
        }

14. Example

View license
[MethodImpl(MethodImplOptions.Synchronized)]
        public void Open()
        {
            if (!p/n ..... /n //View Source file for more details /n }

15. Example

Project: PlayPass
Source File: FileQueueList.cs
View license
public void Initialize(string connectionString)
        {
            var parser = new DbConnectionStringBuilder {ConnectionString = connectionString};
            if (parser.ContainsKey("Data Source"))
                _skipFilePath = parser["Data Source"].ToString();
            else
            {
                var mediaStorageLocation = PlayOnSettings.GetMediaStorageLocation();
                if (mediaStorageLocation == "")
                    throw new Exception("Unable to find PlayLater's Media Storage Location");
                _skipFilePath = mediaStorageLocation;
            }
            if (!Directory.Exists(_skipFilePath))
                throw new Exception(String.Format("Queue List data path does not exists: {0}", _skipFilePath));
        }

16. Example

Project: PlayPass
Source File: TextFileLogger.cs
View license
public void Initialize(string connectionString)
        {
            var parser = new DbConnectionStringBuilder {ConnectionString = connectionString};
            var fileName = parser.ContainsKey("Filename")
                ? parser["Filename"].ToString()
                : Path.Combine(Directory.GetCurrentDirectory(), "PlayPass.log");
            var appendMode = !parser.ContainsKey("Append") || (parser["Append"].ToString() == "1");
            _file = new StreamWriter(fileName, appendMode) {AutoFlush = true};
        }

17. Example

View license
internal void Normalize()
        {
            // Ensure instance id for transient connection
            if (this.IsTransient && string.IsNullOrEmpty(this.InstanceId))
            {
                this.InstanceId = Guid.NewGuid().ToString();
            }

            // Remove the transient information
            if (this.ContainsKey(IsTransientKey))
            {
                this.Remove(IsTransientKey);
            }
        }

18. Example

Project: Umbraco-CMS
Source File: DataLayerHelper.cs
View license
private static void SetDataHelperNamesLegacyConnectionString(DbConnectionStringBuilder connectionStringBuilder)
        {
            // get the data layer type and parse it
            var datalayerType = String.Empty;
            if (connectionStringBuilder.ContainsKey(ConnectionStringDataLayerIdentifier))
            {
                datalayerType = connectionStringBuilder[ConnectionStringDataLayerIdentifier].ToString();
                connectionStringBuilder.Remove(ConnectionStringDataLayerIdentifier);
            }

            _connectionString = connectionStringBuilder.ConnectionString;

            var datalayerTypeParts = datalayerType.Split(",".ToCharArray());

            _dataHelperTypeName = datalayerTypeParts[0].Trim();
            _dataHelperAssemblyName = datalayerTypeParts.Length < 2
                                          ? string.Empty
                                          : datalayerTypeParts[1].Trim();

            if (datalayerTypeParts.Length > 2 || (_dataHelperTypeName.Length == 0 && _dataHelperAssemblyName.Length > 0))
                throw new ArgumentException("Illegal format of data layer property. Should be 'DataLayer = Full_Type_Name [, Assembly_Name]'.", "connectionString");
        }

19. Example

Project: PlayPass
Source File: LoggerFactory.cs
View license
public static ILogger GetLogger(string connectionString, bool debugMode, bool verboseMode)
        {
            var parser = new DbConnectionStringBuilder {ConnectionString = connectionString};
            if (!parser.ContainsKey("Provider"))
                throw new Exception("Logger Provider Type is not specified");

            var providerType = parser["Provider"].ToString().ToUpper();

            if (!Classes.ContainsKey(providerType))
                throw new Exception(String.Format("Unregistered Logger Provider Type: {0}", providerType));

            var type = Classes[providerType];
            var instance = (ILogger) Activator.CreateInstance(type);
            instance.DebugMode = debugMode;
            instance.VerboseMode = verboseMode;
            instance.Initialize(connectionString);
            return instance;
        }

20. Example

Project: PlayPass
Source File: QueueListFactory.cs
View license
public static IQueueList GetQueueList(string connectionString)
        {
            var parser = new DbConnectionStringBuilder {ConnectionString = connectionString};
            if (!parser.ContainsKey("Provider"))
                throw new Exception("Queue List Provider Type is not specified");

            var providerType = parser["Provider"].ToString().ToUpper();

            if (!Classes.ContainsKey(providerType))
                throw new Exception(String.Format("Unregistered Queue List Provider Type: {0}", providerType));

            var type = Classes[providerType];
            var instance = (IQueueList) Activator.CreateInstance(type);
            instance.Initialize(connectionString);
            return instance;
        }

21. Example

Project: NBi
Source File: QueryAdomdEngine.cs
View license
public void CleanCache()
        {
            using (var conn = new AdomdConnection(command.Connection.ConnectionString))
            {
                string xmla = string.Empty;
                using (var stream = Assembly.GetExecutingAssembly()
                                           .GetManifestResourceStream("NBi.Core.Query.CleanCache.xmla"))
                    using (var reader = new StreamReader(stream))
                        xmla = reader.ReadToEnd();

                var csb = new DbConnectionStringBuilder();
                csb.ConnectionString = conn.ConnectionString;
                if (!csb.ContainsKey("Initial Catalog"))
                    throw new ArgumentException("The token 'Initial Catalog' was not provided in the connection string due to this, it was impossible to clean the cache of the database.");

                conn.Open();
                using (var cleanCmd = new AdomdCommand(string.Format(xmla, csb["Initial Catalog"]), conn))
                    cleanCmd.ExecuteNonQuery();
            }
        }

22. Example

Project: NBi
Source File: ConnectionFactory.cs
View license
public IDbConnection Get(string connectionString)
        {
            var csb = new DbConnectionStringBuilder();
            csb.ConnectionString = connectionString;

            string providerName = string.Empty;
            if (csb.ContainsKey("pbix"))
            {
                providerName = "Microsoft.AnalysisServices.AdomdClient";
                var connectionStringBuilder = GetPowerBiDesktopConnectionStringBuilder();
                connectionStringBuilder.Build(csb["pbix"].ToString());
                connectionString = connectionStringBuilder.GetConnectionString();
            }

            if (csb.ContainsKey("Provider"))
                providerName = InterpretProviderName(csb["Provider"].ToString());

            if (string.IsNullOrEmpty(providerName) && csb.ContainsKey("Driver"))
                providerName = "System.Data.Odbc";

            if (string.IsNullOrEmpty(providerName))
                providerName = "System.Data.SqlClient";

            if (string.IsNullOrEmpty(providerName))
                throw new ArgumentException(string.Format("No provider found for connectionString '{0}'", connectionString));
                
            return Get(providerName, connectionString);           
        }

23. Example

View license
protected static void GetDatabaseInfo(ref Site site, string physicalPath, string remoteComputerName)/n ..... /n //View Source file for more details /n }

24. Example

Project: Yarn
Source File: DbFactory.cs
View license
public static string GetProviderInvariantNameByConnectionString(string connectionString)
        {
 /n ..... /n //View Source file for more details /n }

25. Example

View license
private void SyncSelectedObjects(TreeNode selectedNode, bool nodeChecked)
        {
            if (/n ..... /n //View Source file for more details /n }

26. Example

View license
private void doOpen(string hostName)
        {
            networkErrorOccurred = false;
           /n ..... /n //View Source file for more details /n }