We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace System.Globalization
- {
- using System;
- using System.Reflection;
- using System.Collections;
- using System.Threading;
- using System.Runtime.CompilerServices;
- using System.Runtime.ConstrainedExecution;
- using System.IO;
-
-
-
-
- internal sealed class GlobalizationAssembly
- {
-
-
-
-
-
-
-
-
-
- private static Hashtable m_assemblyHash = new Hashtable(4);
-
-
-
-
-
-
-
- static internal GlobalizationAssembly m_defaultInstance = GetGlobalizationAssembly(Assembly.GetAssembly(typeof(GlobalizationAssembly)));
-
- static internal GlobalizationAssembly DefaultInstance {
-
-
-
-
- get {
- if (m_defaultInstance == null)
- throw new TypeLoadException(CultureTable.TypeLoadExceptionMessage);
-
- return m_defaultInstance;
- }
- }
-
-
- static internal GlobalizationAssembly GetGlobalizationAssembly(Assembly assembly)
- {
- GlobalizationAssembly ga;
-
- if ((ga = (GlobalizationAssembly)m_assemblyHash[assembly]) == null) {
-
-
-
- RuntimeHelpers.TryCode createGlobalizationAssem = new RuntimeHelpers.TryCode(CreateGlobalizationAssembly);
- RuntimeHelpers.ExecuteCodeWithLock(typeof(CultureTableRecord), createGlobalizationAssem, assembly);
- ga = (GlobalizationAssembly)m_assemblyHash[assembly];
- }
- BCLDebug.Assert(ga != null, "GlobalizationAssembly was not created");
- return (ga);
- }
-
- [PrePrepareMethod()]
- unsafe private static void CreateGlobalizationAssembly(object assem)
- {
- GlobalizationAssembly ga;
- Assembly assembly = (Assembly)assem;
- if ((ga = (GlobalizationAssembly)m_assemblyHash[assembly]) == null) {
-
- ga = new GlobalizationAssembly();
- ga.pNativeGlobalizationAssembly = nativeCreateGlobalizationAssembly(assembly);
- System.Threading.Thread.MemoryBarrier();
- m_assemblyHash[assembly] = ga;
- }
- }
-
-
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- unsafe private static extern void* nativeCreateGlobalizationAssembly(Assembly assembly);
-
-
-
-
-
-
-
-
-
-
- internal Hashtable compareInfoCache;
-
-
-
-
- unsafe internal void* pNativeGlobalizationAssembly;
-
- internal GlobalizationAssembly()
- {
-
- compareInfoCache = new Hashtable(4);
- }
-
- unsafe static internal byte* GetGlobalizationResourceBytePtr(Assembly assembly, string tableName)
- {
- BCLDebug.Assert(assembly != null, "assembly can not be null. This should be generally the mscorlib.dll assembly.");
- BCLDebug.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);
- }
- }
-
- BCLDebug.Assert(false, String.Format(CultureInfo.CurrentCulture, "Didn't get the resource table {0} for System.Globalization from {1}", tableName, assembly));
-
- throw new ExecutionEngineException();
- }
-
- }
- }