Esempio n. 1
0
        // Helper to ensure the file name is unique underneath assemblyBuilder. This includes
        // modules and resources.
        //
        //
        //
        internal void CheckFileNameConflict(String strFileName)
        {
            int size = m_moduleBuilderList.Count;
            int i;

            for (i = 0; i < size; i++)
            {
                ModuleBuilder moduleBuilder = m_moduleBuilderList[i];
                if (moduleBuilder.m_moduleData.m_strFileName != null)
                {
                    if (String.Compare(moduleBuilder.m_moduleData.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        // Cannot have two dynamic module with the same name
                        throw new ArgumentException(Environment.GetResourceString("Argument_DuplicatedFileName"));
                    }
                }
            }
            size = m_resWriterList.Count;
            for (i = 0; i < size; i++)
            {
                ResWriterData resWriter = m_resWriterList[i];
                if (resWriter.m_strFileName != null)
                {
                    if (String.Compare(resWriter.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        // Cannot have two dynamic module with the same name
                        throw new ArgumentException(Environment.GetResourceString("Argument_DuplicatedFileName"));
                    }
                }
            }
        }
 internal ResWriterData(ResourceWriter resWriter, Stream memoryStream, string strName, string strFileName, string strFullFileName, ResourceAttributes attribute)
 {
     this.m_resWriter       = resWriter;
     this.m_memoryStream    = memoryStream;
     this.m_strName         = strName;
     this.m_strFileName     = strFileName;
     this.m_strFullFileName = strFullFileName;
     this.m_nextResWriter   = null;
     this.m_attribute       = attribute;
 }
 internal ResWriterData(ResourceWriter resWriter, Stream memoryStream, string strName, string strFileName, string strFullFileName, ResourceAttributes attribute)
 {
     this.m_resWriter = resWriter;
     this.m_memoryStream = memoryStream;
     this.m_strName = strName;
     this.m_strFileName = strFileName;
     this.m_strFullFileName = strFullFileName;
     this.m_nextResWriter = null;
     this.m_attribute = attribute;
 }
        // Token: 0x06004863 RID: 18531 RVA: 0x00105B7C File Offset: 0x00103D7C
        internal void CheckResNameConflict(string strNewResName)
        {
            int count = this.m_resWriterList.Count;

            for (int i = 0; i < count; i++)
            {
                ResWriterData resWriterData = this.m_resWriterList[i];
                if (resWriterData.m_strName.Equals(strNewResName))
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateResourceName"));
                }
            }
        }
Esempio n. 5
0
        // Helper to ensure the resource name is unique underneath assemblyBuilder
        internal void CheckResNameConflict(String strNewResName)
        {
            int size = m_resWriterList.Count;
            int i;

            for (i = 0; i < size; i++)
            {
                ResWriterData resWriter = m_resWriterList[i];
                if (resWriter.m_strName.Equals(strNewResName))
                {
                    // Cannot have two resources with the same name
                    throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateResourceName"));
                }
            }
        }
        // Token: 0x06004866 RID: 18534 RVA: 0x00105C5C File Offset: 0x00103E5C
        internal void CheckFileNameConflict(string strFileName)
        {
            int count = this.m_moduleBuilderList.Count;

            for (int i = 0; i < count; i++)
            {
                ModuleBuilder moduleBuilder = this.m_moduleBuilderList[i];
                if (moduleBuilder.m_moduleData.m_strFileName != null && string.Compare(moduleBuilder.m_moduleData.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_DuplicatedFileName"));
                }
            }
            count = this.m_resWriterList.Count;
            for (int i = 0; i < count; i++)
            {
                ResWriterData resWriterData = this.m_resWriterList[i];
                if (resWriterData.m_strFileName != null && string.Compare(resWriterData.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_DuplicatedFileName"));
                }
            }
        }
        internal void CheckFileNameConflict(string strFileName)
        {
            int num2;
            int count = this.m_moduleBuilderList.Count;

            for (num2 = 0; num2 < count; num2++)
            {
                ModuleBuilder builder = this.m_moduleBuilderList[num2];
                if ((builder.m_moduleData.m_strFileName != null) && (string.Compare(builder.m_moduleData.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0))
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_DuplicatedFileName"));
                }
            }
            count = this.m_resWriterList.Count;
            for (num2 = 0; num2 < count; num2++)
            {
                ResWriterData data = this.m_resWriterList[num2];
                if ((data.m_strFileName != null) && (string.Compare(data.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0))
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_DuplicatedFileName"));
                }
            }
        }
 // Token: 0x0600485F RID: 18527 RVA: 0x0010556C File Offset: 0x0010376C
 internal void AddResWriter(ResWriterData resData)
 {
     this.m_resWriterList.Add(resData);
 }
Esempio n. 9
0
        private void DefineManifestResourceNoLock(String name, Stream stream, ResourceAttributes attribute)
        {
            // Define embedded managed resource to be stored in this module
           if (IsTransient())
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
           Contract.EndContractBlock();

            if (name == null)
                throw new ArgumentNullException("name");
            if (name.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
        
            if (m_assemblyBuilder.IsPersistable())
            {
                m_assemblyBuilder.m_assemblyData.CheckResNameConflict(name);

                ResWriterData resWriterData = new ResWriterData( null, stream, name, String.Empty, String.Empty, attribute);
    
                // chain it to the embedded resource list
                resWriterData.m_nextResWriter = m_moduleData.m_embeddedRes;
                m_moduleData.m_embeddedRes = resWriterData;
            }
            else
            { 
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
            }
        }
Esempio n. 10
0
        /**********************************************
        *
        * Define embedded managed resource to be stored in this module
        *                                                               
        *
        **********************************************/
        /// <include file='doc\ModuleBuilder.uex' path='docs/doc[@for="ModuleBuilder.DefineResource1"]/*' />
        
        public IResourceWriter DefineResource(
            String      name,
            String      description,
            ResourceAttributes attribute)
        {
            CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
            try
            {
                Enter();

                BCLDebug.Log("DYNIL","## DYNIL LOGGING: ModuleBuilder.DefineResource( " + name + ")");

                if (IsTransient())
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));

                if (name == null)
                    throw new ArgumentNullException("name");
                if (name.Length == 0)
                    throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");

                Assembly assembly = this.Assembly;
                if (assembly is AssemblyBuilder)
                {
                    AssemblyBuilder asmBuilder = (AssemblyBuilder)assembly;
                    if (asmBuilder.IsPersistable())
                    {
                        asmBuilder.m_assemblyData.CheckResNameConflict(name);

                        MemoryStream stream = new MemoryStream();
                        ResourceWriter resWriter = new ResourceWriter(stream);
                        ResWriterData resWriterData = new ResWriterData( resWriter, stream, name, String.Empty, String.Empty, attribute);

                        // chain it to the embedded resource list
                        resWriterData.m_nextResWriter = m_moduleData.m_embeddedRes;
                        m_moduleData.m_embeddedRes = resWriterData;
                        return resWriter;
                    }
                    else
                    {
                        throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
                    }
                }
                else
                {
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
                }
            }
            finally
            {
                Exit();
            }
        }
 // Helper to add a resource information into the tracking list
 internal void AddResWriter(ResWriterData resData)
 {
     m_resWriterList.Add(resData);
 }
 private IResourceWriter DefineResourceNoLock(string name, string description, ResourceAttributes attribute)
 {
     if (this.IsTransient())
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
     }
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (name.Length == 0)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
     }
     if (!this.m_assemblyBuilder.IsPersistable())
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
     }
     this.m_assemblyBuilder.m_assemblyData.CheckResNameConflict(name);
     MemoryStream stream = new MemoryStream();
     ResourceWriter resWriter = new ResourceWriter(stream);
     ResWriterData data = new ResWriterData(resWriter, stream, name, string.Empty, string.Empty, attribute) {
         m_nextResWriter = this.m_moduleData.m_embeddedRes
     };
     this.m_moduleData.m_embeddedRes = data;
     return resWriter;
 }
Esempio n. 13
0
        private IResourceWriter DefineResourceNoLock(String name, String description, ResourceAttributes attribute)
        {
            // Define embedded managed resource to be stored in this module

            if (IsTransient())
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));

            if (name == null)
                throw new ArgumentNullException(nameof(name));
            if (name.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
            Contract.Ensures(Contract.Result<IResourceWriter>() != null);
            Contract.EndContractBlock();

            if (m_assemblyBuilder.IsPersistable())
            {
                m_assemblyBuilder.m_assemblyData.CheckResNameConflict(name);

                    MemoryStream stream = new MemoryStream();
                    ResourceWriter resWriter = new ResourceWriter(stream);
                    ResWriterData resWriterData = new ResWriterData( resWriter, stream, name, String.Empty, String.Empty, attribute);

                // chain it to the embedded resource list
                resWriterData.m_nextResWriter = m_moduleData.m_embeddedRes;
                m_moduleData.m_embeddedRes = resWriterData;
                return resWriter;
            }
            else
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadResourceContainer"));
            }
        }