WriteCData() public abstract method

public abstract WriteCData ( string text ) : void
text string
return void
Exemplo n.º 1
0
        public void SaveTo(System.Xml.XmlWriter x)
        {
            foreach (var t in LinkTargetConfigurations)
            {
                x.WriteStartElement("TargetConfiguration");

                t.SaveTo(x);

                x.WriteEndElement();
            }

            x.WriteStartElement("DefaultLibs");
            foreach (var lib in DefaultLibraries)
            {
                x.WriteStartElement("lib");
                x.WriteCData(lib);
                x.WriteEndElement();
            }
            x.WriteEndElement();

            x.WriteStartElement("Includes");
            foreach (var inc in GlobalParseCache.DirectoryPaths)
            {
                x.WriteStartElement("Path");
                x.WriteCData(inc);
                x.WriteEndElement();
            }
            x.WriteEndElement();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Writes the error data that belongs in child nodes.
 /// </summary>
 /// <param name="xmlWriter">The XML writer.</param>
 protected void WriteInnerXml(System.Xml.XmlWriter w)
 {
     if (w == null)
     {
         throw new ArgumentNullException("w");
     }
     // message + detail
     if ((!string.IsNullOrEmpty(Message)) || (!string.IsNullOrEmpty(Detail)))
     {
         w.WriteStartElement("message");
         w.WriteAttributeStringIf("text", Message);
         if (!string.IsNullOrEmpty(Detail))
         {
             w.WriteCData(Detail);
         }
         w.WriteEndElement();
     }
     // htmlErrorMessage
     if (!string.IsNullOrEmpty(HtmlErrorMessage))
     {
         w.WriteStartElement("htmlErrorMessage");
         w.WriteCData(HtmlErrorMessage);
         w.WriteEndElement();
     }
     // collections
     w.WriteCollectionIf("serverVariables", new HttpValuesCollection(ServerVariable));
     w.WriteCollectionIf("queryString", new HttpValuesCollection(QueryString));
     w.WriteCollectionIf("form", new HttpValuesCollection(Form));
     w.WriteCollectionIf("cookies", new HttpValuesCollection(Cookie));
 }
Exemplo n.º 3
0
        public void SaveTo(System.Xml.XmlWriter x)
        {
            x.WriteStartElement("BinaryPath");
            x.WriteCData(BinPath);
            x.WriteEndElement();

            foreach (var kv in LinkTargetConfigurations)
            {
                x.WriteStartElement("TargetConfiguration");

                kv.Value.SaveTo(x);

                x.WriteEndElement();
            }

            x.WriteStartElement("DefaultLibs");
            foreach (var lib in DefaultLibraries)
            {
                x.WriteStartElement("lib");
                x.WriteCData(lib);
                x.WriteEndElement();
            }
            x.WriteEndElement();

            x.WriteStartElement("Includes");
            foreach (var inc in ParseCache.ParsedDirectories)
            {
                x.WriteStartElement("Path");
                x.WriteCData(inc);
                x.WriteEndElement();
            }
            x.WriteEndElement();
        }
Exemplo n.º 4
0
        public void SaveTo(System.Xml.XmlWriter x)
        {
            x.WriteAttributeString("Target", TargetType.ToString());

            x.WriteStartElement("CompilerCommand");
            x.WriteCData(Compiler);
            x.WriteEndElement();

            x.WriteStartElement("LinkerCommand");
            x.WriteCData(Linker);
            x.WriteEndElement();

            x.WriteStartElement("ObjectLinkPattern");
            x.WriteCData(ObjectFileLinkPattern);
            x.WriteEndElement();

            x.WriteStartElement("IncludePathPattern");
            x.WriteCData(IncludePathPattern);
            x.WriteEndElement();

            x.WriteStartElement("DebugArgs");
            DebugArguments.SaveTo(x);
            x.WriteEndElement();

            x.WriteStartElement("ReleaseArgs");
            ReleaseArguments.SaveTo(x);
            x.WriteEndElement();
        }
Exemplo n.º 5
0
		public void WriteTo (XmlWriter w)
		{
			w.WriteStartElement ("cmd");
			w.WriteCData (DubCommand);
			w.WriteEndElement ();

			w.WriteStartElement ("commonargs");
			w.WriteCData (CommonArgs);
			w.WriteEndElement ();
		}
        public void WriteTo(XmlWriter x)
        {
            x.WriteStartElement("NACL_SDK_ROOT");
            x.WriteCData(NACL_SDK_ROOT);
            x.WriteEndElement();

            x.WriteStartElement("NACL_MONO_ROOT");
            x.WriteCData(NACL_MONO_ROOT);
            x.WriteEndElement();
        }
Exemplo n.º 7
0
        internal static void Save(XmlWriter x)
        {
            x.WriteStartElement("UnittestCommand");
            x.WriteCData(UnittestCommand);
            x.WriteEndElement();

            x.WriteStartElement("MainMethodFlag");
            x.WriteCData(MainMethodFlag);
            x.WriteEndElement();
        }
Exemplo n.º 8
0
        public void SaveTo(System.Xml.XmlWriter x)
        {
            x.WriteStartElement("CompilerArg");
            x.WriteCData(CompilerArguments);
            x.WriteEndElement();

            x.WriteStartElement("LinkerArgs");
            x.WriteCData(LinkerArguments);
            x.WriteEndElement();
        }
Exemplo n.º 9
0
 private void generateXml(XmlWriter writer)
 {
     writer.WriteStartDocument();
     writer.WriteStartElement("results");
     foreach (var runner in _results.GroupBy(x => x.Runner))
     {
         writer.WriteStartElement("runner");
         writer.WriteAttributeString("id", runner.Key);
         foreach (var assembly in runner.GroupBy(x => x.Assembly))
         {
             writer.WriteStartElement("assembly");
             writer.WriteAttributeString("name", assembly.Key);
             foreach (var fixture in assembly.GroupBy(x => x.TestFixture))
             {
                 writer.WriteStartElement("fixture");
                 writer.WriteAttributeString("name", fixture.Key);
                 foreach (var test in fixture)
                 {
                     writer.WriteStartElement("test");
                     writer.WriteAttributeString("state", test.State.ToString());
                     writer.WriteAttributeString("name", test.TestName);
                     if (test.TestDisplayName != null)
                         writer.WriteAttributeString("displayName", test.TestDisplayName);
                     writer.WriteAttributeString("duration", test.DurationInMilliseconds.ToString());
                     writer.WriteStartElement("message");
                     writer.WriteCData(test.Message);
                     writer.WriteEndElement();
                     if (test.State == TestState.Failed || test.State == TestState.Ignored)
                     {
                         writer.WriteStartElement("stack-trace");
                         foreach (var line in test.StackLines)
                         {
                             writer.WriteStartElement("line");
                             writer.WriteStartElement("method");
                             writer.WriteCData(line.Method);
                             writer.WriteEndElement();
                             writer.WriteStartElement("file");
                             writer.WriteAttributeString("line", line.Line.ToString());
                             writer.WriteRaw(line.File);
                             writer.WriteEndElement();
                             writer.WriteEndElement();
                         }
                         writer.WriteEndElement();
                     }
                     writer.WriteEndElement();
                 }
                 writer.WriteEndElement();
             }
             writer.WriteEndElement();
         }
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
Exemplo n.º 10
0
        public void SaveTo(XmlWriter x)
        {
            x.WriteStartElement ("CompilerArg");
            x.WriteCData (CompilerArguments);
            x.WriteEndElement ();

            x.WriteStartElement ("LinkerArgs");
            x.WriteCData (LinkerArguments);
            x.WriteEndElement ();

            x.WriteStartElement ("OneStepBuildArgs");
            x.WriteCData (OneStepBuildArguments);
            x.WriteEndElement ();
        }
Exemplo n.º 11
0
        public void SaveTo(System.Xml.XmlWriter x)
        {
            x.WriteStartElement("BinaryPath");
            x.WriteCData(BinPath);
            x.WriteEndElement();

            x.WriteStartElement("VersionId");
            x.WriteCData(PredefinedVersionConstant);
            x.WriteEndElement();

            x.WriteStartElement("CompilerCommand");
            x.WriteCData(SourceCompilerCommand);
            x.WriteEndElement();

            x.WriteStartElement("Patterns");
            ArgumentPatterns.SaveTo(x);
            x.WriteEndElement();

            x.WriteStartElement("gdcLibPrefixing");
            x.WriteString(EnableGDCLibPrefixing ? "true" : "false");
            x.WriteEndElement();

            foreach (var kv in LinkTargetConfigurations)
            {
                x.WriteStartElement("TargetConfiguration");

                kv.Value.SaveTo(x);

                x.WriteEndElement();
            }

            x.WriteStartElement("DefaultLibs");
            foreach (var lib in DefaultLibraries)
            {
                x.WriteStartElement("lib");
                x.WriteCData(lib);
                x.WriteEndElement();
            }
            x.WriteEndElement();

            x.WriteStartElement("Includes");
            foreach (var inc in ParseCache.ParsedDirectories)
            {
                x.WriteStartElement("Path");
                x.WriteCData(inc);
                x.WriteEndElement();
            }
            x.WriteEndElement();
        }
Exemplo n.º 12
0
		/// <summary>
		/// Write a string to an XmlWriter
		/// </summary>
		/// <param name="writer">the writer to write to</param>
		/// <param name="text">the string to write</param>
		/// <remarks>
		/// The test is escaped either using XML escape entities
		/// or using CDATA sections.
		/// </remarks>
		public static void WriteEscapedXmlString(XmlWriter writer, string text)
		{
			// Write either escaped text or CDATA sections

			int weightCData = 12 * (1 + CountSubstrings(text, CDATA_END));
			int weightStringEscapes = 3*(CountSubstrings(text, "<") + CountSubstrings(text, ">")) + 4*CountSubstrings(text, "&");

			if (weightStringEscapes <= weightCData)
			{
				// Write string using string escapes
				writer.WriteString(text);
			}
			else
			{
				// Write string using CDATA section

				int end = text.IndexOf(CDATA_END);
	
				if (end < 0) 
				{
					writer.WriteCData(text);
				}
				else
				{
					int start = 0;
					while (end > -1) 
					{
						writer.WriteCData(text.Substring(start, end - start));
						if (end == text.Length - 3)
						{
							start = text.Length;
							writer.WriteString(CDATA_END);
							break;
						}
						else
						{
							writer.WriteString(CDATA_UNESCAPABLE_TOKEN);
							start = end + 2;
							end = text.IndexOf(CDATA_END, start);
						}
					}
	
					if (start < text.Length)
					{
						writer.WriteCData(text.Substring(start));
					}
				}
			}
		}
Exemplo n.º 13
0
        protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
        {
            writer.WriteStartElement("LogEntry");

              writer.WriteStartElement("Level");
              writer.WriteString(loggingEvent.Level.DisplayName);
              writer.WriteEndElement();

              writer.WriteStartElement("Message");
              writer.WriteCData(loggingEvent.RenderedMessage);
              writer.WriteEndElement();

              writer.WriteStartElement("Details");
              if (loggingEvent.ExceptionObject != null)
            writer.WriteCData(loggingEvent.ExceptionObject.ToString());
              writer.WriteEndElement();

              writer.WriteStartElement("StackTrace");

              if (loggingEvent.ExceptionObject != null)
              {
            writer.WriteCData(string.IsNullOrEmpty(loggingEvent.ExceptionObject.StackTrace) ? string.Empty : loggingEvent.ExceptionObject.StackTrace);
            //Exception Details
            {
              // Get stack trace for the exception with source file information
              var st = new StackTrace(loggingEvent.ExceptionObject, true);
              // Get the top stack frame
              var frame = st.GetFrame(0);

              if (frame != null)
              {
            // Get the line number from the stack frame
            var line = frame.GetFileLineNumber();

            string error_dtls = string.Format("\nFile: {0} -> Line:{1}", frame.GetFileName(), frame.GetFileLineNumber());
            writer.WriteCData(error_dtls);
              }
            }

            writer.WriteEndElement();
              }

              writer.WriteStartElement("TimeStamp");
              writer.WriteString(loggingEvent.TimeStamp.ToString("dd/MM/yyyy HH:mm:ss"));
              writer.WriteEndElement();

              writer.WriteEndElement();
        }
        protected override bool SerializeElement(XmlWriter writer, bool serializeCollectionKey)
        {
            if (writer != null)
                writer.WriteCData(Value);

            return true;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Add authors.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        private static void AddAuthors(XmlWriter writer)
        {
            writer.WriteStartElement("authors");

            foreach (MembershipUser user in Membership.GetAllUsers())
            {
                writer.WriteStartElement("author");

                writer.WriteAttributeString("id", user.UserName);
                writer.WriteAttributeString(
                    "date-created", user.CreationDate.ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
                writer.WriteAttributeString(
                    "date-modified", user.CreationDate.ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture));
                writer.WriteAttributeString("approved", "true");
                writer.WriteAttributeString("email", user.Email);

                writer.WriteStartElement("title");
                writer.WriteAttributeString("type", "text");
                writer.WriteCData(user.UserName);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Exemplo n.º 16
0
        private static void AddCategories(XmlWriter writer)
        {
            writer.WriteStartElement("categories");

            foreach (Category category in Category.Categories)
            {
                writer.WriteStartElement("category");

                writer.WriteAttributeString("id", category.Id.ToString());
                writer.WriteAttributeString("date-created", category.DateCreated.ToString("yyyy-MM-ddTHH:mm:ss"));
                writer.WriteAttributeString("date-modified", category.DateModified.ToString("yyyy-MM-ddTHH:mm:ss"));
                writer.WriteAttributeString("approved", "true");
                writer.WriteAttributeString("parentref", "0");

                if (!String.IsNullOrEmpty(category.Description))
                {
                    writer.WriteAttributeString("description", category.Description);
                }

                writer.WriteStartElement("title");
                writer.WriteAttributeString("type", "text");
                writer.WriteCData(category.Title);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
 private static void WriteNode(XmlReader reader, XmlWriter writer)
 {
     while (reader.Read())
     {
         switch (reader.NodeType)
         {
         case XmlNodeType.Element:
             writer.WriteStartElement(reader.Name);
             break;
         case XmlNodeType.Text:
             writer.WriteString(reader.Value);
             break;
         case XmlNodeType.CDATA:
             writer.WriteCData(reader.Value);
             break;
         case XmlNodeType.ProcessingInstruction:
             writer.WriteProcessingInstruction(reader.Name, reader.Value);
             break;
         case XmlNodeType.Comment:
             writer.WriteComment(reader.Value);
             break;
         case XmlNodeType.XmlDeclaration:
             break;
         case XmlNodeType.Document:
             break;
         case XmlNodeType.DocumentType:
             break;
         case XmlNodeType.EntityReference:
             break;
         case XmlNodeType.EndElement:
             writer.WriteEndElement();
             break;
         }
     }
 }
 protected override void Write(XmlWriter writer)
 {
     writer.WriteElementString("_type", "2");
     writer.WriteStartElement("char");
     writer.WriteCData(m_char.ToString());
     writer.WriteEndElement();
 }
Exemplo n.º 19
0
        public static void GravarLogAcesso()
        {
            List <string> logKeys = new List <string>(new string[] { "HTTP_USER_AGENT", "HTTP_REFERER", "QUERY_STRING", "REMOTE_ADDR" });

            StringBuilder xml = new StringBuilder();

            using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(xml)) {
                writer.WriteStartDocument();
                writer.WriteStartElement("Dados");

                foreach (string key in HttpContext.Current.Request.ServerVariables.AllKeys)
                {
                    if (logKeys.Contains(key))
                    {
                        writer.WriteStartElement("Item");
                        writer.WriteAttributeString("Key", key);
                        writer.WriteCData(HttpContext.Current.Request.ServerVariables[key]);
                        writer.WriteEndElement();
                    }
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }

            string atributo = xml.ToString().Replace("utf-16", "utf-8");

            DatabaseUtil.Connector.BindSql("insert into log_acesso (cod_usuario, dat_acesso, dsc_atributo) values (?, ?, ?) ").
            ToParam("@Usuario", Convert.ToInt32(HttpContext.Current.Session["CodUsuario"])).
            ToParam("@Data", DateTime.Now).
            ToParam("@Atributo", atributo).
            Execute();
        }
Exemplo n.º 20
0
 protected override void Write(XmlWriter writer)
 {
     writer.WriteElementString("_type", "0");
     writer.WriteStartElement("text");
     writer.WriteCData(m_text);
     writer.WriteEndElement();
 }
Exemplo n.º 21
0
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            foreach (KeyValue key in this.Keys)
            {
                writer.WriteStartElement("item");

                //Write key
                writer.WriteStartElement("key");
                writer.WriteStartElement("keyValue");
                if (key.FunctionKey != null)
                {
                    writer.WriteStartElement("functionKey");
                    writer.WriteString(key.FunctionKey.Value.ToString());
                    writer.WriteEndElement();
                }
                if (key.String != null)
                {
                    writer.WriteStartElement("str");
                    writer.WriteCData(key.String);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteStartElement("value");
                writer.WriteStartElement("ticks");
                writer.WriteString(this[key]);
                writer.WriteEndElement();
                writer.WriteEndElement();

                writer.WriteEndElement();
            }
        }
Exemplo n.º 22
0
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            foreach (KeyValue key in this.Keys)
            {
                writer.WriteStartElement("item");

                //Write key
                writer.WriteStartElement("key");
                writer.WriteStartElement("keyValue");
                if (key.FunctionKey != null)
                {
                    writer.WriteStartElement("functionKey");
                    writer.WriteString(key.FunctionKey.Value.ToString());
                    writer.WriteEndElement();
                }
                if (key.String != null)
                {
                    writer.WriteStartElement("str");
                    writer.WriteCData(key.String);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();

                //Write value (as ticks because TimeSpan is not XML serialisable)
                TimeSpan value = this[key];
                writer.WriteStartElement("value");
                writer.WriteStartElement("ticks");
                writer.WriteString(XmlConvert.ToString(value));
                writer.WriteEndElement();
                writer.WriteEndElement();

                writer.WriteEndElement();
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Writes the contents of this configuration element to the configuration file when implemented in a derived class.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"/> that writes to the configuration file.</param>
        /// <param name="serializeCollectionKey">true to serialize only the collection key properties; otherwise, false.</param>
        /// <returns>
        /// true if any data was actually serialized; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.Configuration.ConfigurationErrorsException">
        /// The current attribute is locked at a higher configuration level.
        /// </exception>
        protected override bool SerializeElement(System.Xml.XmlWriter writer, bool serializeCollectionKey)
        {
            bool returnValue;

            if (string.IsNullOrEmpty(cDataConfigurationPropertyName))
            {
                returnValue = base.SerializeElement(writer, serializeCollectionKey);
            }
            else
            {
                foreach (ConfigurationProperty configurationProperty in Properties)
                {
                    string        name          = configurationProperty.Name;
                    TypeConverter converter     = configurationProperty.Converter;
                    string        propertyValue = converter.ConvertToString(base[name]);

                    if (writer != null)
                    {
                        if (name == cDataConfigurationPropertyName)
                        {
                            writer.WriteCData(propertyValue);
                        }
                        else
                        {
                            writer.WriteAttributeString("name", propertyValue);
                        }
                    }
                }

                returnValue = true;
            }

            return(returnValue);
        }
Exemplo n.º 24
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("src", src);
     if (!System.String.IsNullOrEmpty(Value))
     {
         writer.WriteCData(Value);
     }
 }
 protected override bool SerializeToXmlElement(XmlWriter writer, string elementName)
 {
     if (writer == null)
         return true;
     writer.WriteStartElement(elementName);
     writer.WriteCData(Sql);
     writer.WriteEndElement();
     return false;
 }
Exemplo n.º 26
0
 private void WriteDirectValue(CommenceValue v)
 {
     _xw.WriteStartElement(XmlConvert.EncodeLocalName(base.ExportHeaders[v.ColumnDefinition.ColumnIndex]));
     // only write if we have something
     if (!string.IsNullOrEmpty(v.DirectFieldValue))
     {
         // can we get away with writing the value or do we need to use CData?
         if (v.ColumnDefinition.CommenceFieldDefinition.MaxChars == CommenceLimits.MaxTextFieldCapacity)
         {
             _xw.WriteCData(v.DirectFieldValue);
         }
         else
         {
             _xw.WriteString(v.DirectFieldValue);
         }
     }
     _xw.WriteEndElement();
 }
Exemplo n.º 27
0
        public bool writeCdata(string content)
        {
            if (_state.Count != 0 && _state.Peek() != State.PI)
            {
                PhpException.Throw(PhpError.Warning, Resources.XmlWritterCDataWrongContext);
                return(false);
            }

            return(CheckedCall(() => _writer.WriteCData(content)));
        }
Exemplo n.º 28
0
 /// <summary>
 /// Write xml
 /// </summary>
 /// <param name="writer">Writer</param>
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     if (string.IsNullOrWhiteSpace(value))
     {
         writer.WriteString(string.Empty);
     }
     else
     {
         writer.WriteCData("\n" + value + "\n");
     }
 }
Exemplo n.º 29
0
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteElementString("Key", this.Key);
            writer.WriteElementString("Expire", this.Expire.HasValue ? this.Expire.Value.ToString("yyyy-MM-dd HH:mm:ss") : "");
            writer.WriteStartElement("Value");
            var valueType    = Value.GetType();
            var assemblyName = valueType.Assembly.FullName.Split(',')[0];

            writer.WriteAttributeString("Type", string.Format("{0},{1}", valueType.FullName, assemblyName));
            writer.WriteCData(string.Format("{0}", XmlSerialize.SerializeToString(this.Value)));
            writer.WriteEndElement();
        }
Exemplo n.º 30
0
 void writeFields(UniFields fields, XmlWriter writer)
 {
     writer.WriteStartElement("fields");
     foreach (String str in fields.Keys) {
         writer.WriteStartElement("field");
         writer.WriteAttributeString("name", str);
         writer.WriteAttributeString("type", fields[str].Type.ToString());
         writer.WriteCData(fields[str].Value.ToString());
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
Exemplo n.º 31
0
		public void Save(XmlWriter x)
		{
			x.WriteStartDocument();

			x.WriteStartElement("ResourceFileBinding");

			x.WriteStartElement("CompilerPath");
			x.WriteCData(ResourceCompilerPath);
			x.WriteEndElement();

			x.WriteStartElement("CompilerArguments");
			x.WriteCData(ResourceCompilerArguments);
			x.WriteEndElement();

			/*
			x.WriteStartElement("BracketHightlighting");
			x.WriteAttributeString("value", EnableMatchingBracketHighlighting.ToString().ToLower());
			x.WriteEndElement();
			*/
			x.WriteEndElement();
		}
Exemplo n.º 32
0
 public static void write(XmlWriter writer, LuaScript[] scripts)
 {
     writer.WriteStartElement("scripts");
     foreach (LuaScript lua in scripts) {
         writer.WriteStartElement("script");
         writer.WriteAttributeString("name", lua.Name);
         writer.WriteAttributeString("tag", lua.Tag.ToString());
         writer.WriteCData(lua.Code);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
 private static void WriteKey(string key, ILocalizationDictionary dictionary, XmlWriter writer) {
   writer.WriteStartElement("key");
   writer.WriteAttributeString("id", key);
   foreach(var locale in dictionary.Locales) {
     var value = dictionary[locale, key];
     if(value==null) continue;
     writer.WriteStartElement("val");
     writer.WriteAttributeString("for", locale);
     writer.WriteCData(value);
     writer.WriteEndElement();
   }
   writer.WriteEndElement();
 }
Exemplo n.º 34
0
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            foreach (string key in properties.Keys)
            {
                writer.WriteStartElement("item");

                writer.WriteAttributeString("key", key);

                writer.WriteCData(this[key]);

                writer.WriteEndElement();
            }
        }
Exemplo n.º 35
0
        private static void WriteShallowNode(XmlReader reader, XmlWriter writer)
        {
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                    writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                    writer.WriteAttributes(reader, true);
                    if (reader.IsEmptyElement)
                    {
                        writer.WriteEndElement();
                    }
                    return;

                case XmlNodeType.Text:
                    writer.WriteString(reader.Value);
                    return;

                case XmlNodeType.CDATA:
                    writer.WriteCData(reader.Value);
                    return;

                case XmlNodeType.ProcessingInstruction:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    return;

                case XmlNodeType.Comment:
                    writer.WriteComment(reader.Value);
                    return;

                case XmlNodeType.DocumentType:
                    writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
                    return;

                case XmlNodeType.Whitespace:
                    writer.WriteWhitespace(reader.Value);
                    return;

                case XmlNodeType.SignificantWhitespace:
                    writer.WriteWhitespace(reader.Value);
                    return;

                case XmlNodeType.EndElement:
                    writer.WriteFullEndElement();
                    return;

                case XmlNodeType.XmlDeclaration:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    return;
            }
            throw new InvalidOperationException("Invalid node");
        }
Exemplo n.º 36
0
		/// <summary>
		/// Write a string to an <see cref="XmlWriter"/>
		/// </summary>
		/// <param name="writer">the writer to write to</param>
		/// <param name="textData">the string to write</param>
		/// <param name="invalidCharReplacement">The string to replace non XML compliant chars with</param>
		/// <remarks>
		/// <para>
		/// The test is escaped either using XML escape entities
		/// or using CDATA sections.
		/// </para>
		/// </remarks>
		public static void WriteEscapedXmlString(XmlWriter writer, string textData, string invalidCharReplacement) {
			string stringData = MaskXmlInvalidCharacters(textData, invalidCharReplacement);
			// Write either escaped text or CDATA sections

			int weightCData = 12 * (1 + CountSubstrings(stringData, CDATA_END));
			int weightStringEscapes = 3 * (CountSubstrings(stringData, "<") + CountSubstrings(stringData, ">")) + 4 * CountSubstrings(stringData, "&");

			if (weightStringEscapes <= weightCData) {
				// Write string using string escapes
				writer.WriteString(stringData);
			} else {
				// Write string using CDATA section

				int end = stringData.IndexOf(CDATA_END);

				if (end < 0) {
					writer.WriteCData(stringData);
				} else {
					int start = 0;
					while (end > -1) {
						writer.WriteCData(stringData.Substring(start, end - start));
						if (end == stringData.Length - 3) {
							start = stringData.Length;
							writer.WriteString(CDATA_END);
							break;
						} else {
							writer.WriteString(CDATA_UNESCAPABLE_TOKEN);
							start = end + 2;
							end = stringData.IndexOf(CDATA_END, start);
						}
					}

					if (start < stringData.Length) {
						writer.WriteCData(stringData.Substring(start));
					}
				}
			}
		}
        private void WriteExceptionXml(XmlWriter writer, Exception e)
        {
            writer.WriteElementString("message", e.Message);
            writer.WriteElementString("source", e.Source);
            writer.WriteStartElement("stack-trace");
            writer.WriteCData(e.StackTrace);
            writer.WriteEndElement();

            if (e.InnerException != null)
            {
                writer.WriteStartElement("inner-exception");
                WriteExceptionXml(writer, e.InnerException);
                writer.WriteEndElement();
            }
        }
Exemplo n.º 38
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteStartElement("RequestTemplates");
     foreach (string request in request_templates)
     {
         writer.WriteStartElement("Request");
         writer.WriteCData(request);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
     writer.WriteElementString("URL", URL);
     writer.WriteElementString("SearchDateBeginInterval", SearchDateBeginInterval.ToString());
     writer.WriteElementString("SearchDateEndInterval", SearchDateEndInterval.ToString());
     writer.WriteElementString("ShowResponse", ShowResponse.ToString());
 }
        void IXmlSerializable.WriteXml(XmlWriter writer)
        {
            Regex regExHTML = new Regex(@"<(\w|-|_)+>(.)*<\/(\w)+>");

            writer.WriteAttributeString("FieldName", this.FieldName);

            // If the content is HTML-like, use a CDATA section
            if (regExHTML.IsMatch(this.Value))
            {
                writer.WriteCData(this.Value);
            }
            else
            {
                writer.WriteString(this.Value);
            }
        }
Exemplo n.º 40
0
        public void SaveTo(System.Xml.XmlWriter x)
        {
            x.WriteAttributeString("Target", TargetType.ToString());

            x.WriteStartElement("LinkerCommand");
            x.WriteCData(Linker);
            x.WriteEndElement();

            x.WriteStartElement("DebugArgs");
            DebugArguments.SaveTo(x);
            x.WriteEndElement();

            x.WriteStartElement("ReleaseArgs");
            ReleaseArguments.SaveTo(x);
            x.WriteEndElement();
        }
Exemplo n.º 41
0
		public void Save(XmlWriter x)
		{
			x.WriteStartDocument();

			x.WriteStartElement("dsettings");

			x.WriteStartElement("cv2pdb");
			x.WriteCData(cv2pdb_exe);
			x.WriteEndElement();

			x.WriteStartElement("BracketHightlighting");
			x.WriteAttributeString("value", EnableMatchingBracketHighlighting.ToString().ToLower());
			x.WriteEndElement();

			x.WriteStartElement("UseCodeCompletion");
			x.WriteAttributeString("value",UseCodeCompletion.ToString().ToLower());
			x.WriteEndElement();

			x.WriteStartElement("UseMethodInsight");
			x.WriteAttributeString("value", UseMethodInsight.ToString().ToLower());
			x.WriteEndElement();

			x.WriteStartElement("ForceCodeCompetionPopupCommit");
			x.WriteAttributeString("value", ForceCodeCompetionPopupCommit. ToString().ToLower());
			x.WriteEndElement();

			x.WriteStartElement("UseSemanticErrorHighlighting");
			x.WriteAttributeString("value", UseSemanticErrorHighlighting.ToString().ToLower());
			x.WriteEndElement();

			x.WriteStartElement("UseSemanticHighlighting");
			x.WriteAttributeString("value", UseSemanticHighlighting.ToString().ToLower());
			x.WriteEndElement();

			x.WriteStartElement("SmartIndentation");
			x.WriteAttributeString("value", EnableSmartIndentation. ToString().ToLower());
			x.WriteEndElement();

			x.WriteStartElement("CompletionOptions");
			CompletionOptions.Instance.Save(x);
			x.WriteEndElement();

			dmd1.Save(x);
			dmd2.Save(x);

			x.WriteEndElement();
		}
Exemplo n.º 42
0
		public override void WriteTo (XmlWriter writer)
		{
			int start = 0;
			StringBuilder sb = null;
			for (int i = 0; i < Value.Length - 2; i++) {
				if (Value [i] == ']' && Value [i + 1] == ']'
					&& Value [i + 2] == '>') {
					if (sb == null)
						sb = new StringBuilder ();
					sb.Append (Value, start, i - start);
					sb.Append ("]]&gt;");
					start = i + 3;
				}
			}
			if (start != 0 && start != Value.Length)
				sb.Append (Value, start, Value.Length - start);
			writer.WriteCData (sb == null ? Value : sb.ToString ());
		}
Exemplo n.º 43
0
        protected override void WriteElementContent(XmlWriter writer)
        {
            if (!string.IsNullOrEmpty(_text)) {
            if (_type == null || _type.Value == null) {
              writer.WriteString(_text);
              return;
            }

            if (Helper.IsXmlType(_type)) {
              writer.WriteRaw(_text);
            }
            else if (_type == AtomContentType.Html) {
              writer.WriteCData(_text);
            }
            else {
              writer.WriteString(_text);
            }
              }
        }
Exemplo n.º 44
0
		/// <summary>
		/// Writes an XmlElement using cdata text and optional attributes
		/// </summary>
		/// <param name="writer">The writer to use</param>
		/// <param name="name">The name of the element</param>
		/// <param name="cdataText">The cdata text value of the element</param>
		/// <param name="attributes">The attributes for the element</param>
		public static void WriteCDataElement(XmlWriter writer, string name, string cdataText, params XmlStringPair[] attributes)
		{
			Debug.Assert(writer != null);
			
			// if the element will have data
			if (XmlWriterUtils.IsNeeded(cdataText))
			{
				// start the element
				writer.WriteStartElement(name);

				// write the attributes
				XmlWriterUtils.WriteAttributes(writer, attributes);

				// write the cdata text value
				writer.WriteCData(cdataText);

				// end the element
				writer.WriteEndElement();
			}
		}
Exemplo n.º 45
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteCData(Value);
 }
Exemplo n.º 46
0
        // Writes the content (inner XML) of the current node into the provided XmlWriter.
        private async Task WriteNodeAsync(XmlWriter xtw, bool defattr)
        {
#if !SILVERLIGHT
            Debug.Assert(xtw is XmlTextWriter);
#endif
            int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth;
            while (await this.ReadAsync().ConfigureAwait(false) && (d < this.Depth))
            {
                switch (this.NodeType)
                {
                case XmlNodeType.Element:
                    xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
#if !SILVERLIGHT // Removing dependency on XmlTextWriter
                    ((XmlTextWriter)xtw).QuoteChar = this.QuoteChar;
#endif
                    xtw.WriteAttributes(this, defattr);
                    if (this.IsEmptyElement)
                    {
                        xtw.WriteEndElement();
                    }
                    break;

                case XmlNodeType.Text:
                    xtw.WriteString(await this.GetValueAsync().ConfigureAwait(false));
                    break;

                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    xtw.WriteWhitespace(await this.GetValueAsync().ConfigureAwait(false));
                    break;

                case XmlNodeType.CDATA:
                    xtw.WriteCData(this.Value);
                    break;

                case XmlNodeType.EntityReference:
                    xtw.WriteEntityRef(this.Name);
                    break;

                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                    xtw.WriteProcessingInstruction(this.Name, this.Value);
                    break;

                case XmlNodeType.DocumentType:
                    xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
                    break;

                case XmlNodeType.Comment:
                    xtw.WriteComment(this.Value);
                    break;

                case XmlNodeType.EndElement:
                    xtw.WriteFullEndElement();
                    break;
                }
            }
            if (d == this.Depth && this.NodeType == XmlNodeType.EndElement)
            {
                await ReadAsync().ConfigureAwait(false);
            }
        }
Exemplo n.º 47
0
 protected override void WriteContentsTo(System.Xml.XmlWriter writer)
 {
     writer.WriteCData(Text);
 }
Exemplo n.º 48
0
        /// <summary>
        /// Persists a localization file into an XML format.
        /// </summary>
        /// <param name="writer">XmlWriter where the localization file should persist itself as XML.</param>
        public void Persist(XmlWriter writer)
        {
            writer.WriteStartElement(Localization.XmlElementName, XmlNamespaceUri);

            if (-1 != this.codepage)
            {
                writer.WriteAttributeString("Codepage", this.codepage.ToString(CultureInfo.InvariantCulture));
            }

            if (!String.IsNullOrEmpty(this.culture))
            {
                writer.WriteAttributeString("Culture", this.culture);
            }

            foreach (WixVariableRow wixVariableRow in this.variables.Values)
            {
                writer.WriteStartElement("String", XmlNamespaceUri);

                writer.WriteAttributeString("Id", wixVariableRow.Id);

                if (wixVariableRow.Overridable)
                {
                    writer.WriteAttributeString("Overridable", "yes");
                }

                writer.WriteCData(wixVariableRow.Value);

                writer.WriteEndElement();
            }

            foreach (string controlKey in this.localizedControls.Keys)
            {
                writer.WriteStartElement("UI", XmlNamespaceUri);

                string[] controlKeys = controlKey.Split('/');
                string dialog = controlKeys[0];
                string control = controlKeys[1];

                if (!String.IsNullOrEmpty(dialog))
                {
                    writer.WriteAttributeString("Dialog", dialog);
                }

                if (!String.IsNullOrEmpty(control))
                {
                    writer.WriteAttributeString("Control", control);
                }

                LocalizedControl localizedControl = this.localizedControls[controlKey];

                if (CompilerCore.IntegerNotSet != localizedControl.X)
                {
                    writer.WriteAttributeString("X", localizedControl.X.ToString());
                }

                if (CompilerCore.IntegerNotSet != localizedControl.Y)
                {
                    writer.WriteAttributeString("Y", localizedControl.Y.ToString());
                }

                if (CompilerCore.IntegerNotSet != localizedControl.Width)
                {
                    writer.WriteAttributeString("Width", localizedControl.Width.ToString());
                }

                if (CompilerCore.IntegerNotSet != localizedControl.Height)
                {
                    writer.WriteAttributeString("Height", localizedControl.Height.ToString());
                }

                if (MsiInterop.MsidbControlAttributesRTLRO == (localizedControl.Attributes & MsiInterop.MsidbControlAttributesRTLRO))
                {
                    writer.WriteAttributeString("RightToLeft", "yes");
                }

                if (MsiInterop.MsidbControlAttributesRightAligned == (localizedControl.Attributes & MsiInterop.MsidbControlAttributesRightAligned))
                {
                    writer.WriteAttributeString("RightAligned", "yes");
                }

                if (MsiInterop.MsidbControlAttributesLeftScroll == (localizedControl.Attributes & MsiInterop.MsidbControlAttributesLeftScroll))
                {
                    writer.WriteAttributeString("LeftScroll", "yes");
                }

                if (!String.IsNullOrEmpty(localizedControl.Text))
                {
                    writer.WriteCData(localizedControl.Text);
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Exemplo n.º 49
0
 public override void WriteCData(string text)
 {
     CheckAsync();
     _coreWriter.WriteCData(text);
 }
Exemplo n.º 50
0
 public override void WriteCData(string text)
 {
     _writer.WriteCData(text);
 }
Exemplo n.º 51
0
 public override void WriteCData(string?text)
 {
     _wrapped.WriteCData(text);
 }
Exemplo n.º 52
0
 public override void WriteCData(string text)
 {
     writer.WriteCData(text);
     state = WriteState.Content;
 }
Exemplo n.º 53
0
        protected override void DoWrite(Node node)
        {
            switch (node.Type)
            {
            case NodeType.DocumentStart:
            case NodeType.DocumentEnd:
                // nada a fazer
                break;

            case NodeType.ObjectStart:
            {
                var parentKind       = stack.FirstOrDefault();
                var parentIsProperty = parentKind == NodeType.Property;

                if (!parentIsProperty)
                {
                    var name    = (node.Value ?? "Element").ToString();
                    var tagName = ValueConventions.CreateName(name, Settings, TextCase.PascalCase);

                    writer.WriteStartElement(tagName);
                }

                stack.Push(NodeType.Object);
                break;
            }

            case NodeType.ObjectEnd:
            {
                stack.Pop();

                var parentKind       = stack.FirstOrDefault();
                var parentIsProperty = parentKind == NodeType.Property;

                if (!parentIsProperty)
                {
                    writer.WriteEndElement();
                }
                break;
            }

            case NodeType.CollectionStart:
            {
                var parentKind       = stack.FirstOrDefault();
                var parentIsProperty = parentKind == NodeType.Property;

                if (!parentIsProperty)
                {
                    var name    = (node.Value ?? "Array").ToString();
                    var tagName = ValueConventions.CreateName(name, Settings, TextCase.PascalCase);
                    writer.WriteStartElement(tagName);
                }

                var attName = ValueConventions.CreateName("IsArray", Settings, TextCase.PascalCase);
                writer.WriteAttributeString(attName, "true");

                stack.Push(NodeType.Collection);
                break;
            }

            case NodeType.CollectionEnd:
            {
                stack.Pop();

                var parentKind       = stack.FirstOrDefault();
                var parentIsProperty = parentKind == NodeType.Property;

                if (!parentIsProperty)
                {
                    writer.WriteEndElement();
                }

                break;
            }

            case NodeType.PropertyStart:
            {
                var name    = (node.Value ?? "Property").ToString();
                var tagName = ValueConventions.CreateName(name, Settings, TextCase.PascalCase);
                writer.WriteStartElement(tagName);

                stack.Push(NodeType.Property);
                break;
            }

            case NodeType.PropertyEnd:
            {
                writer.WriteEndElement();
                stack.Pop();
                break;
            }

            case NodeType.Value:
            {
                if (node.Value == null)
                {
                    writer.WriteValue(null);
                }
                else if (node.Value is XContainer)
                {
                    var xml   = (XContainer)node.Value;
                    var cdata = xml.ToString(SaveOptions.DisableFormatting);
                    writer.WriteCData(cdata);
                }
                else
                {
                    var text = ValueConventions.CreateText(node.Value, Settings);
                    writer.WriteValue(text);
                }
                break;
            }

            default:
                throw new SerializationException("Token não esperado: " + node);
            }

            if (Settings.AutoFlush)
            {
                DoFlush();
            }
        }
 public override void WriteTo(XmlWriter w)
 {
     w.WriteCData(this.Data);
 }
Exemplo n.º 55
0
 public override void WriteCData(string text)
 {
     CheckState();
     w.WriteCData(text);
 }
Exemplo n.º 56
0
        public void Save(XmlWriter x)
        {
            x.WriteStartElement ("exe");
            x.WriteCData (Executable);
            x.WriteEndElement ();

            x.WriteStartElement ("args");
            x.WriteCData (Arguments);
            x.WriteEndElement ();
        }
Exemplo n.º 57
0
        public void WriteTo(XmlWriter x)
        {
            x.WriteStartElement ("DefaultCompiler");
            x.WriteString (DefaultCompiler);
            x.WriteEndElement ();

            foreach (var cmp in Compilers) {
                x.WriteStartElement ("Compiler");
                x.WriteAttributeString ("Name", cmp.Vendor);

                cmp.SaveTo (x);

                x.WriteEndElement ();
            }

            x.WriteStartElement ("ResCmp");
            Win32ResourceCompiler.Instance.Save (x);
            x.WriteEndElement ();

            x.WriteStartElement ("DDocBaseUrl");
            x.WriteCData (D.Refactoring.DDocumentationLauncher.DigitalMarsUrl);
            x.WriteEndElement ();

            x.WriteStartElement ("CompletionOptions");
            CompletionOptions.Save (x);
            x.WriteEndElement ();

            x.WriteStartElement("DocumentOutline");
            Outline.Save(x);
            x.WriteEndElement();

            x.WriteStartElement("FormattingCorrectsIndentOnly");
            x.WriteString(Formatting.DCodeFormatter.IndentCorrectionOnly ? "true" : "false");
            x.WriteEndElement();
        }
Exemplo n.º 58
0
        /// <summary>
        /// Replay all cached events to an XmlWriter.
        /// </summary>
        public void EventsToWriter(XmlWriter writer)
        {
            XmlEvent[] page;
            int        idxPage, idxEvent;

            byte[]       bytes;
            char[]       chars;
            XmlRawWriter rawWriter;

            // Special-case single text node at the top-level
            if (this.singleText.Count != 0)
            {
                writer.WriteString(this.singleText.GetResult());
                return;
            }

            rawWriter = writer as XmlRawWriter;

            // Loop over set of pages
            for (idxPage = 0; idxPage < this.pages.Count; idxPage++)
            {
                page = this.pages[idxPage];

                // Loop over events in each page
                for (idxEvent = 0; idxEvent < page.Length; idxEvent++)
                {
                    switch (page[idxEvent].EventType)
                    {
                    case XmlEventType.Unknown:
                        // No more events
                        Debug.Assert(idxPage + 1 == this.pages.Count);
                        return;

                    case XmlEventType.DocType:
                        writer.WriteDocType(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3, (string)page[idxEvent].Object);
                        break;

                    case XmlEventType.StartElem:
                        writer.WriteStartElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        break;

                    case XmlEventType.StartAttr:
                        writer.WriteStartAttribute(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        break;

                    case XmlEventType.EndAttr:
                        writer.WriteEndAttribute();
                        break;

                    case XmlEventType.CData:
                        writer.WriteCData(page[idxEvent].String1);
                        break;

                    case XmlEventType.Comment:
                        writer.WriteComment(page[idxEvent].String1);
                        break;

                    case XmlEventType.PI:
                        writer.WriteProcessingInstruction(page[idxEvent].String1, page[idxEvent].String2);
                        break;

                    case XmlEventType.Whitespace:
                        writer.WriteWhitespace(page[idxEvent].String1);
                        break;

                    case XmlEventType.String:
                        writer.WriteString(page[idxEvent].String1);
                        break;

                    case XmlEventType.Raw:
                        writer.WriteRaw(page[idxEvent].String1);
                        break;

                    case XmlEventType.EntRef:
                        writer.WriteEntityRef(page[idxEvent].String1);
                        break;

                    case XmlEventType.CharEnt:
                        writer.WriteCharEntity((char)page[idxEvent].Object);
                        break;

                    case XmlEventType.SurrCharEnt:
                        chars = (char[])page[idxEvent].Object;
                        writer.WriteSurrogateCharEntity(chars[0], chars[1]);
                        break;

                    case XmlEventType.Base64:
                        bytes = (byte[])page[idxEvent].Object;
                        writer.WriteBase64(bytes, 0, bytes.Length);
                        break;

                    case XmlEventType.BinHex:
                        bytes = (byte[])page[idxEvent].Object;
                        writer.WriteBinHex(bytes, 0, bytes.Length);
                        break;

                    case XmlEventType.XmlDecl1:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteXmlDeclaration((XmlStandalone)page[idxEvent].Object);
                        }
                        break;

                    case XmlEventType.XmlDecl2:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteXmlDeclaration(page[idxEvent].String1);
                        }
                        break;

                    case XmlEventType.StartContent:
                        if (rawWriter != null)
                        {
                            rawWriter.StartElementContent();
                        }
                        break;

                    case XmlEventType.EndElem:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        }
                        else
                        {
                            writer.WriteEndElement();
                        }
                        break;

                    case XmlEventType.FullEndElem:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteFullEndElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                        }
                        else
                        {
                            writer.WriteFullEndElement();
                        }
                        break;

                    case XmlEventType.Nmsp:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteNamespaceDeclaration(page[idxEvent].String1, page[idxEvent].String2);
                        }
                        else
                        {
                            writer.WriteAttributeString("xmlns", page[idxEvent].String1, XmlReservedNs.NsXmlNs, page[idxEvent].String2);
                        }
                        break;

                    case XmlEventType.EndBase64:
                        if (rawWriter != null)
                        {
                            rawWriter.WriteEndBase64();
                        }
                        break;

                    case XmlEventType.Close:
                        writer.Close();
                        break;

                    case XmlEventType.Flush:
                        writer.Flush();
                        break;

                    case XmlEventType.Dispose:
                        ((IDisposable)writer).Dispose();
                        break;

                    default:
                        Debug.Assert(false, "Unknown event: " + page[idxEvent].EventType);
                        break;
                    }
                }
            }

            Debug.Assert(false, "Unknown event should be added to end of event sequence.");
        }
Exemplo n.º 59
0
 /// <summary>
 /// Write element text
 /// </summary>
 /// <param name="writer">XML writer</param>
 protected override void WriteText(XmlWriter writer)
 {
     string text = Utils.To<string>(Value);
     if (text != null)
     {
         text = text.Trim() + Environment.NewLine;
         if (text.Length > 0)
         {
             if (text.IndexOfAny("><&".ToCharArray()) != -1)
             {
                 if (!text.Contains("?>"))
                     writer.WriteProcessingInstruction("_", text);
                 else
                     writer.WriteCData(text);
             }
             else
                 writer.WriteValue(text);
         }
     }
 }
Exemplo n.º 60
0
 public bool writeCdata(string content) => CheckedCall(() => _writer.WriteCData(content));