Datei: IntegrationTests/IntegrationTests/PersistenceManagerFactory.cs

Last Commit (182cfd7)
1 //
2 // Copyright (c) 2002-2016 Mirko Matytschak
3 // (www.netdataobjects.de)
4 //
5 // Author: Mirko Matytschak
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8 // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
10 // Software, and to permit persons to whom the Software is furnished to do so, subject to the following
11 // conditions:
12
13 // The above copyright notice and this permission notice shall be included in all copies or substantial portions
14 // of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22
23 using System;
24 using System.Linq;
25 using System.IO;
26 using NDO;
27 using NDO.Mapping;
28 using Reisekosten.Personal;
29 using System.Diagnostics;
30 using System.Runtime.InteropServices;
31 using System.Reflection;
32 using System.Data.SqlClient;
33
34 namespace NdoUnitTests
35 {
36 ····/// <summary>
37 ····/// Zusammenfassung för PersistenceManagerFactory.
38 ····/// </summary>
39 ····public class PmFactory
40 ····{
41 ········static object lockObject = new object();
42 ········static NDOMapping _mapping;
43
44 ········public static PersistenceManager NewPersistenceManager(TransactionMode transactionMode = TransactionMode.Optimistic)
45 ········{
46 ············var appPath = AppDomain.CurrentDomain.BaseDirectory;
47 ············string path = Path.Combine(appPath, "NDOMapping.xml");
48 ············
49 ············PersistenceManager pm;
50 ············
51 ············lock (lockObject)
52 ············{
53 ················if (_mapping != null)
 
54 ····················pm = new PersistenceManager( _mapping );
 
55 ················else
56 ················{
57 pm = new PersistenceManager( path) ;
58 ····················_mapping = pm.NDOMapping;
59 ················}
60 ············}
61
62 ············pm.TransactionMode = transactionMode;
63 ············
64 ············Connection conn = (Connection)pm.NDOMapping.Connections.First();
65 #if ORACLE || FIREBIRD || POSTGRE
66 ············pm.IdGenerationEvent += new NDO.IdGenerationHandler(IdGenerator.OnIdGenerationEvent);
67 ············IdGenerator.ConnectionString = ((Connection)pm.NDOMapping.Connections.First()).Name;
68 #endif
69 ············return pm;
70 ········}
71 ····}
72 }
73
New Commit (a04c7be)
1 //
2 // Copyright (c) 2002-2016 Mirko Matytschak
3 // (www.netdataobjects.de)
4 //
5 // Author: Mirko Matytschak
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8 // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
10 // Software, and to permit persons to whom the Software is furnished to do so, subject to the following
11 // conditions:
12
13 // The above copyright notice and this permission notice shall be included in all copies or substantial portions
14 // of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22
23 using System;
24 using System.Linq;
25 using System.IO;
26 using NDO;
27 using NDO.Mapping;
28 using Reisekosten.Personal;
29 using System.Diagnostics;
30 using System.Runtime.InteropServices;
31 using System.Reflection;
32 using System.Data.SqlClient;
33
34 namespace NdoUnitTests
35 {
36 ····/// <summary>
37 ····/// Zusammenfassung för PersistenceManagerFactory.
38 ····/// </summary>
39 ····public class PmFactory
40 ····{
41 ········static object lockObject = new object();
42 ········static NDOMapping _mapping;
43
44 ········public static PersistenceManager NewPersistenceManager(TransactionMode transactionMode = TransactionMode.Optimistic)
45 ········{
46 ············var appPath = AppDomain.CurrentDomain.BaseDirectory;
47 ············string path = Path.Combine(appPath, "NDOMapping.xml");
48 ············
49 ············PersistenceManager pm;
50 ············
51 ············lock (lockObject)
52 ············{
53 ················if (_mapping != null)
54 ················{
55 ····················pm = new PersistenceManager( _mapping );
56 ················}
57 ················else
58 ················{
59 pm = new PersistenceManager( path ) ;
60 ····················_mapping = pm.NDOMapping;
61 ················}
62 ············}
63
64 ············pm.TransactionMode = transactionMode;
65 ············
66 ············Connection conn = (Connection)pm.NDOMapping.Connections.First();
67 #if ORACLE || POSTGRE
68 ············pm.IdGenerationEvent += new NDO.IdGenerationHandler(IdGenerator.OnIdGenerationEvent);
69 ············IdGenerator.ConnectionString = ((Connection)pm.NDOMapping.Connections.First()).Name;
70 #endif
71 ············return pm;
72 ········}
73 ····}
74 }
75