Пример #1
0
        /// <summary>
        /// override of WriteEndAttributes
        /// </summary>
        public override void WriteEndAttributes(XamlEndAttributesNode xamlEndAttributesNode)
        {
            if (xamlEndAttributesNode.IsCompact)
            {
                return;
            }

            if (_isRootTag)
            {
                _class         = string.Empty;
                _classModifier = string.Empty;
                _subClass      = string.Empty;
                XamlTypeMapper.IsProtectedAttributeAllowed = false;
            }

            _isRootTag   = false;
            _isSameScope = false;

            if (!_pass2)
            {
                if (_nameField == null)
                {
                    if (_isFieldModifierSet)
                    {
                        ThrowException(SRID.FieldModifierNotAllowed,
                                       MarkupCompiler.DefinitionNSPrefix,
                                       xamlEndAttributesNode.LineNumber,
                                       xamlEndAttributesNode.LinePosition);
                    }
                }
                else if (_fieldModifier != MemberAttributes.Assembly)
                {
                    if (MemberAttributes.Private != _fieldModifier &&
                        MemberAttributes.Assembly != _fieldModifier)
                    {
                        MarkupCompiler.GenerateXmlComments(_nameField, _nameField.Name + " Name Field");
                    }

                    _nameField.Attributes = _fieldModifier;
                    _fieldModifier        = MemberAttributes.Assembly;
                }

                _nameField          = null;
                _isFieldModifierSet = false;

                _compiler.ConnectNameAndEvents(_name, _events, _connectionId);

                _name = null;

                if (_events != null)
                {
                    _events.Clear();
                    _events = null;
                }
            }
            else
            {
                _compiler.CheckForNestedNameScope();
            }

            // Clear the compiler's generic type argument list (see Dev11 923).
            _compiler.ClearGenericTypeArgs();

            base.WriteEndAttributes(xamlEndAttributesNode);
        }
        /// <summary>
        /// override of WriteEndAttributes
        /// </summary>
        public override void WriteEndAttributes(XamlEndAttributesNode xamlEndAttributesNode)
        {
            if (xamlEndAttributesNode.IsCompact)
            {
                return;
            }

            if (_isRootTag)
            {
                _class         = string.Empty;
                _classModifier = string.Empty;
                _subClass      = string.Empty;
                XamlTypeMapper.IsProtectedAttributeAllowed = false;
            }

            _isRootTag   = false;
            _isSameScope = false;

            if (!_pass2)
            {
                if (_nameField == null)
                {
                    if (_isFieldModifierSet)
                    {
                        ThrowException(SRID.FieldModifierNotAllowed,
                                       MarkupCompiler.DefinitionNSPrefix,
                                       xamlEndAttributesNode.LineNumber,
                                       xamlEndAttributesNode.LinePosition);
                    }
                }
                else if (_fieldModifier != MemberAttributes.Assembly)
                {
                    if (MemberAttributes.Private != _fieldModifier &&
                        MemberAttributes.Assembly != _fieldModifier)
                    {
                        MarkupCompiler.GenerateXmlComments(_nameField, _nameField.Name + " Name Field");
                    }

                    _nameField.Attributes = _fieldModifier;
                    _fieldModifier        = MemberAttributes.Assembly;
                }

                _nameField          = null;
                _isFieldModifierSet = false;

                _compiler.ConnectNameAndEvents(_name, _events, _connectionId);

                _name = null;

                if (_events != null)
                {
                    _events.Clear();
                    _events = null;
                }
            }
            else
            {
                _compiler.CheckForNestedNameScope();
            }

            // Clear the compiler's generic type argument list
            // (Strange xaml compilation error MC6025 in unrelated class)
            // The bug arises because the markup compiler's _typeArgsList is set for any tag
            // that has an x:TypeArguments attribute.   It should be cleared upon reaching the
            // end of the tag's attributes, but this only happens in the non-pass2 case.  If the
            // tag needs pass2 processing, the list is set but not cleared, leading to a mysterious
            // exception in the next tag (<ResourceDictionary>, in the repro).
            _compiler.ClearGenericTypeArgs();

            base.WriteEndAttributes(xamlEndAttributesNode);
        }