1 //------------------------------------------------------------------------------
2 // <copyright file="OdbcConnectionString.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="true" primary="false">Microsoft</owner>
7 //------------------------------------------------------------------------------
9 namespace System.Data.Odbc {
12 using System.Collections;
14 using System.Data.Common;
15 using System.Security;
16 using System.Security.Permissions;
19 internal sealed class OdbcConnectionString : DbConnectionOptions {
20 // instances of this class are intended to be immutable, i.e readonly
21 // used by pooling classes so it is much easier to verify correctness
22 // when not worried about the class being modified during execution
24 private static class KEY {
25 internal const string SaveFile = "savefile";
28 private readonly string _expandedConnectionString;
30 internal OdbcConnectionString(string connectionString, bool validate) : base(connectionString, null, true) {
32 string filename = null;
34 _expandedConnectionString = ExpandDataDirectories(ref filename, ref position);
36 if (validate || (null == _expandedConnectionString)) {
37 // do not check string length if it was expanded because the final result may be shorter than the original
38 if ((null != connectionString) && (ODBC32.MAX_CONNECTION_STRING_LENGTH < connectionString.Length)) { // MDAC 83536
39 throw ODBC.ConnectionStringTooLong();
44 protected internal override System.Security.PermissionSet CreatePermissionSet() {
45 System.Security.PermissionSet permissionSet;
46 if (ContainsKey(KEY.SaveFile)) {
47 permissionSet = new NamedPermissionSet("FullTrust");
50 permissionSet = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.None);
51 permissionSet.AddPermission(new OdbcPermission(this));
56 protected internal override string Expand() {
57 if (null != _expandedConnectionString) {
58 return _expandedConnectionString;