// Token: 0x06006E31 RID: 28209 RVA: 0x001FBBD4 File Offset: 0x001F9DD4
 private void SetLocalizationComments(BamlStartElementNode node, InternalBamlLocalizabilityResolver.ElementComments comments, string stringComment)
 {
     if (!string.IsNullOrEmpty(stringComment))
     {
         try
         {
             comments.LocalizationComments = LocComments.ParsePropertyComments(stringComment);
         }
         catch (FormatException)
         {
             this.RaiseErrorNotifyEvent(new BamlLocalizerErrorNotifyEventArgs(BamlTreeMap.GetKey(node), BamlLocalizerError.InvalidLocalizationComments));
         }
     }
 }
        //----------------------------------
        // private method
        //----------------------------------

        /// <summary>
        /// Serialize the tree out to the stream.
        /// </summary>
        private void SerializeImp(
            BamlLocalizer localizer,
            BamlTree tree,
            Stream output
            )
        {
            Debug.Assert(output != null, "The output stream given is null");
            Debug.Assert(tree != null && tree.Root != null, "The tree to be serialized is null.");

            _writer        = new BamlWriter(output);
            _bamlTreeStack = new Stack <BamlTreeNode>();

            // intialize the stack.
            _bamlTreeStack.Push(tree.Root);

            while (_bamlTreeStack.Count > 0)
            {
                BamlTreeNode currentNode = _bamlTreeStack.Pop();
                if (!currentNode.Visited)
                {
                    // Mark this node so that it won't be serialized again.
                    currentNode.Visited = true;
                    currentNode.Serialize(_writer);
                    PushChildrenToStack(currentNode.Children);
                }
                else
                {
                    BamlStartElementNode elementNode = currentNode as BamlStartElementNode;
                    Debug.Assert(elementNode != null);

                    if (elementNode != null)
                    {
                        localizer.RaiseErrorNotifyEvent(
                            new BamlLocalizerErrorNotifyEventArgs(
                                BamlTreeMap.GetKey(elementNode),
                                BamlLocalizerError.DuplicateElement
                                )
                            );
                    }
                }
            }

            // do not close stream as we don't own it.
        }
Exemple #3
0
 private void SetLocalizationAttributes(
     BamlStartElementNode node,
     ElementComments comments,
     string attributes
     )
 {
     if (!string.IsNullOrEmpty(attributes))
     {
         try {
             comments.LocalizationAttributes = LocComments.ParsePropertyLocalizabilityAttributes(attributes);
         }
         catch (FormatException)
         {
             RaiseErrorNotifyEvent(
                 new BamlLocalizerErrorNotifyEventArgs(
                     BamlTreeMap.GetKey(node),
                     BamlLocalizerError.InvalidLocalizationAttributes
                     )
                 );
         }
     }
 }
Exemple #4
0
 // Token: 0x06006E19 RID: 28185 RVA: 0x001FB070 File Offset: 0x001F9270
 private void SerializeImp(BamlLocalizer localizer, BamlTree tree, Stream output)
 {
     this._writer        = new BamlWriter(output);
     this._bamlTreeStack = new Stack <BamlTreeNode>();
     this._bamlTreeStack.Push(tree.Root);
     while (this._bamlTreeStack.Count > 0)
     {
         BamlTreeNode bamlTreeNode = this._bamlTreeStack.Pop();
         if (!bamlTreeNode.Visited)
         {
             bamlTreeNode.Visited = true;
             bamlTreeNode.Serialize(this._writer);
             this.PushChildrenToStack(bamlTreeNode.Children);
         }
         else
         {
             BamlStartElementNode bamlStartElementNode = bamlTreeNode as BamlStartElementNode;
             if (bamlStartElementNode != null)
             {
                 localizer.RaiseErrorNotifyEvent(new BamlLocalizerErrorNotifyEventArgs(BamlTreeMap.GetKey(bamlStartElementNode), BamlLocalizerError.DuplicateElement));
             }
         }
     }
 }
Exemple #5
0
 // Token: 0x06006E20 RID: 28192 RVA: 0x001FB1DC File Offset: 0x001F93DC
 internal void EnsureMap()
 {
     if (this._localizableResources != null)
     {
         return;
     }
     this._resolver.InitLocalizabilityCache();
     this._keyToBamlNodeIndexMap = new Hashtable(this._tree.Size);
     this._uidToBamlNodeIndexMap = new Hashtable(this._tree.Size / 2);
     this._localizableResources  = new BamlLocalizationDictionary();
     for (int i = 0; i < this._tree.Size; i++)
     {
         BamlTreeNode bamlTreeNode = this._tree[i];
         if (!bamlTreeNode.Unidentifiable)
         {
             if (bamlTreeNode.NodeType == BamlNodeType.StartElement)
             {
                 BamlStartElementNode bamlStartElementNode = (BamlStartElementNode)bamlTreeNode;
                 this._resolver.AddClassAndAssembly(bamlStartElementNode.TypeFullName, bamlStartElementNode.AssemblyName);
             }
             BamlLocalizableResourceKey key = BamlTreeMap.GetKey(bamlTreeNode);
             if (key != null)
             {
                 if (bamlTreeNode.NodeType == BamlNodeType.StartElement)
                 {
                     if (this._uidToBamlNodeIndexMap.ContainsKey(key.Uid))
                     {
                         this._resolver.RaiseErrorNotifyEvent(new BamlLocalizerErrorNotifyEventArgs(key, BamlLocalizerError.DuplicateUid));
                         bamlTreeNode.Unidentifiable = true;
                         if (bamlTreeNode.Children == null)
                         {
                             goto IL_1AB;
                         }
                         using (List <BamlTreeNode> .Enumerator enumerator = bamlTreeNode.Children.GetEnumerator())
                         {
                             while (enumerator.MoveNext())
                             {
                                 BamlTreeNode bamlTreeNode2 = enumerator.Current;
                                 if (bamlTreeNode2.NodeType != BamlNodeType.StartElement)
                                 {
                                     bamlTreeNode2.Unidentifiable = true;
                                 }
                             }
                             goto IL_1AB;
                         }
                     }
                     this._uidToBamlNodeIndexMap.Add(key.Uid, i);
                 }
                 this._keyToBamlNodeIndexMap.Add(key, i);
                 if (this._localizableResources.RootElementKey == null && bamlTreeNode.NodeType == BamlNodeType.StartElement && bamlTreeNode.Parent != null && bamlTreeNode.Parent.NodeType == BamlNodeType.StartDocument)
                 {
                     this._localizableResources.SetRootElementKey(key);
                 }
                 BamlLocalizableResource bamlLocalizableResource = this._localizableResourceBuilder.BuildFromNode(key, bamlTreeNode);
                 if (bamlLocalizableResource != null)
                 {
                     this._localizableResources.Add(key, bamlLocalizableResource);
                 }
             }
         }
         IL_1AB :;
     }
     this._resolver.ReleaseLocalizabilityCache();
 }