Datei: IntegrationTests/IntegrationTests/PersistenceManagerFactory.cs

Last Commit (08b23aa)
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
New Commit (60aa080)
1 //
2 // Copyright ( c) 2002-2025 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.IO;
25 using NDO;
26 using NDO.Mapping;
 
 
 
 
 
27
28 namespace NdoUnitTests
29 {
30 ····/// <summary>
31 ····/// Zusammenfassung för PersistenceManagerFactory.
32 ····/// </summary>
33 ····public class PmFactory
34 ····{
35 ········static object lockObject = new object();
36 ········static NDOMapping _mapping;
37
38 ········public static PersistenceManager NewPersistenceManager(TransactionMode transactionMode = TransactionMode.Optimistic)
39 ········{
40 ············var appPath = AppDomain.CurrentDomain.BaseDirectory;
41 ············string path = Path.Combine(appPath, "NDOMapping.xml");
42 ············
43 ············PersistenceManager pm;
44 ············
45 ············lock (lockObject)
46 ············{
47 ················if (_mapping != null)
48 ················{
49 ····················pm = new PersistenceManager( _mapping );
50 ················}
51 ················else
52 ················{
53 ····················pm = new PersistenceManager( path );
54 ····················_mapping = pm.NDOMapping;
55 ················}
56 ············}
57
58 ············pm.TransactionMode = transactionMode;
59 ············
60 //Connection conn = ( Connection) pm. NDOMapping. Connections. First( ) ;
61 #if ORACLE || POSTGRE
62 ············pm.IdGenerationEvent += new NDO.IdGenerationHandler(IdGenerator.OnIdGenerationEvent);
63 ············IdGenerator.ConnectionString = ((Connection)pm.NDOMapping.Connections.First()).Name;
64 #endif
65 ············return pm;
66 ········}
67 ····}
68 }
69