The Labs \ Source Viewer \ SSCLI \ System.Reflection.Emit \ ModuleBuilderData

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. ////////////////////////////////////////////////////////////////////////////////
  16. ////////////////////////////////////////////////////////////////////////////////
  17. namespace System.Reflection.Emit
  18. {
  19.     using System;
  20.     using System.Reflection;
  21.     using System.IO;
  22.     using System.Globalization;
  23.    
  24.     // This is a package private class. This class hold all of the managed
  25.     // data member for ModuleBuilder. Note that what ever data members added to
  26.     // this class cannot be accessed from the EE.
  27.     [Serializable()]
  28.     internal class ModuleBuilderData
  29.     {
  30.         internal ModuleBuilderData(ModuleBuilder module, string strModuleName, string strFileName)
  31.         {
  32.             Init(module, strModuleName, strFileName);
  33.         }
  34.        
  35.         internal virtual void Init(ModuleBuilder module, string strModuleName, string strFileName)
  36.         {
  37.             m_fGlobalBeenCreated = false;
  38.             m_fHasGlobal = false;
  39.             m_globalTypeBuilder = new TypeBuilder(module);
  40.             m_module = module;
  41.             m_strModuleName = strModuleName;
  42.             m_tkFile = 0;
  43.             m_isSaved = false;
  44.             m_embeddedRes = null;
  45.             m_strResourceFileName = null;
  46.             m_resourceBytes = null;
  47.             m_fHasExplicitUnmanagedResource = false;
  48.             if (strFileName == null) {
  49.                 // fake a transient module file name
  50.                 m_strFileName = strModuleName;
  51.                 m_isTransient = true;
  52.             }
  53.             else {
  54.                 string strExtension = Path.GetExtension(strFileName);
  55.                 if (strExtension == null || strExtension == String.Empty) {
  56.                     // This is required by our loader. It cannot load module file that does not have file extension.
  57.                     throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_NoModuleFileExtension"), strFileName));
  58.                 }
  59.                 m_strFileName = strFileName;
  60.                 m_isTransient = false;
  61.             }
  62.             m_module.InternalSetModuleProps(m_strModuleName);
  63.         }
  64.         internal virtual bool IsTransient()
  65.         {
  66.             return m_isTransient;
  67.         }
  68.        
  69.         internal string m_strModuleName;
  70.         // scope name (can be different from file name)
  71.         internal string m_strFileName;
  72.         internal bool m_fGlobalBeenCreated;
  73.         internal bool m_fHasGlobal;
  74.         [NonSerialized()]
  75.         internal TypeBuilder m_globalTypeBuilder;
  76.         [NonSerialized()]
  77.         internal ModuleBuilder m_module;
  78.         internal int m_tkFile;
  79.         // this is the file token for this module builder
  80.         internal bool m_isSaved;
  81.         [NonSerialized()]
  82.         internal ResWriterData m_embeddedRes;
  83.         internal const string MULTI_BYTE_VALUE_CLASS = "$ArrayType$";
  84.         internal bool m_isTransient;
  85.         internal bool m_fHasExplicitUnmanagedResource;
  86.         internal string m_strResourceFileName;
  87.         internal byte[] m_resourceBytes;
  88.     }
  89. }

Developer Fusion