PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/FluentNHibernate/Cfg/Db/IfxDRDAConnectionStringBuilder.cs

http://github.com/jagregory/fluent-nhibernate
C# | 254 lines | 134 code | 15 blank | 105 comment | 12 complexity | a5dc8a63e4600c30898d6d3c4dd5542f MD5 | raw file
Possible License(s): BSD-3-Clause, CC-BY-SA-3.0, Apache-2.0
  1. namespace FluentNHibernate.Cfg.Db
  2. {
  3. public class IfxDRDAConnectionStringBuilder : ConnectionStringBuilder
  4. {
  5. private string authentication = "";
  6. private string database = "";
  7. private string hostVarParameter = "";
  8. private string isolationLevel = "";
  9. private string maxPoolSize = "";
  10. private string minPoolSize = "";
  11. private string password = "";
  12. private string pooling = "";
  13. private string server = "";
  14. private string username = "";
  15. private string otherOptions = "";
  16. /// <summary>
  17. /// The type of authentication to be used. Acceptable values:
  18. /// <list type="bullet">
  19. /// <item>
  20. /// SERVER
  21. /// </item>
  22. /// <item>
  23. /// SERVER_ENCRYPT
  24. /// </item>
  25. /// <item>
  26. /// DATA_ENCRYPT
  27. /// </item>
  28. /// <item>
  29. /// KERBEROS
  30. /// </item>
  31. /// <item>
  32. /// GSSPLUGIN
  33. /// </item>
  34. /// </list>
  35. /// </summary>
  36. /// <param name="authentication"></param>
  37. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  38. public IfxDRDAConnectionStringBuilder Authentication(string authentication)
  39. {
  40. this.authentication = authentication;
  41. IsDirty = true;
  42. return this;
  43. }
  44. /// <summary>
  45. /// The name of the database within the server instance.
  46. /// </summary>
  47. /// <param name="database"></param>
  48. /// <returns>IfxSQLIConnectionStringBuilder object</returns>
  49. public IfxDRDAConnectionStringBuilder Database(string database)
  50. {
  51. this.database = database;
  52. IsDirty = true;
  53. return this;
  54. }
  55. /// <summary>
  56. /// <list type="bullet">
  57. /// <item>
  58. /// <term>true</term>
  59. /// <description> - host variable (:param) support enabled.</description>
  60. /// </item>
  61. /// <item>
  62. /// <term>false (default)</term>
  63. /// <description> - host variable support disabled.</description>
  64. /// </item>
  65. /// </list>
  66. /// </summary>
  67. /// <param name="hostVarParameter"></param>
  68. /// <returns>IfxSQLIConnectionStringBuilder object</returns>
  69. public IfxDRDAConnectionStringBuilder HostVarParameter(string hostVarParameter)
  70. {
  71. this.hostVarParameter = hostVarParameter;
  72. IsDirty = true;
  73. return this;
  74. }
  75. /// <summary>
  76. /// Isolation level for the connection. Possible values:
  77. /// <list type="bullet">
  78. /// <item>
  79. /// ReadCommitted
  80. /// </item>
  81. /// <item>
  82. /// ReadUncommitted
  83. /// </item>
  84. /// <item>
  85. /// RepeatableRead
  86. /// </item>
  87. /// <item>
  88. /// Serializable
  89. /// </item>
  90. /// <item>
  91. /// Transaction
  92. /// </item>
  93. /// </list>
  94. /// This keyword is only supported for applications participating in a
  95. /// distributed transaction.
  96. /// </summary>
  97. /// <param name="isolationLevel"></param>
  98. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  99. public IfxDRDAConnectionStringBuilder IsolationLevel(string isolationLevel)
  100. {
  101. this.isolationLevel = isolationLevel;
  102. IsDirty = true;
  103. return this;
  104. }
  105. /// <summary>
  106. /// The maximum number of connections allowed in the pool.
  107. /// </summary>
  108. /// <param name="maxPoolSize"></param>
  109. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  110. public IfxDRDAConnectionStringBuilder MaxPoolSize(string maxPoolSize)
  111. {
  112. this.maxPoolSize = maxPoolSize;
  113. IsDirty = true;
  114. return this;
  115. }
  116. /// <summary>
  117. /// The minimum number of connections allowed in the pool. Default value 0.
  118. /// </summary>
  119. /// <param name="minPoolSize"></param>
  120. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  121. public IfxDRDAConnectionStringBuilder MinPoolSize(string minPoolSize)
  122. {
  123. this.minPoolSize = minPoolSize;
  124. IsDirty = true;
  125. return this;
  126. }
  127. /// <summary>
  128. /// The password associated with the User ID.
  129. /// </summary>
  130. /// <param name="password"></param>
  131. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  132. public IfxDRDAConnectionStringBuilder Password(string password)
  133. {
  134. this.password = password;
  135. IsDirty = true;
  136. return this;
  137. }
  138. /// <summary>
  139. /// When set to true, the IfxConnection object is drawn from
  140. /// the appropriate pool, or if necessary, it is created and added
  141. /// to the appropriate pool. Default value 'true'.
  142. /// </summary>
  143. /// <param name="pooling"></param>
  144. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  145. public IfxDRDAConnectionStringBuilder Pooling(string pooling)
  146. {
  147. this.pooling = pooling;
  148. IsDirty = true;
  149. return this;
  150. }
  151. /// <summary>
  152. /// Server name with optional port number for direct connection using either
  153. /// IPv4 notation (<![CDATA[<server name/ip address>[:<port>]]]>) or IPv6 notation.
  154. /// </summary>
  155. /// <param name="server"></param>
  156. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  157. public IfxDRDAConnectionStringBuilder Server(string server)
  158. {
  159. this.server = server;
  160. IsDirty = true;
  161. return this;
  162. }
  163. /// <summary>
  164. /// The login account.
  165. /// </summary>
  166. /// <param name="username"></param>
  167. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  168. public IfxDRDAConnectionStringBuilder Username(string username)
  169. {
  170. this.username = username;
  171. IsDirty = true;
  172. return this;
  173. }
  174. /// <summary>
  175. /// Other options: Connection Lifetime, Connection Reset, Connection Timeout, CurrentSchema, Enlist,
  176. /// Interrupt, Persist Security Info, ResultArrayAsReturnValue, Security, TrustedContextSystemUserID,
  177. /// TrustedContextSystemPassword
  178. /// </summary>
  179. /// <param name="otherOptions"></param>
  180. /// <returns>IfxDRDAConnectionStringBuilder object</returns>
  181. public IfxDRDAConnectionStringBuilder OtherOptions(string otherOptions)
  182. {
  183. this.otherOptions = otherOptions;
  184. IsDirty = true;
  185. return this;
  186. }
  187. protected internal override string Create()
  188. {
  189. var connectionString = base.Create();
  190. if (!string.IsNullOrEmpty(connectionString))
  191. return connectionString;
  192. if (this.authentication.Length > 0)
  193. {
  194. connectionString += string.Format("Authentication={0};", this.authentication);
  195. }
  196. if (this.database.Length > 0)
  197. {
  198. connectionString += string.Format("Database={0};", this.database);
  199. }
  200. if (this.hostVarParameter.Length > 0)
  201. {
  202. connectionString += string.Format("HostVarParameter={0};", this.hostVarParameter);
  203. }
  204. if (this.isolationLevel.Length > 0)
  205. {
  206. connectionString += string.Format("IsolationLevel={0};", this.isolationLevel);
  207. }
  208. if (this.maxPoolSize.Length > 0)
  209. {
  210. connectionString += string.Format("Max Pool Size={0};", this.maxPoolSize);
  211. }
  212. if (this.minPoolSize.Length > 0)
  213. {
  214. connectionString += string.Format("Min Pool Size={0};", this.minPoolSize);
  215. }
  216. if (this.password.Length > 0)
  217. {
  218. connectionString += string.Format("PWD={0};", this.password);
  219. }
  220. if (this.pooling.Length > 0)
  221. {
  222. connectionString += string.Format("Pooling={0};", this.pooling);
  223. }
  224. if (this.server.Length > 0)
  225. {
  226. connectionString += string.Format("Server={0};", this.server);
  227. }
  228. if (this.username.Length > 0)
  229. {
  230. connectionString += string.Format("UID={0};", this.username);
  231. }
  232. if (this.otherOptions.Length > 0)
  233. {
  234. connectionString += this.otherOptions;
  235. }
  236. return connectionString;
  237. }
  238. }
  239. }