// Token: 0x06006EAC RID: 28332 RVA: 0x001FC674 File Offset: 0x001FA874
        private static bool ApplyChangeToBamlTree(BamlLocalizableResourceKey key, BamlLocalizableResource resource, BamlTreeUpdater.BamlTreeUpdateMap treeMap)
        {
            if (resource == null || resource.Content == null || !resource.Modifiable)
            {
                return(true);
            }
            if (!treeMap.LocalizationDictionary.Contains(key) && !treeMap.IsNewBamlTreeNode(key))
            {
                return(true);
            }
            BamlTreeNode bamlTreeNode = treeMap.MapKeyToBamlTreeNode(key);

            Invariant.Assert(bamlTreeNode != null);
            BamlNodeType nodeType = bamlTreeNode.NodeType;

            if (nodeType != BamlNodeType.StartElement)
            {
                if (nodeType != BamlNodeType.Property)
                {
                    if (nodeType == BamlNodeType.LiteralContent)
                    {
                        BamlLiteralContentNode bamlLiteralContentNode = (BamlLiteralContentNode)bamlTreeNode;
                        bamlLiteralContentNode.Content = BamlResourceContentUtil.UnescapeString(resource.Content);
                        if (bamlLiteralContentNode.Parent == null)
                        {
                            BamlTreeNode bamlTreeNode2 = treeMap.MapUidToBamlTreeElementNode(key.Uid);
                            if (bamlTreeNode2 == null)
                            {
                                return(false);
                            }
                            bamlTreeNode2.AddChild(bamlLiteralContentNode);
                        }
                    }
                }
                else
                {
                    BamlPropertyNode bamlPropertyNode = (BamlPropertyNode)bamlTreeNode;
                    bamlPropertyNode.Value = BamlResourceContentUtil.UnescapeString(resource.Content);
                    if (bamlPropertyNode.Parent == null)
                    {
                        BamlStartElementNode bamlStartElementNode = treeMap.MapUidToBamlTreeElementNode(key.Uid);
                        if (bamlStartElementNode == null)
                        {
                            return(false);
                        }
                        bamlStartElementNode.InsertProperty(bamlTreeNode);
                    }
                }
            }
            else
            {
                string b = null;
                if (treeMap.LocalizationDictionary.Contains(key))
                {
                    b = treeMap.LocalizationDictionary[key].Content;
                }
                if (resource.Content != b)
                {
                    BamlTreeUpdater.ReArrangeChildren(key, bamlTreeNode, resource.Content, treeMap);
                }
            }
            return(true);
        }
        private static bool ApplyChangeToBamlTree(
            BamlLocalizableResourceKey key,
            BamlLocalizableResource resource,
            BamlTreeUpdateMap treeMap
            )
        {
            if (resource == null ||
                resource.Content == null ||
                !resource.Modifiable)
            {
                // Invalid translation or the resource is marked as non-modifiable.
                return(true);
            }

            if (!treeMap.LocalizationDictionary.Contains(key) &&
                !treeMap.IsNewBamlTreeNode(key))
            {
                // A localizable node is either in the localization dicationary extracted
                // from the source or it is a new node created by the localizer.
                // Otherwise, we cannot modify it.
                return(true);
            }

            // get the node, at this point, all the missing nodes are created
            BamlTreeNode node = treeMap.MapKeyToBamlTreeNode(key);

            Invariant.Assert(node != null);

            // apply translations
            switch (node.NodeType)
            {
            case BamlNodeType.LiteralContent:
            {
                BamlLiteralContentNode literalNode = (BamlLiteralContentNode)node;

                // set the content to the node.
                literalNode.Content = BamlResourceContentUtil.UnescapeString(resource.Content);

                // now try to link this node into the parent.
                if (literalNode.Parent == null)
                {
                    BamlTreeNode parent = treeMap.MapUidToBamlTreeElementNode(key.Uid);
                    if (parent != null)
                    {
                        // link it up with the parent
                        parent.AddChild(literalNode);
                    }
                    else
                    {
                        return(false);    // can't resolve the parent yet
                    }
                }
                break;
            }

            case BamlNodeType.Property:
            {
                BamlPropertyNode propertyNode = (BamlPropertyNode)node;

                // set the translation into the property
                propertyNode.Value = BamlResourceContentUtil.UnescapeString(resource.Content);

                // now try to link this node into the parent
                if (propertyNode.Parent == null)
                {
                    BamlStartElementNode parent = (BamlStartElementNode)treeMap.MapUidToBamlTreeElementNode(key.Uid);
                    if (parent != null)
                    {
                        // insert property node to the parent
                        parent.InsertProperty(node);
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;
            }

            case BamlNodeType.StartElement:
            {
                string source = null;
                if (treeMap.LocalizationDictionary.Contains(key))
                {
                    source = ((BamlLocalizableResource)treeMap.LocalizationDictionary[key]).Content;
                }

                if (resource.Content != source)
                {
                    // only rearrange the value if source and update are different
                    ReArrangeChildren(key, node, resource.Content, treeMap);
                }

                break;
            }

            default:
                break;
            }


            return(true);
        }