blob: 4de3fd399b8f99e8f64d139d4f69c7bd89544719 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Globalization {
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Security;
using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.IO;
using System.Diagnostics.Contracts;
/*=================================GlobalizationAssembly==========================
**
** This class provides the table loading wrapper that calls GetManifestResourceStream
**
** It used to provide an idea for sort versioning, but that proved to not work
**
============================================================================*/
internal sealed class GlobalizationAssembly
{
// ----------------------------------------------------------------------------------------------------
//
// Instance data members and instance methods.
//
// ----------------------------------------------------------------------------------------------------
[System.Security.SecurityCritical] // auto-generated
internal unsafe static byte* GetGlobalizationResourceBytePtr(Assembly assembly, String tableName) {
Contract.Assert(assembly != null, "assembly can not be null. This should be generally the "+System.CoreLib.Name+" assembly.");
Contract.Assert(tableName != null, "table name can not be null");
Stream stream = assembly.GetManifestResourceStream(tableName);
UnmanagedMemoryStream bytesStream = stream as UnmanagedMemoryStream;
if (bytesStream != null) {
byte* bytes = bytesStream.PositionPointer;
if (bytes != null) {
return (bytes);
}
}
Contract.Assert(
false,
String.Format(
CultureInfo.CurrentCulture,
"Didn't get the resource table {0} for System.Globalization from {1}",
tableName,
assembly));
// We can not continue if we can't get the resource.
throw new InvalidOperationException();
}
}
}
|