Ejemplo n.º 1
0
        // Token: 0x06001F49 RID: 8009 RVA: 0x00094928 File Offset: 0x00092B28
        internal override void Copy(BamlRecord record)
        {
            base.Copy(record);
            BamlDefAttributeRecord bamlDefAttributeRecord = (BamlDefAttributeRecord)record;

            bamlDefAttributeRecord._name           = this._name;
            bamlDefAttributeRecord._nameId         = this._nameId;
            bamlDefAttributeRecord._attributeUsage = this._attributeUsage;
        }
Ejemplo n.º 2
0
        // Read a x:foo="bar" record.  If foo is "Name" then this is 
        // a dictionary key record which is stored in the BamlDictionaryHolder until the end of
        // the current object is read.  Then it is used as a key to add the current 
        // object to the parent dictionary.  This is currently all the reader understands,
        // but a more general handling of def records will occur with PS# 14348
        //
        // Second special case added: If foo is "Uid" then this is an identifier 
        //  unique to this tag.  This is added by a MSBuild pre-processing step
        //  or a tool, and is used for localization or accessibility.  In the 
        //  case of UIElement objects, this value will end up as an attached 
        //  property DefinitionProperties.UidProperty.
        // 
        protected virtual void ReadDefAttributeRecord(BamlDefAttributeRecord bamlDefAttributeRecord)
        {
            // Get the name of the attribute from the string table, and cache it in the
            // def record. 
            bamlDefAttributeRecord.Name = MapTable.GetStringFromStringId(
                                            bamlDefAttributeRecord.NameId); 
 
            if (bamlDefAttributeRecord.Name == XamlReaderHelper.DefinitionName)
            { 
                object key = XamlTypeMapper.GetDictionaryKey(bamlDefAttributeRecord.Value, ParserContext);

                if (key == null)
                { 
                    ThrowException(SRID.ParserNoResource, bamlDefAttributeRecord.Value);
                } 
 
                SetKeyOnContext(key, bamlDefAttributeRecord.Value, CurrentContext, ParentContext);
            } 

            else if(bamlDefAttributeRecord.Name == XamlReaderHelper.DefinitionUid ||
                    bamlDefAttributeRecord.NameId == BamlMapTable.UidStringId)
            { 
                // The x:Uid attribute is added to all elements in the markup.
                //  This means we'll be called here under all sorts of conditions, 
                //  most of which are meaningless.  Just ignore the useless parts. 

                // If we don't have an object to set to - bail. 
                if( CurrentContext == null )
                    return;

                CurrentContext.Uid = bamlDefAttributeRecord.Value; 

                // UIDs are only meaningful on UIElements.  Ignore all cases where 
                //  the attribute was added to irrelevant elements.  Don't instantiate delay 
                //  created objects here by calling GetCurrentObjectData(), because delay
                //  created objects are never UIElements. Instantiating non-UIElements here 
                //  will cause delay creation of value types to fail.
                UIElement element = CurrentContext.ObjectData as UIElement;
                if( element != null )
                { 
                    SetDependencyValue(element, UIElement.UidProperty, bamlDefAttributeRecord.Value);
                } 
            } 

            else if (bamlDefAttributeRecord.Name == XamlReaderHelper.DefinitionShared) 
            {
                // The x:Shared token information was stored in the IBamlDictionaryKey
                // in the compiled case. Otherwise, it makes no sense to use it.
                ThrowException(SRID.ParserDefSharedOnlyInCompiled); 
            }
 
            else if (bamlDefAttributeRecord.Name == XamlReaderHelper.DefinitionRuntimeName) // x:Name 
            {
                object element = GetCurrentObjectData(); 

                if( element != null )
                {
                    DoRegisterName(bamlDefAttributeRecord.Value, element); 
                }
 
            } 
            else
            { 
                // You will only get this error if the XamlParser is out of [....]
                // with the BamlRecordReader (since it should catch unknown def
                // attributes), or if a BamlWriter was used to write
                // a bogus attribute. 
                ThrowException(SRID.ParserUnknownDefAttribute, bamlDefAttributeRecord.Name);
            } 
        }