1111
1212namespace appMpower . Orm ;
1313
14+ #if AOTDLL
15+
1416public static class NativeMethods
1517{
1618 private static JsonWriterOptions _jsonWriterOptions = new JsonWriterOptions
@@ -19,9 +21,9 @@ public static class NativeMethods
1921 SkipValidation = true
2022 } ;
2123
22- private readonly static WorldSerializer _worldSerializer = new WorldSerializer ( ) ;
23- private readonly static WorldsSerializer _worldsSerializer = new WorldsSerializer ( ) ;
24- private readonly static FortunesSerializer _fortunesSerializer = new FortunesSerializer ( ) ;
24+ private readonly static WorldSerializer _worldSerializer = new ( ) ;
25+ private readonly static WorldsSerializer _worldsSerializer = new ( ) ;
26+ private readonly static FortunesSerializer _fortunesSerializer = new ( ) ;
2527 private static readonly byte [ ] _delimiter = new byte [ ] { 0xFF , 0xFF , 0xFF , 0xFF } ;
2628
2729 [ UnmanagedCallersOnly ( EntryPoint = "Dbms" ) ]
@@ -87,52 +89,6 @@ public static unsafe IntPtr Fortunes(int* length, IntPtr* handlePointer)
8789 return byteArrayPointer ;
8890 }
8991
90- /*
91- [UnmanagedCallersOnly(EntryPoint = "Fortunes")]
92- public static unsafe IntPtr Fortunes(int* length, IntPtr* handlePointer)
93- {
94- List<Fortune> fortunes = RawDb.LoadFortunesRows();
95-
96- int totalSize = 0;
97-
98- foreach (var fortune in fortunes)
99- {
100- totalSize += sizeof(int) // for Id
101- + Encoding.UTF8.GetByteCount(fortune.Message ?? "") // for Message
102- + _delimiter.Length; // for delimiter
103- }
104-
105- // Allocate the total buffer
106- byte[] buffer = new byte[totalSize];
107- int offset = 0;
108-
109- // Write each object to the buffer
110- foreach (var fortune in fortunes)
111- {
112- // Write Id
113- BitConverter.TryWriteBytes(buffer.AsSpan(offset, sizeof(int)), fortune.Id);
114- offset += sizeof(int);
115-
116- // Write Message
117- int descriptionLength = Encoding.UTF8.GetBytes(fortune.Message ?? "", buffer.AsSpan(offset));
118- offset += descriptionLength;
119-
120- // Write Delimiter
121- _delimiter.CopyTo(buffer, offset);
122- offset += _delimiter.Length;
123- }
124-
125- byte[] byteArray = buffer.ToArray();
126- *length = byteArray.Length;
127-
128- GCHandle handle = GCHandle.Alloc(byteArray, GCHandleType.Pinned);
129- IntPtr byteArrayPointer = handle.AddrOfPinnedObject();
130- *handlePointer = GCHandle.ToIntPtr(handle);
131-
132- return byteArrayPointer;
133- }
134- */
135-
13692 [ UnmanagedCallersOnly ( EntryPoint = "Query" ) ]
13793 public static unsafe IntPtr Query ( int queries , int * length , IntPtr * handlePointer )
13894 {
@@ -192,4 +148,6 @@ public static unsafe IntPtr DbById(int id, int* length, IntPtr* handlePointer)
192148
193149 return byteArrayPointer ;
194150 }
195- }
151+ }
152+
153+ #endif
0 commit comments