//----------------------------------
        // 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.            
        }
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteRoutedEvent(
         _assemblyName, 
         _ownerTypeFullName, 
         _eventIdName, 
         _handlerName
         );
 }
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteText(_content, _typeConverterAssemblyName, _typeConverterName);
 }
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteLiteralContent(_literalContent);
 }
 internal override void Serialize(BamlWriter writer)
 {
     // skip seralizing Localization.Comments and Localization.Attributes properties
     if (!LocComments.IsLocCommentsProperty(_ownerTypeFullName, _propertyName)
      && !LocComments.IsLocLocalizabilityProperty(_ownerTypeFullName, _propertyName))            
     {
         writer.WriteProperty(
          _assemblyName, 
          _ownerTypeFullName, 
          _propertyName, 
          _value, 
          _attributeUsage
          );
     }             
 }
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteEndComplexProperty();
 }
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteContentProperty(
             _assemblyName,
             _typeFullName,
             _propertyName
             );
 }
 internal override void Serialize(BamlWriter writer)
 {
     writer.WritePIMapping(
         _xmlNamespace, 
         _clrNamespace, 
         _assemblyName
         );                
 }
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteEndElement();
 }
Esempio n. 10
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteStartElement(_assemblyName, _typeFullName, _isInjected, _useTypeConverter);
 }
Esempio n. 11
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteConnectionId(_connectionId);
 }
Esempio n. 12
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteStartDocument();
 }
Esempio n. 13
0
 /// <summary>
 /// Serialize the node through BamlWriter
 /// </summary>
 internal abstract void Serialize(BamlWriter writer);
Esempio n. 14
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WritePresentationOptionsAttribute(_name, _value);
 }
Esempio n. 15
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteEvent(
         _eventName, 
         _handlerName
         );
 }
Esempio n. 16
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteDefAttribute(_name, _value);
 }
Esempio n. 17
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteXmlnsProperty(_prefix, _xmlns);
 }
Esempio n. 18
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteStartComplexProperty(
         _assemblyName, 
         _ownerTypeFullName, 
         _propertyName
         );
 }
Esempio n. 19
0
 internal override void Serialize(BamlWriter writer)
 {
     writer.WriteEndConstructor();
 }