// Token: 0x06006EB3 RID: 28339 RVA: 0x001FCD44 File Offset: 0x001FAF44 private static void TryAddContentPropertyToNewElement(BamlTreeUpdater.BamlTreeUpdateMap bamlTreeMap, BamlStartElementNode bamlNode) { string contentProperty = bamlTreeMap.GetContentProperty(bamlNode.AssemblyName, bamlNode.TypeFullName); if (!string.IsNullOrEmpty(contentProperty)) { bamlNode.AddChild(new BamlContentPropertyNode(bamlNode.AssemblyName, bamlNode.TypeFullName, contentProperty)); } }
// Token: 0x06006EAB RID: 28331 RVA: 0x001FC55C File Offset: 0x001FA75C private static void CreateMissingBamlTreeNode(BamlLocalizationDictionary dictionary, BamlTreeUpdater.BamlTreeUpdateMap treeMap) { BamlLocalizationDictionaryEnumerator enumerator = dictionary.GetEnumerator(); while (enumerator.MoveNext()) { BamlLocalizableResourceKey key = enumerator.Key; BamlLocalizableResource value = enumerator.Value; if (treeMap.MapKeyToBamlTreeNode(key) == null) { if (key.PropertyName == "$Content") { if (treeMap.MapUidToBamlTreeElementNode(key.Uid) == null) { BamlStartElementNode bamlStartElementNode = new BamlStartElementNode(treeMap.Resolver.ResolveAssemblyFromClass(key.ClassName), key.ClassName, false, false); bamlStartElementNode.AddChild(new BamlDefAttributeNode("Uid", key.Uid)); BamlTreeUpdater.TryAddContentPropertyToNewElement(treeMap, bamlStartElementNode); bamlStartElementNode.AddChild(new BamlEndElementNode()); treeMap.AddBamlTreeNode(key.Uid, key, bamlStartElementNode); } } else { BamlTreeNode node; if (key.PropertyName == "$LiteralContent") { node = new BamlLiteralContentNode(value.Content); } else { node = new BamlPropertyNode(treeMap.Resolver.ResolveAssemblyFromClass(key.ClassName), key.ClassName, key.PropertyName, value.Content, BamlAttributeUsage.Default); } treeMap.AddBamlTreeNode(null, key, node); } } } }
private static void CreateMissingBamlTreeNode( BamlLocalizationDictionary dictionary, BamlTreeUpdateMap treeMap ) { BamlLocalizationDictionaryEnumerator enumerator = dictionary.GetEnumerator(); while (enumerator.MoveNext()) { BamlLocalizableResourceKey key = enumerator.Key; BamlLocalizableResource resource = enumerator.Value; // get the baml tree node from the tree BamlTreeNode node = treeMap.MapKeyToBamlTreeNode(key); if (node == null) { if (key.PropertyName == BamlConst.ContentSuffix) { // see if there is already a Baml node with the Uid. If so // ignore this entry node = treeMap.MapUidToBamlTreeElementNode(key.Uid); if (node == null) { // create new Baml element node BamlStartElementNode newNode = new BamlStartElementNode( treeMap.Resolver.ResolveAssemblyFromClass(key.ClassName), key.ClassName, false, /*isInjected*/ false /*CreateUsingTypeConverter*/ ); // create new x:Uid node for this element node newNode.AddChild( new BamlDefAttributeNode( XamlReaderHelper.DefinitionUid, key.Uid ) ); TryAddContentPropertyToNewElement(treeMap, newNode); // terminate the node with EndElementNode newNode.AddChild(new BamlEndElementNode()); // store this new node into the map so that it can be found // when other translations reference it as a childplace holder, or property owner treeMap.AddBamlTreeNode(key.Uid, key, newNode); } } else { BamlTreeNode newNode; if (key.PropertyName == BamlConst.LiteralContentSuffix) { // create a LiterContent node newNode = new BamlLiteralContentNode(resource.Content); } else { newNode = new BamlPropertyNode( treeMap.Resolver.ResolveAssemblyFromClass(key.ClassName), key.ClassName, key.PropertyName, resource.Content, BamlAttributeUsage.Default ); } // add to the map treeMap.AddBamlTreeNode(null, key, newNode); } } } }
/// <remarks> /// Try to add the matching ContentPropertyNode to the newly constructed element /// </remarks> private static void TryAddContentPropertyToNewElement( BamlTreeUpdateMap bamlTreeMap, BamlStartElementNode bamlNode ) { string contentProperty = bamlTreeMap.GetContentProperty(bamlNode.AssemblyName, bamlNode.TypeFullName); if (!string.IsNullOrEmpty(contentProperty)) { bamlNode.AddChild( new BamlContentPropertyNode( bamlNode.AssemblyName, bamlNode.TypeFullName, contentProperty ) ); } }
private static bool GetBamlTreeNodeFromXmlNode( BamlLocalizableResourceKey key, XmlNode node, // xml node to construct BamlTreeNode from BamlTreeUpdateMap bamlTreeMap, // Baml tree update map IList<BamlTreeNode> newChildrenList // list of new children ) { if (node.NodeType == XmlNodeType.Text) { // construct a Text tree node from the xml content return GetBamlTreeNodeFromText( key, node.Value, bamlTreeMap, newChildrenList ); } else if (node.NodeType == XmlNodeType.Element) { XmlElement child = node as XmlElement; string className = bamlTreeMap.Resolver.ResolveFormattingTagToClass(child.Name); bool invalidResult = string.IsNullOrEmpty(className); string assemblyName = null; if (!invalidResult) { assemblyName = bamlTreeMap.Resolver.ResolveAssemblyFromClass(className); invalidResult = string.IsNullOrEmpty(assemblyName); } if (invalidResult) { bamlTreeMap.Resolver.RaiseErrorNotifyEvent( new BamlLocalizerErrorNotifyEventArgs( key, BamlLocalizerError.UnknownFormattingTag ) ); return false; } // get the uid for this formatting tag string tagUid = null; if (child.HasAttributes) { tagUid = child.GetAttribute(XamlReaderHelper.DefinitionUid); if (!string.IsNullOrEmpty(tagUid)) tagUid = BamlResourceContentUtil.UnescapeString(tagUid); } BamlStartElementNode bamlNode = null; if (tagUid != null) { bamlNode = bamlTreeMap.MapUidToBamlTreeElementNode(tagUid); } if (bamlNode == null) { bamlNode = new BamlStartElementNode( assemblyName, className, false, /*isInjected*/ false /*CreateUsingTypeConverter*/ ); if (tagUid != null) { // store the new node created bamlTreeMap.AddBamlTreeNode( tagUid, new BamlLocalizableResourceKey(tagUid, className, BamlConst.ContentSuffix, assemblyName), bamlNode ); // Add the x:Uid node to the element bamlNode.AddChild( new BamlDefAttributeNode( XamlReaderHelper.DefinitionUid, tagUid ) ); } TryAddContentPropertyToNewElement(bamlTreeMap, bamlNode); // terminate the child by a end element node bamlNode.AddChild(new BamlEndElementNode()); } else { if (bamlNode.TypeFullName != className) { // This can happen if the localizer adds a new element with an id // that is also been added to the newer version of source baml bamlTreeMap.Resolver.RaiseErrorNotifyEvent( new BamlLocalizerErrorNotifyEventArgs( key, BamlLocalizerError.DuplicateUid ) ); return false; } } newChildrenList.Add(bamlNode); bool succeed = true; if (child.HasChildNodes) { // recursively go down IList<BamlTreeNode> list = new List<BamlTreeNode>(); for (int i = 0; i < child.ChildNodes.Count && succeed; i++) { succeed = GetBamlTreeNodeFromXmlNode( key, child.ChildNodes[i], bamlTreeMap, list ); } if (succeed) { // merging the formatting translation with exisiting nodes. // formatting translation doesn't contain properties. MergeChildrenList(key, bamlTreeMap, bamlNode, list); } } return succeed; } return true; // other than text and element nodes }
// Token: 0x06006EB1 RID: 28337 RVA: 0x001FCAE4 File Offset: 0x001FACE4 private static bool GetBamlTreeNodeFromXmlNode(BamlLocalizableResourceKey key, XmlNode node, BamlTreeUpdater.BamlTreeUpdateMap bamlTreeMap, IList <BamlTreeNode> newChildrenList) { if (node.NodeType == XmlNodeType.Text) { return(BamlTreeUpdater.GetBamlTreeNodeFromText(key, node.Value, bamlTreeMap, newChildrenList)); } if (node.NodeType != XmlNodeType.Element) { return(true); } XmlElement xmlElement = node as XmlElement; string text = bamlTreeMap.Resolver.ResolveFormattingTagToClass(xmlElement.Name); bool flag = string.IsNullOrEmpty(text); string text2 = null; if (!flag) { text2 = bamlTreeMap.Resolver.ResolveAssemblyFromClass(text); flag = string.IsNullOrEmpty(text2); } if (flag) { bamlTreeMap.Resolver.RaiseErrorNotifyEvent(new BamlLocalizerErrorNotifyEventArgs(key, BamlLocalizerError.UnknownFormattingTag)); return(false); } string text3 = null; if (xmlElement.HasAttributes) { text3 = xmlElement.GetAttribute("Uid"); if (!string.IsNullOrEmpty(text3)) { text3 = BamlResourceContentUtil.UnescapeString(text3); } } BamlStartElementNode bamlStartElementNode = null; if (text3 != null) { bamlStartElementNode = bamlTreeMap.MapUidToBamlTreeElementNode(text3); } if (bamlStartElementNode == null) { bamlStartElementNode = new BamlStartElementNode(text2, text, false, false); if (text3 != null) { bamlTreeMap.AddBamlTreeNode(text3, new BamlLocalizableResourceKey(text3, text, "$Content", text2), bamlStartElementNode); bamlStartElementNode.AddChild(new BamlDefAttributeNode("Uid", text3)); } BamlTreeUpdater.TryAddContentPropertyToNewElement(bamlTreeMap, bamlStartElementNode); bamlStartElementNode.AddChild(new BamlEndElementNode()); } else if (bamlStartElementNode.TypeFullName != text) { bamlTreeMap.Resolver.RaiseErrorNotifyEvent(new BamlLocalizerErrorNotifyEventArgs(key, BamlLocalizerError.DuplicateUid)); return(false); } newChildrenList.Add(bamlStartElementNode); bool flag2 = true; if (xmlElement.HasChildNodes) { IList <BamlTreeNode> list = new List <BamlTreeNode>(); int num = 0; while (num < xmlElement.ChildNodes.Count && flag2) { flag2 = BamlTreeUpdater.GetBamlTreeNodeFromXmlNode(key, xmlElement.ChildNodes[num], bamlTreeMap, list); num++; } if (flag2) { BamlTreeUpdater.MergeChildrenList(key, bamlTreeMap, bamlStartElementNode, list); } } return(flag2); }
private static void CreateMissingBamlTreeNode( BamlLocalizationDictionary dictionary, BamlTreeUpdateMap treeMap ) { BamlLocalizationDictionaryEnumerator enumerator = dictionary.GetEnumerator(); while (enumerator.MoveNext()) { BamlLocalizableResourceKey key = enumerator.Key; BamlLocalizableResource resource = enumerator.Value; // get the baml tree node from the tree BamlTreeNode node = treeMap.MapKeyToBamlTreeNode(key); if (node == null) { if (key.PropertyName == BamlConst.ContentSuffix) { // see if there is already a Baml node with the Uid. If so // ignore this entry node = treeMap.MapUidToBamlTreeElementNode(key.Uid); if (node == null) { // create new Baml element node BamlStartElementNode newNode = new BamlStartElementNode( treeMap.Resolver.ResolveAssemblyFromClass(key.ClassName), key.ClassName, false, /*isInjected*/ false /*CreateUsingTypeConverter*/ ); // create new x:Uid node for this element node newNode.AddChild( new BamlDefAttributeNode( XamlReaderHelper.DefinitionUid, key.Uid ) ); TryAddContentPropertyToNewElement(treeMap, newNode); // terminate the node with EndElementNode newNode.AddChild(new BamlEndElementNode()); // store this new node into the map so that it can be found // when other translations reference it as a childplace holder, or property owner treeMap.AddBamlTreeNode(key.Uid, key, newNode); } } else { BamlTreeNode newNode; if (key.PropertyName == BamlConst.LiteralContentSuffix) { // create a LiterContent node newNode = new BamlLiteralContentNode(resource.Content); } else { newNode = new BamlPropertyNode( treeMap.Resolver.ResolveAssemblyFromClass(key.ClassName), key.ClassName, key.PropertyName, resource.Content, BamlAttributeUsage.Default ); } // add to the map treeMap.AddBamlTreeNode(null, key, newNode); } } } }
private static bool GetBamlTreeNodeFromXmlNode( BamlLocalizableResourceKey key, XmlNode node, // xml node to construct BamlTreeNode from BamlTreeUpdateMap bamlTreeMap, // Baml tree update map IList <BamlTreeNode> newChildrenList // list of new children ) { if (node.NodeType == XmlNodeType.Text) { // construct a Text tree node from the xml content return(GetBamlTreeNodeFromText( key, node.Value, bamlTreeMap, newChildrenList )); } else if (node.NodeType == XmlNodeType.Element) { XmlElement child = node as XmlElement; string className = bamlTreeMap.Resolver.ResolveFormattingTagToClass(child.Name); bool invalidResult = string.IsNullOrEmpty(className); string assemblyName = null; if (!invalidResult) { assemblyName = bamlTreeMap.Resolver.ResolveAssemblyFromClass(className); invalidResult = string.IsNullOrEmpty(assemblyName); } if (invalidResult) { bamlTreeMap.Resolver.RaiseErrorNotifyEvent( new BamlLocalizerErrorNotifyEventArgs( key, BamlLocalizerError.UnknownFormattingTag ) ); return(false); } // get the uid for this formatting tag string tagUid = null; if (child.HasAttributes) { tagUid = child.GetAttribute(XamlReaderHelper.DefinitionUid); if (!string.IsNullOrEmpty(tagUid)) { tagUid = BamlResourceContentUtil.UnescapeString(tagUid); } } BamlStartElementNode bamlNode = null; if (tagUid != null) { bamlNode = bamlTreeMap.MapUidToBamlTreeElementNode(tagUid); } if (bamlNode == null) { bamlNode = new BamlStartElementNode( assemblyName, className, false, /*isInjected*/ false /*CreateUsingTypeConverter*/ ); if (tagUid != null) { // store the new node created bamlTreeMap.AddBamlTreeNode( tagUid, new BamlLocalizableResourceKey(tagUid, className, BamlConst.ContentSuffix, assemblyName), bamlNode ); // Add the x:Uid node to the element bamlNode.AddChild( new BamlDefAttributeNode( XamlReaderHelper.DefinitionUid, tagUid ) ); } TryAddContentPropertyToNewElement(bamlTreeMap, bamlNode); // terminate the child by a end element node bamlNode.AddChild(new BamlEndElementNode()); } else { if (bamlNode.TypeFullName != className) { // This can happen if the localizer adds a new element with an id // that is also been added to the newer version of source baml bamlTreeMap.Resolver.RaiseErrorNotifyEvent( new BamlLocalizerErrorNotifyEventArgs( key, BamlLocalizerError.DuplicateUid ) ); return(false); } } newChildrenList.Add(bamlNode); bool succeed = true; if (child.HasChildNodes) { // recursively go down IList <BamlTreeNode> list = new List <BamlTreeNode>(); for (int i = 0; i < child.ChildNodes.Count && succeed; i++) { succeed = GetBamlTreeNodeFromXmlNode( key, child.ChildNodes[i], bamlTreeMap, list ); } if (succeed) { // merging the formatting translation with exisiting nodes. // formatting translation doesn't contain properties. MergeChildrenList(key, bamlTreeMap, bamlNode, list); } } return(succeed); } return(true); // other than text and element nodes }