CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
WellKnownValues.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Configuration;
4using System.Linq;
5using System.Reflection;
6using System.Text;
7using System.Threading.Tasks;
8
9namespace Csla.Test
10{
11 public class WellKnownValues
12 {
13 private static System.Configuration.Configuration AppConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
14
15 static WellKnownValues()
16 {
17 DataDirectory = BuildDataDirectory();
18 DataPortalTestDatabase = GetConnectionString("DataPortalTestDatabase");
19 DataPortalTestDatabaseWithInvalidDBValue = GetConnectionString("DataPortalTestDatabaseWithInvalidDBValue");
20 DataPortalTestDatabaseEntities = GetConnectionString("DataPortalTestDatabaseEntities");
21 EntityConnectionWithMissingDB = GetConnectionString("DataPortalTestDatabaseEntitiesWithInvalidDBValue");
22 }
23
24 public static string DataDirectory { get; }
25
26 public static string EntityConnectionWithMissingDBConnectionStringName = "DataPortalTestDatabaseEntitiesWithInvalidDBValue";
27 public static string EntityConnectionWithMissingDB {get;}
28 public static string DataPortalTestDatabaseEntities { get; }
29 public static string DataPortalTestDatabaseWithInvalidDBValue { get; }
30
31 public static string DataPortalTestDatabase { get; }
32 public static string TestLinqToSqlContextDataContext { get; }
33
34 #region Private Helper Methods
35
36 private static string BuildDataDirectory()
37 {
38 string dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString() ?? AppDomain.CurrentDomain.BaseDirectory;
39 if (dataDirectory.EndsWith(@"\"))
40 {
41 dataDirectory = dataDirectory.Substring(0, dataDirectory.Length - 1);
42 }
43 return dataDirectory;
44 }
45
46 private static string GetConnectionString(string connectionName)
47 {
48 string connectionString;
49 ConnectionStringSettingsCollection conStrings = AppConfig.ConnectionStrings.ConnectionStrings;
50
51 connectionString = conStrings[connectionName].ConnectionString;
52 connectionString = connectionString.Replace("|DataDirectory|", DataDirectory);
53 return connectionString;
54 }
55
56 #endregion
57 }
58}
static string DataPortalTestDatabase
static string DataPortalTestDatabaseEntities
static string EntityConnectionWithMissingDB
static string EntityConnectionWithMissingDBConnectionStringName
static string DataPortalTestDatabaseWithInvalidDBValue
static string TestLinqToSqlContextDataContext