You've already forked linux-packaging-mono
Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
67
external/referencesource/mscorlib/system/globalization/globalizationassembly.cs
vendored
Normal file
67
external/referencesource/mscorlib/system/globalization/globalizationassembly.cs
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
// ==++==
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// ==--==
|
||||
|
||||
namespace System.Globalization {
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Security;
|
||||
using System.Security.Principal;
|
||||
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
|
||||
[ResourceExposure(ResourceScope.Process)]
|
||||
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Process)]
|
||||
internal unsafe static byte* GetGlobalizationResourceBytePtr(Assembly assembly, String tableName) {
|
||||
Contract.Assert(assembly != null, "assembly can not be null. This should be generally the mscorlib.dll 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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user