// Token: 0x060020EE RID: 8430 RVA: 0x000973F4 File Offset: 0x000955F4 public void WriteDefAttribute(string name, string value) { this.VerifyWriteState(); BamlRecordType bamlRecordType = this.PeekRecordType(); if (bamlRecordType != BamlRecordType.ElementStart && name != "Uid") { throw new InvalidOperationException(SR.Get("BamlWriterNoInElement", new object[] { "WriteDefAttribute", bamlRecordType.ToString() })); } if (name == "Key") { DefAttributeData defAttributeData = this._extensionParser.IsMarkupExtensionDefAttribute(this.PeekElementType(), ref value, 0, 0, 0); if (defAttributeData != null) { if (name != "Key") { defAttributeData.IsSimple = false; } if (defAttributeData.IsSimple) { int num = defAttributeData.Args.IndexOf(':'); string prefix = string.Empty; string localName = defAttributeData.Args; if (num > 0) { prefix = defAttributeData.Args.Substring(0, num); localName = defAttributeData.Args.Substring(num + 1); } string namespaceURI = this._parserContext.XmlnsDictionary[prefix]; string empty = string.Empty; string empty2 = string.Empty; Type type = null; Type type2 = null; bool elementType = ((IParserHelper)this).GetElementType(false, localName, namespaceURI, ref empty, ref empty2, ref type, ref type2); if (elementType) { XamlDefAttributeKeyTypeNode xamlDefNode = new XamlDefAttributeKeyTypeNode(0, 0, this._depth, empty2, type.Assembly.FullName, type); this._bamlRecordWriter.WriteDefAttributeKeyType(xamlDefNode); } else { defAttributeData.IsSimple = false; DefAttributeData defAttributeData2 = defAttributeData; defAttributeData2.Args += "}"; } } if (!defAttributeData.IsSimple) { this._extensionParser.CompileDictionaryKey(this._markupExtensionNodes, defAttributeData); } return; } } XamlDefAttributeNode xamlDefNode2 = new XamlDefAttributeNode(0, 0, this._depth, name, value); this._bamlRecordWriter.WriteDefAttribute(xamlDefNode2); }
/// <summary> /// Write an attribute in the Definition namespace. /// </summary> /// <remarks> /// This is really a processing directive, rather than an actual property. /// It is used to define keys for dictionaries, resource references, /// language declarations, base class names for tags, etc. /// </remarks> public void WriteDefAttribute( string name, string value) { VerifyWriteState(); BamlRecordType parentType = PeekRecordType(); if (parentType != BamlRecordType.ElementStart && name != "Uid" ) // Parser's supposed to ignore x:Uid everywhere { throw new InvalidOperationException(SR.Get(SRID.BamlWriterNoInElement, "WriteDefAttribute", parentType.ToString())); } else if (name == XamlReaderHelper.DefinitionName) { // Check if this is a MarkupExtension, and if so expand it in xaml so that // it represents a key tree. DefAttributeData data = _extensionParser.IsMarkupExtensionDefAttribute( PeekElementType(), ref value, 0, 0, 0); if (data != null) { if (name != XamlReaderHelper.DefinitionName) { data.IsSimple = false; } if (data.IsSimple) { // If the MarkupExtension does not expand out into a complex property // subtree, but can be handled inline with other properties, then // process it immediately in place of the normal property int colonIndex = data.Args.IndexOf(':'); string prefix = string.Empty; string typeName = data.Args; if (colonIndex > 0) { prefix = data.Args.Substring(0, colonIndex); typeName = data.Args.Substring(colonIndex+1); } string valueNamespaceURI = _parserContext.XmlnsDictionary[prefix]; string valueAssemblyName = string.Empty; string valueTypeFullName = string.Empty; Type valueElementType = null; Type valueSerializerType = null; bool resolvedTag = ((IParserHelper)this).GetElementType(false, typeName, valueNamespaceURI,ref valueAssemblyName, ref valueTypeFullName, ref valueElementType, ref valueSerializerType); // If we can't resolve a simple TypeExtension value at compile time, // then write it out as a normal type extension and wait until runtime // since the type may not be visible now. if (resolvedTag) { XamlDefAttributeKeyTypeNode defKeyNode = new XamlDefAttributeKeyTypeNode( 0, 0, _depth, valueTypeFullName, valueElementType.Assembly.FullName, valueElementType); _bamlRecordWriter.WriteDefAttributeKeyType(defKeyNode); } else { data.IsSimple = false; data.Args += "}"; } } if (!data.IsSimple) { _extensionParser.CompileDictionaryKey( _markupExtensionNodes, data); } return; } } XamlDefAttributeNode defNode = new XamlDefAttributeNode( 0, 0, _depth, name, value); _bamlRecordWriter.WriteDefAttribute(defNode); }