Exemplo n.º 1
0
        // Token: 0x06002063 RID: 8291 RVA: 0x00096108 File Offset: 0x00094308
        internal override void Copy(BamlRecord record)
        {
            base.Copy(record);
            BamlAssemblyInfoRecord bamlAssemblyInfoRecord = (BamlAssemblyInfoRecord)record;

            bamlAssemblyInfoRecord._assemblyFullName = this._assemblyFullName;
            bamlAssemblyInfoRecord._assembly         = this._assembly;
        }
Exemplo n.º 2
0
        // Welcome to the world of "known types".
        // Known Types are used to bypass the cost of reflection for the
        // types introduced by the system. 

#region Constructor 
 
        static BamlMapTable()
        { 
            // Setup the assembly record for the known types of controls
            KnownAssemblyInfoRecord = new BamlAssemblyInfoRecord();
            KnownAssemblyInfoRecord.AssemblyId = -1;
            KnownAssemblyInfoRecord.Assembly = ReflectionHelper.LoadAssembly(_frameworkAssembly, string.Empty); 
            KnownAssemblyInfoRecord.AssemblyFullName = KnownAssemblyInfoRecord.Assembly.FullName;
        } 
Exemplo n.º 3
0
        // Token: 0x06001EC5 RID: 7877 RVA: 0x00093A70 File Offset: 0x00091C70
        internal BamlRecord ReadNextRecord(BinaryReader bamlBinaryReader, long bytesAvailable, BamlRecordType recordType)
        {
            BamlRecord bamlRecord;

            switch (recordType)
            {
            case BamlRecordType.AssemblyInfo:
                bamlRecord = new BamlAssemblyInfoRecord();
                goto IL_A6;

            case BamlRecordType.TypeInfo:
                bamlRecord = new BamlTypeInfoRecord();
                goto IL_A6;

            case BamlRecordType.TypeSerializerInfo:
                bamlRecord = new BamlTypeInfoWithSerializerRecord();
                goto IL_A6;

            case BamlRecordType.AttributeInfo:
                bamlRecord = new BamlAttributeInfoRecord();
                goto IL_A6;

            case BamlRecordType.StringInfo:
                bamlRecord = new BamlStringInfoRecord();
                goto IL_A6;

            case BamlRecordType.DefAttributeKeyString:
                bamlRecord = new BamlDefAttributeKeyStringRecord();
                goto IL_A6;

            case BamlRecordType.DefAttributeKeyType:
                bamlRecord = new BamlDefAttributeKeyTypeRecord();
                goto IL_A6;

            case BamlRecordType.KeyElementStart:
                bamlRecord = new BamlKeyElementStartRecord();
                goto IL_A6;
            }
            bamlRecord = this._readCache[(int)recordType];
            if (bamlRecord == null || bamlRecord.IsPinned)
            {
                bamlRecord = (this._readCache[(int)recordType] = this.AllocateRecord(recordType));
            }
IL_A6:
            bamlRecord.Next = null;
            if (bamlRecord != null)
            {
                if (bamlRecord.LoadRecordSize(bamlBinaryReader, bytesAvailable) && bytesAvailable >= (long)bamlRecord.RecordSize)
                {
                    bamlRecord.LoadRecordData(bamlBinaryReader);
                }
                else
                {
                    bamlRecord = null;
                }
            }
            return(bamlRecord);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Ensure we have an assembly record for this assembly
        /// </summary> 
        internal void EnsureAssemblyRecord(Assembly asm)
        { 
            string fullName = asm.FullName; 
            BamlAssemblyInfoRecord record = ObjectHashTable[fullName] as BamlAssemblyInfoRecord;
 
            // If we don't have an assembly record for this assembly yet it is most likely
            // because it is an assembly that is part of the default namespace and was not defined
            // using a mapping PI.  In that case, add an assembly record to the object cache and
            // populate it with the required data.  Note that it DOES NOT have a valid AssemblyId 
            // and this is not written out the the baml stream.
            if (record == null ) 
            { 
                record = new BamlAssemblyInfoRecord();
                record.AssemblyFullName = fullName; 
                record.Assembly = asm;
                ObjectHashTable[fullName] = record;
            }
 
        }
Exemplo n.º 5
0
        // Add an already-loaded assembly record to the map table.  These are generally 
        // appended to the end.  If we specify an existing slot in the table, make
        // sure we are not overwriting existing data. 
        internal void LoadAssemblyInfoRecord(BamlAssemblyInfoRecord record) 
        {
            Debug.Assert(AssemblyIdMap.Count == record.AssemblyId || 
                         record.AssemblyFullName ==
                ((BamlAssemblyInfoRecord)AssemblyIdMap[record.AssemblyId]).AssemblyFullName);

            if (AssemblyIdMap.Count == record.AssemblyId) 
            {
                AssemblyIdMap.Add(record); 
            } 
        }
Exemplo n.º 6
0
        // assembly maps
        // mapping of ids to Assembly Names and Assembly reference 
        // create an entry for every referenced assembly passed in on compile 
        // in case no tags reference it at compile but do at Load we won't need
        // to be given this information again. 

        internal BamlAssemblyInfoRecord AddAssemblyMap(
            BinaryWriter binaryWriter,
            string assemblyFullName) 
        {
            Debug.Assert(assemblyFullName.Length != 0, "empty assembly"); 
 
            AssemblyInfoKey key = new AssemblyInfoKey();
            key.AssemblyFullName = assemblyFullName; 

            BamlAssemblyInfoRecord bamlAssemblyInfoRecord =
                (BamlAssemblyInfoRecord) GetHashTableData(key);
 
            if (null == bamlAssemblyInfoRecord)
            { 
                bamlAssemblyInfoRecord = new BamlAssemblyInfoRecord(); 
                bamlAssemblyInfoRecord.AssemblyFullName = assemblyFullName;
 
#if PBTCOMPILER
                try
                {
                    if (bamlAssemblyInfoRecord.Assembly == null) 
                    {
                        // Load the assembly so that we can get the Assembly.FullName to store in Baml. 
                        // This will ensure that we are we use the same assembly during compilation and loading. 
                        GetAssemblyFromAssemblyInfo(bamlAssemblyInfoRecord);
                        if (bamlAssemblyInfoRecord.Assembly != null && 
                            bamlAssemblyInfoRecord.Assembly.FullName != assemblyFullName)
                        {
                            // Given name is a partial name for the assembly
 
                            // Add AssemblyInfo for the full name of the assembly and add a cache entry
                            // for the same record against the partial name. Note that there is no need 
                            // to write a Baml record for the partial assembly name 
                            bamlAssemblyInfoRecord = AddAssemblyMap(binaryWriter, bamlAssemblyInfoRecord.Assembly.FullName);
 
                            ObjectHashTable.Add(key, bamlAssemblyInfoRecord);

                            // Records written out the Baml must have a legitimate Assembly ID
                            Debug.Assert(bamlAssemblyInfoRecord.AssemblyId >= 0); 

                            return bamlAssemblyInfoRecord; 
                        } 
                        else
                        { 
                            // Given name is the full name for the assembly. Simply add a cache entry for
                            // the record and write it out to Baml.
                        }
                    } 
                }
                catch(Exception e) 
                { 
                    if (CriticalExceptions.IsCriticalException(e))
                    { 
                       throw;
                    }

                    // It is possible that the we are writing out a record for the very same assembly 
                    // that is being built on compilation. Hence the assembly may not get loaded.
                } 
#endif 

                // review, could be a race condition here. 
                bamlAssemblyInfoRecord.AssemblyId = (short) AssemblyIdMap.Add(bamlAssemblyInfoRecord);

                ObjectHashTable.Add(key,bamlAssemblyInfoRecord);
 
                // Write to BAML
                bamlAssemblyInfoRecord.Write(binaryWriter); 
            } 
            else if (bamlAssemblyInfoRecord.AssemblyId == -1)
            { 
                // This is the case when EnsureAssemblyRecord has cached the AssemblyInfo but hasn't
                // written it out to Baml. This now needs to be written out to Baml.

                Debug.Assert( 
                    bamlAssemblyInfoRecord.Assembly != null &&
                    bamlAssemblyInfoRecord.Assembly.FullName == bamlAssemblyInfoRecord.AssemblyFullName); 
 
                // review, could be a race condition here.
                bamlAssemblyInfoRecord.AssemblyId = (short) AssemblyIdMap.Add(bamlAssemblyInfoRecord); 

                // Write to BAML
                bamlAssemblyInfoRecord.Write(binaryWriter);
            } 

            // Records written out the Baml must have a legitimate Assembly ID 
            Debug.Assert(bamlAssemblyInfoRecord.AssemblyId >= 0); 

            return bamlAssemblyInfoRecord; 
        }
Exemplo n.º 7
0
        // Return the Assembly from the passed Assembly info record.  This is cached in
        // the info record.
        private Assembly GetAssemblyFromAssemblyInfo(BamlAssemblyInfoRecord assemblyInfoRecord)
        { 
            if (null == assemblyInfoRecord.Assembly)
            { 
                string path = XamlTypeMapper.AssemblyPathFor(assemblyInfoRecord.AssemblyFullName); 
                assemblyInfoRecord.Assembly = ReflectionHelper.LoadAssembly(assemblyInfoRecord.AssemblyFullName, path);
            } 

            return assemblyInfoRecord.Assembly;
        }