public void WriteTo(System.Xml.XmlWriter writer, bool includeWhitespace)
 {
     writer.WriteRaw("<?xml version=\"");
     writer.WriteRaw(_version);
     writer.WriteRaw("\" encoding=\"");
     writer.WriteRaw(_encoding);
     writer.WriteRaw("\" ?>");
 }
 /// <summary>
 /// Override the method to write the content to the xml dictionary writer.
 /// </summary>
 /// <param name="writer">Specify the output destination of the content.</param>
 protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
 {
     byte[] bytes = new byte[this.stream.Length];
     this.stream.Position = 0;
     this.stream.Read(bytes, 0, bytes.Length);
     writer.WriteRaw(this.encoding.GetString(bytes));
 }
        public override void WriteXml(System.Xml.XmlWriter writer)
        {
            XmlRootAttribute root = (XmlRootAttribute)this.GetType().GetCustomAttributes(typeof(XmlRootAttribute), true).First<object>();
            PropertyInfo[] properties = this.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
            PropertyInfo property = properties.First<PropertyInfo>(delegate(PropertyInfo prop){
               return prop.Name == "BaseUri" ;
            });
    
            XmlAttributeAttribute attribute = (XmlAttributeAttribute)property.GetCustomAttributes(typeof(XmlAttributeAttribute), true).Single<object>();
            writer.WriteAttributeString(attribute.AttributeName, WADLUtility.Url.CreateUrl(this.BaseUri.OriginalString, relativeUri));
    
            foreach (WADLMethod method in Methods)
            {
                using (MemoryStream mem = new MemoryStream())
                {
                    XmlSerializer rez = new XmlSerializer(typeof(WADLMethod),root.Namespace);
                    rez.Serialize(mem, method);
                    mem.Flush();
                    mem.Position = 0;
                    using (StreamReader sr = new StreamReader(mem))
                    {
                        sr.ReadLine();
                        writer.WriteRaw(sr.ReadToEnd());
                        sr.Close();
                    }
                    mem.Close();
                }
            }

        }
Example #4
0
		protected override void ExportData(System.Xml.XmlWriter writer, ExportContext context)
		{
			//-- For exmple:
			//   <Url authType="Forms">localhost:1315/</Url>
			//   <Url authType="Windows">name.server.xy</Url>

            writer.WriteRaw(GetRawXml());
		}
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     XElement element = WriteXml();
     foreach (IRuleNode list in RuleNodes)
     {
         element.Add(XElement.Parse(XmlHelper.ToXml(list)));
     }
     foreach (XAttribute attribute in element.Attributes())
     {
         writer.WriteAttributeString(attribute.Name.LocalName, attribute.Value);
     }
     writer.WriteRaw((String) element);
 }
 protected virtual void WriteDescription(
     System.Xml.XmlWriter xmlWriter,
     XCRI.Interfaces.XCRICAP12.IDescription description,
     string elementName,
     string elementNamespace
     )
 {
     if (description == null)
         throw new ArgumentNullException("description");
     if ((description.CompatibleWith & XCRIProfiles.XCRI_v1_2) == 0)
         return;
     this._WriteStartElement(xmlWriter, elementName, elementNamespace);
     this._WriteXsiTypeAttribute
         (
         xmlWriter,
         description.XsiTypeValue,
         description.XsiTypeValueNamespace
         );
     this._WriteXmlLanguageAttribute
         (
         xmlWriter,
         description.XmlLanguage
         );
     switch (description.ContentType)
     {
         case DescriptionContentTypes.Href:
             if (description.Href != null)
                 this._WriteAttribute
                     (
                     xmlWriter,
                     "href",
                     elementNamespace,
                     description.Href.ToString(),
                     String.Empty
                     );
             break;
         case DescriptionContentTypes.XHTML:
             this._WriteStartElement(xmlWriter, "div", Configuration.Namespaces.XHTMLNamespaceUri);
             if (!String.IsNullOrEmpty(description.Value))
                 xmlWriter.WriteRaw
                     (
                     description.Value
                     );
             this._WriteEndElement(xmlWriter);
             break;
         case DescriptionContentTypes.Text:
             xmlWriter.WriteValue
                 (
                 description.Value
                 );
             break;
     }
     this._WriteEndElement(xmlWriter);
 }
 protected virtual void _Write(
     System.Xml.XmlWriter xmlWriter,
     string elementName,
     string elementNamespace,
     string elementValue,
     bool renderRaw,
     string xsiType,
     string xsiTypeNamespace,
     string xmlLanguage
     )
 {
     this._WriteStartElement(xmlWriter, elementName, elementNamespace);
     this._WriteXsiTypeAttribute
         (
         xmlWriter,
         xsiType,
         xsiTypeNamespace
         );
     this._WriteXmlLanguageAttribute
         (
         xmlWriter,
         xmlLanguage
         );
     if (!String.IsNullOrEmpty(elementValue))
     {
         if (renderRaw)
             xmlWriter.WriteRaw
                 (
                 elementValue
                 );
         else
             xmlWriter.WriteValue
                 (
                 elementValue
                 );
     }
     this._WriteEndElement(xmlWriter);
 }
Example #8
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Get an instance ref
            ED instance_ed = (ED)o;

            // Do a base format
            ANYFormatter baseFormatter = new ANYFormatter();
            baseFormatter.Graph(s, o, result);

            // Null flavor
            if (((ANY)o).NullFlavor != null)
            {
                return;
            }

            // Attributes
            if (instance_ed.MediaType != null && instance_ed.Representation != EncapsulatedDataRepresentation.TXT)
                s.WriteAttributeString("mediaType", instance_ed.MediaType);
            if (instance_ed.Language != null)
                s.WriteAttributeString("language", instance_ed.Language);
            if (instance_ed.Compression != null)
                s.WriteAttributeString("compression", Util.ToWireFormat(instance_ed.Compression));
            if (instance_ed.IntegrityCheckAlgorithm != null)
                s.WriteAttributeString("integrityCheckAlgorithm", Util.ToWireFormat(instance_ed.IntegrityCheckAlgorithm));

            Encoding textEncoding = System.Text.Encoding.UTF8;

            // Representation of data
            if(instance_ed.Data != null && instance_ed.Data.Length > 0)
                switch(instance_ed.Representation)
                {
                    case EncapsulatedDataRepresentation.TXT:
                        s.WriteAttributeString("value", textEncoding.GetString(instance_ed.Data));
                        break;
                    case EncapsulatedDataRepresentation.B64:
                        s.WriteStartElement("data", "urn:hl7-org:v3");
                        s.WriteBase64(instance_ed.Data, 0, instance_ed.Data.Length);
                        s.WriteEndElement();// data
                        break;
                    case EncapsulatedDataRepresentation.XML:
                        s.WriteStartElement("xml", "urn:hl7-org:v3");
                        s.WriteRaw(instance_ed.XmlData.OuterXml);
                        s.WriteEndElement(); // xml
                        break;
                }

            // Elements
            if (instance_ed.Reference != null)
            {
                s.WriteStartElement("reference", "urn:hl7-org:v3");
                var hostResult = Host.Graph(s, instance_ed.Reference);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            if (instance_ed.IntegrityCheck != null && instance_ed.IntegrityCheck.Length > 0)
            {
                s.WriteStartElement("integrityCheck", "urn:hl7-org:v3");
                s.WriteBase64(instance_ed.IntegrityCheck, 0, instance_ed.IntegrityCheck.Length);
                s.WriteEndElement(); // intcheck
            }
            if (instance_ed.Thumbnail != null)
            {
                s.WriteStartElement("thumbnail", "urn:hl7-org:v3");
                var hostResult = Host.Graph(s, instance_ed.Thumbnail);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);

                s.WriteEndElement();
            }
            if (instance_ed.Description != null)
            {
                s.WriteStartElement("description", "urn:hl7-org:v3");
                var hostResult = Host.Graph(s, instance_ed.Description);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            if (instance_ed.Translation != null && !instance_ed.Translation.IsNull)
            {
                foreach (var trans in instance_ed.Translation)
                {
                    s.WriteStartElement("translation", "urn:hl7-org:v3");
                    var hostResult = Host.Graph(s, trans);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement(); // translation
                }
            }

        }
Example #9
0
		public bool OutputXml(System.Xml.XmlTextWriter xmlOutput, bool useXmlLangValue)
		{
			if (xmlOutput != null)
			{
				m_UseXmlLangValue = useXmlLangValue;
				xmlOutput.WriteRaw(ToXmlString());
				xmlOutput.WriteRaw(System.Environment.NewLine);
				m_UseXmlLangValue = false;
			}
			return true;
		}
        public override void WriteXml(System.Xml.XmlWriter writer)
        {
            
            XmlRootAttribute root = (XmlRootAttribute)this.GetType().GetCustomAttributes(typeof(XmlRootAttribute), true).First<object>();
            PropertyInfo[] properties = this.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
            PropertyInfo name = properties.First<PropertyInfo>(delegate(PropertyInfo prop)
            {
                return prop.Name == "MethodName";
            });

            var Fs = (from parameter in Parameters
                      select parameter).Where<WADLParam>(delegate(WADLParam attribute)
                      {
                          return attribute.Style == ParamStyles.Form;
                      });

            var Qs = (from parameter in Parameters
                      select parameter).Where<WADLParam>(delegate(WADLParam attribute)
                      {
                          return attribute.Style == ParamStyles.Query ;
                      });
            
            var Qh = (from parameter in Parameters
                      select parameter).Where<WADLParam>(delegate(WADLParam attribute)
                      {
                          return attribute.Style == ParamStyles.Header;
                      });

            var Pp = (from parameter in Parameters
                      select parameter).Where<WADLParam>(delegate(WADLParam attribute)
                      {
                          return attribute.Style == ParamStyles.Template;
                      });

            string path = String.IsNullOrEmpty(this.MethodName) ? "/" : this.MethodName == "/"?"/":String.Concat("/", this.MethodName);
            foreach (WADLParam pathAttribute in Pp)
            {
                path = String.Concat(path,path.EndsWith("/")?"{":"/{", pathAttribute.Name, "}");           
            }

            string query = String.Empty;
            foreach (WADLParam pathAttribute in Qs)
            {
                query = String.Concat(query, String.IsNullOrEmpty(query) ? "?" : "&", pathAttribute.Name, "={", pathAttribute.Name, "}");
            }

            path = String.Concat(path,query);

            if (name.GetCustomAttributes(typeof(XmlAttributeAttribute), true).Length == 1 && !String.IsNullOrEmpty(path))
            {
                XmlAttributeAttribute attribute = (XmlAttributeAttribute)name.GetCustomAttributes(typeof(XmlAttributeAttribute), true).First<object>();
                writer.WriteAttributeString("path", path);
            }

            foreach (WADLAttribute pathAttribute in Pp)
            {
                using (MemoryStream mem = new MemoryStream())
                {
                    XmlSerializer rez = new XmlSerializer(typeof(WADLParam), root.Namespace);
                    rez.Serialize(mem, pathAttribute);
                    mem.Flush();
                    mem.Position = 0;
                    using (StreamReader sr = new StreamReader(mem))
                    {
                        sr.ReadLine();
                        writer.WriteRaw(sr.ReadToEnd());
                        sr.Close();
                    }
                    mem.Close();
                }
            }

            writer.WriteStartElement("method");
            foreach (PropertyInfo property in properties)
            {
                if (property.GetCustomAttributes(typeof(XmlAttributeAttribute), true).Length == 1 && property.Name != "MethodName" )
                {
                    XmlAttributeAttribute attribute = (XmlAttributeAttribute)property.GetCustomAttributes(typeof(XmlAttributeAttribute), true).First<object>();
                    writer.WriteAttributeString(attribute.AttributeName,property.GetValue(this, null).ToString());
                }
            }

            if (Doc != null)
            {
                using (MemoryStream mem = new MemoryStream())
                {
                    XmlSerializer rez = new XmlSerializer(typeof(WADLDoc), root.Namespace);
                    rez.Serialize(mem, doc);
                    mem.Flush();
                    mem.Position = 0;
                    using (StreamReader sr = new StreamReader(mem))
                    {
                        sr.ReadLine();
                        writer.WriteRaw(sr.ReadToEnd());
                        sr.Close();
                    }
                    mem.Close();
                }

            }

            writer.WriteStartElement("request");
            foreach (WADLParam parameter in Fs)
            {
                using (MemoryStream mem = new MemoryStream())
                {
                    XmlSerializer rez = new XmlSerializer(typeof(WADLParam), root.Namespace);
                    rez.Serialize(mem, parameter);
                    mem.Flush();
                    mem.Position = 0;
                    using (StreamReader sr = new StreamReader(mem))
                    {
                        sr.ReadLine();
                        writer.WriteRaw(sr.ReadToEnd());
                        sr.Close();
                    }
                    mem.Close();
                }
            }
            foreach (WADLParam parameter in Qs)
            {
                using (MemoryStream mem = new MemoryStream())
                {
                    XmlSerializer rez = new XmlSerializer(typeof(WADLParam), root.Namespace);
                    rez.Serialize(mem, parameter);
                    mem.Flush();
                    mem.Position = 0;
                    using (StreamReader sr = new StreamReader(mem))
                    {
                        sr.ReadLine();
                        writer.WriteRaw(sr.ReadToEnd());
                        sr.Close();
                    }
                    mem.Close();
                }
            }
            writer.WriteEndElement();
            writer.WriteStartElement("response");

            foreach (WADLParam parameter in headers)
            {
                using (MemoryStream mem = new MemoryStream())
                {
                    XmlSerializer rez = new XmlSerializer(typeof(WADLParam), root.Namespace);
                    rez.Serialize(mem, parameter);
                    mem.Flush();
                    mem.Position = 0;
                    using (StreamReader sr = new StreamReader(mem))
                    {
                        sr.ReadLine();
                        writer.WriteRaw(sr.ReadToEnd());
                        sr.Close();
                    }
                    mem.Close();
                }
            }

            #region comment
            //foreach (WADLFault fault in faults)
            //{
            //    using (MemoryStream mem = new MemoryStream())
            //    {
            //        XmlSerializer rez = new XmlSerializer(typeof(WADLFault), root.Namespace);
            //        rez.Serialize(mem, fault);
            //        mem.Flush();
            //        mem.Position = 0;
            //        using (StreamReader sr = new StreamReader(mem))
            //        {
            //            sr.ReadLine();
            //            writer.WriteRaw(sr.ReadToEnd());
            //            sr.Close();
            //        }
            //        mem.Close();
            //    }
            //}
            #endregion

            foreach (WADLRepresentation representation in representations)
            {
                using (MemoryStream mem = new MemoryStream())
                {
                    XmlSerializer rez = new XmlSerializer(typeof(WADLRepresentation), root.Namespace);
                    rez.Serialize(mem, representation);
                    mem.Flush();
                    mem.Position = 0;
                    using (StreamReader sr = new StreamReader(mem))
                    {
                        sr.ReadLine();
                        writer.WriteRaw(sr.ReadToEnd());
                        sr.Close();
                    }
                    mem.Close();
                }
            }
            writer.WriteEndElement();
            writer.WriteEndElement();
        }
Example #11
0
		private void OutputErrorElement(System.Xml.XmlTextWriter xmlOutput)
		{
			// put out the errors
			int ttlErrors = m_FatalErrors.Count + m_Errors.Count;	// fatal and reg errors
			xmlOutput.WriteStartElement("Errors");
			xmlOutput.WriteAttributeString("count", ttlErrors.ToString());
			if (m_FatalErrors.Count > NumErrorsWithInfo || m_Errors.Count > NumErrorsWithInfo)
			{
				int ttl = 0;
				if (m_FatalErrors.Count > NumErrorsWithInfo)
					ttl += NumErrorsWithInfo;
				else
					ttl +=m_FatalErrors.Count;

				if (m_Errors.Count > NumErrorsWithInfo)
					ttl += NumErrorsWithInfo;
				else
					ttl +=m_Errors.Count;

				xmlOutput.WriteAttributeString("listed", ttl.ToString());
			}
//			foreach (string msg in m_FatalErrors)
			foreach (WrnErrInfo info in m_FatalErrors)
			{
				if (info == null)	// end of real messages, rest are null for a total count
					break;
				xmlOutput.WriteStartElement("Error");
				xmlOutput.WriteAttributeString("File", info.FileName);
				xmlOutput.WriteAttributeString("Line", info.LineNumber.ToString());
				xmlOutput.WriteRaw(info.Message);
				xmlOutput.WriteEndElement();
			}
			foreach (WrnErrInfo info in m_Errors)
			{
				if (info == null)	// end of real messages, rest are null for a total count
					break;
				xmlOutput.WriteStartElement("Error");
				xmlOutput.WriteAttributeString("File", info.FileName);
				xmlOutput.WriteAttributeString("Line", info.LineNumber.ToString());
				xmlOutput.WriteRaw(info.Message);
				xmlOutput.WriteEndElement();
			}
			xmlOutput.WriteEndElement();
		}
 /// <summary>
 /// Writes the XML representation of the answer.
 /// </summary>
 /// <param name="writer">The XmlWriter to which to write the answer value.</param>
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteWhitespace("\n\t\t"); // To go the extra mile, figure out how many tab characters to use
     writer.WriteRaw(_outerXml);
     writer.WriteWhitespace("\n\t\t"); // To go the extra mile, figure out how many tab characters to use
 }
Example #13
0
            public void WriteXml(System.Xml.XmlWriter writer)
            {
                try
                {
                    foreach (System.Data.DataRow dr in m_schema.Rows)
                    {
                        string columnName = System.Convert.ToString(dr["column_name"]);
                        string entityType = System.Convert.ToString(dr["EntityType"]);
                        string data = null;

                        // 2014-11-26T12:30:53.967
                        if (object.ReferenceEquals(m_data.Table.Columns[columnName].DataType, typeof(DateTime)))
                        {
                            if (m_data[columnName] == System.DBNull.Value)
                                data = null;
                            else
                            {
                                System.DateTime dat = (System.DateTime)m_data[columnName];
                                data = dat.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff", System.Globalization.CultureInfo.InvariantCulture);
                            }
                        }
                        else if (object.ReferenceEquals(m_data.Table.Columns[columnName].DataType, typeof(byte[])))
                        {
                            if (m_data[columnName] != System.DBNull.Value)
                            {
                                byte[] dat = (byte[])m_data[columnName];

                                if (dat != null)
                                {
                                    data = System.Convert.ToBase64String(dat);
                                }
                            }

                        }
                        else
                            data = System.Convert.ToString(m_data[columnName], System.Globalization.CultureInfo.InvariantCulture);

                        // LoLz
                        if (IsDevelopment)
                            OptionallyDecryptPassword(ref data, columnName);

                        writer.WriteStartElement("d:" + columnName);

                        if (!StringComparer.Ordinal.Equals(entityType, "Edm.String"))
                            writer.WriteAttributeString("m:type", entityType);

                        if (string.IsNullOrEmpty(data))
                            writer.WriteAttributeString("m:null", "true");

                        if (data != null)
                        {
                            // writer.WriteValue(data);

                            if(System.StringComparer.OrdinalIgnoreCase.Equals(columnName, "KU_Bemerkung") )
                                System.Console.WriteLine(data);

                            // string str = System.Security.SecurityElement.Escape(data)
                            string str = m_XmlEndcoder.XmlEscape(data);
                            writer.WriteRaw(str);
                        }

                        writer.WriteEndElement();
                    } // Next dr

                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                    throw;
                }

                //// <d:AD_UID m:type="Edm.Guid">6d12a79a-033d-4ca4-8e48-4a5eaa6f6aad</d:AD_UID>
                //writer.WriteStartElement("d:" + "AD_UID");
                //writer.WriteAttributeString("m:type", "Edm.Guid");
                //writer.WriteValue(System.Guid.NewGuid().ToString());
                //writer.WriteEndElement();

                ////<d:AD_User>hbd_cafm</d:AD_User>
                //writer.WriteStartElement("d:" + "AD_User");
                //writer.WriteValue("hbd_cafm");
                //writer.WriteEndElement();

                //// <d:AD_Password>DrpC0u2ZJp0=</d:AD_Password>
                //writer.WriteStartElement("d:" + "AD_Password");
                //writer.WriteValue("DrpC0u2ZJp0=");
                //writer.WriteEndElement();

                //// <d:AD_Level m:type="Edm.Byte">1</d:AD_Level>
                //writer.WriteStartElement("d:" + "AD_Level");
                //writer.WriteAttributeString("m:type", "Edm.Byte");
                //writer.WriteValue(1);
                //writer.WriteEndElement();
            }
Example #14
0
		/// <summary>
		/// Export the specified cell to HTML
		/// </summary>
		/// <param name="context"></param>
		/// <param name="writer"></param>
		protected virtual void ExportHTMLCell(CellContext context, System.Xml.XmlTextWriter writer)
		{
			if (context.Cell == null)
			{
				//start element td
				writer.WriteStartElement("td");
				writer.WriteRaw("&nbsp;");
			}
			else
			{
				#region TD style
				Range rangeCell = context.Grid.PositionToCellRange(context.Position);
				if (rangeCell.Start != context.Position)
					return;

				//start element td
				writer.WriteStartElement("td");

				//check for rowspan and colspan 
				if (rangeCell.ColumnsCount > 1 || rangeCell.RowsCount > 1)
				{
					//colspan, rowspan
					writer.WriteAttributeString("colspan", rangeCell.ColumnsCount.ToString() );
					writer.WriteAttributeString("rowspan", rangeCell.RowsCount.ToString() );
				}

				if (context.Cell.View is Cells.Views.Cell)
				{
					Cells.Views.Cell viewCell = (Cells.Views.Cell)context.Cell.View;

					//write backcolor
					if ( (Mode & ExportHTMLMode.CellBackColor) == ExportHTMLMode.CellBackColor)
					{
						writer.WriteAttributeString("bgcolor", ColorToHTML(context.Cell.View.BackColor) );
					}

					string l_Style = "";

					//border
					l_Style = BorderToHTMLStyle(viewCell.Border);

					//style
					writer.WriteAttributeString("style", l_Style);

					//alignment
					writer.WriteAttributeString("align", DevAge.Windows.Forms.Utilities.ContentToHorizontalAlignment(viewCell.TextAlignment).ToString().ToLower());
					if (DevAge.Drawing.Utilities.IsBottom(viewCell.TextAlignment))
						writer.WriteAttributeString("valign", "bottom");
					else if (DevAge.Drawing.Utilities.IsTop(viewCell.TextAlignment))
						writer.WriteAttributeString("valign", "top");
					else if (DevAge.Drawing.Utilities.IsMiddle(viewCell.TextAlignment))
						writer.WriteAttributeString("valign", "middle");
				}
				#endregion

				if (context.Cell.View is Cells.Views.CheckBox)
				{
					Cells.Models.ICheckBox checkModel = (Cells.Models.ICheckBox)context.Cell.Model.FindModel(typeof(Cells.Models.ICheckBox));
					Cells.Models.CheckBoxStatus status = checkModel.GetCheckBoxStatus(context);
					if (status.Checked == true)
						writer.WriteRaw("<input type=\"checkbox\" checked>");
					else
						writer.WriteRaw("<input type=\"checkbox\">");
				}

				#region Font
				if (context.Cell.View is Cells.Views.Cell)
				{
					//Read the image
					System.Drawing.Image img = null;
					Cells.Models.IImage imgModel = (Cells.Models.IImage)context.Cell.Model.FindModel(typeof(Cells.Models.IImage));
					if (imgModel != null)
						img = imgModel.GetImage(context);


					Cells.Views.Cell viewCell = (Cells.Views.Cell)context.Cell.View;

					if (img != null )
					{
						writer.WriteStartElement("img");

						writer.WriteAttributeString("align", DevAge.Windows.Forms.Utilities.ContentToHorizontalAlignment(viewCell.ImageAlignment).ToString().ToLower());
						writer.WriteAttributeString("src", ExportImage(img));

						//img
						writer.WriteEndElement();
					}

					writer.WriteStartElement("font");

					writer.WriteAttributeString("color", ColorToHTML(viewCell.ForeColor));

					ExportHTMLCellContent(context, writer);

					//font
					writer.WriteEndElement();
				}
				else
					ExportHTMLCellContent(context, writer);
				#endregion

				//td
				writer.WriteEndElement();
			}
		}
        public override void WriteUserDefinedContent(System.Xml.XmlWriter writer, System.Type classType, System.Type contentAttributeType, BaseAttribute parentAttribute)
        {
            base.WriteUserDefinedContent(writer, classType, contentAttributeType, parentAttribute);

            if (contentAttributeType == null && !DoNotAutoDetectClassName) // First time that this method is called for this class
            {
                var classAttribute = parentAttribute as ClassAttribute;
                if (classAttribute != null)
                {
                    if (classAttribute.EntityName == null && classAttribute.Name == null)
                        writer.WriteAttributeString("name", HbmWriterHelper.GetNameWithAssembly(classType));
                }
                var subclassAttribute = parentAttribute as SubclassAttribute;
                if (subclassAttribute != null)
                {
                    if (subclassAttribute.EntityName == null && subclassAttribute.Name == null)
                        writer.WriteAttributeString("name", HbmWriterHelper.GetNameWithAssembly(classType));
                }
                var joinedSubclassAttribute = parentAttribute as JoinedSubclassAttribute;
                if (joinedSubclassAttribute != null)
                {
                    if (joinedSubclassAttribute.EntityName == null && joinedSubclassAttribute.Name == null)
                        writer.WriteAttributeString("name", HbmWriterHelper.GetNameWithAssembly(classType));
                }
                var unionSubclassAttribute = parentAttribute as UnionSubclassAttribute;
                if (unionSubclassAttribute != null)
                {
                    if (unionSubclassAttribute.EntityName == null && unionSubclassAttribute.Name == null)
                        writer.WriteAttributeString("name", HbmWriterHelper.GetNameWithAssembly(classType));
                }
            }

            // Insert [RawXml] after the specified type of attribute
            System.Collections.ArrayList RawXmlAttributedMembersList = FindSystemAttributedMembers( typeof(RawXmlAttribute), classType );
            foreach( System.Reflection.MemberInfo member in RawXmlAttributedMembersList )
            {
                RawXmlAttribute rawXml = member.GetCustomAttributes(typeof(RawXmlAttribute), false)[0] as RawXmlAttribute;
                if(contentAttributeType != rawXml.After)
                    continue;
                if(rawXml.Content==null)
                    throw new MappingException("You must specify the content of the RawXmlAttribute on the member: " + member.Name + " of the class " + member.DeclaringType.FullName);

                System.Xml.XmlTextWriter textWriter = writer as System.Xml.XmlTextWriter;
                if(textWriter != null) // TODO: Hack to restore indentation after writing the raw XML
                {
                    textWriter.WriteStartElement("!----"); // Write <!---->
                    textWriter.Flush();
                    textWriter.BaseStream.Flush(); // Note: Seek doesn't work properly here; so the started elt can't be removed
                }

                writer.WriteRaw(rawXml.Content);

                if(textWriter != null) // TODO: Hack to restore indentation after writing the raw XML
                {
                    textWriter.WriteEndElement();
                    textWriter.Flush();
                    textWriter.BaseStream.Flush();
                    textWriter.BaseStream.Seek(-8, System.IO.SeekOrigin.Current); // Remove </!---->
                }
            }

            if(contentAttributeType == typeof(ComponentAttribute))
            {
                System.Collections.ArrayList ComponentPropertyList = FindSystemAttributedMembers( typeof(ComponentPropertyAttribute), classType );
                foreach( System.Reflection.MemberInfo member in ComponentPropertyList )
                {
                    object[] objects = member.GetCustomAttributes(typeof(ComponentPropertyAttribute), false);
                    WriteComponentProperty(writer, member, objects[0] as ComponentPropertyAttribute, parentAttribute);
                }
            }

            if(contentAttributeType == typeof(CacheAttribute))
            {
                object[] attributes = classType.GetCustomAttributes(typeof(CacheAttribute), false);
                if(attributes.Length > 0)
                    WriteCache(writer, null, (CacheAttribute)attributes[0], parentAttribute, classType);
            }
            if(contentAttributeType == typeof(DiscriminatorAttribute))
            {
                object[] attributes = classType.GetCustomAttributes(typeof(DiscriminatorAttribute), false);
                if(attributes.Length > 0)
                    WriteDiscriminator(writer, null, (DiscriminatorAttribute)attributes[0], parentAttribute, classType);
            }
            if(contentAttributeType == typeof(KeyAttribute))
            {
                object[] attributes = classType.GetCustomAttributes(typeof(KeyAttribute), false);
                if(attributes.Length > 0)
                    WriteKey(writer, null, (KeyAttribute)attributes[0], parentAttribute, classType);
            }
        }
Example #16
0
		/// <summary>
		/// Used to Display a Tree Like View of how the Nodes are organized.
		/// </summary>
		/// <param name="writer"></param>
		/// <param name="Position"></param>
		public void Tree(System.Xml.XmlTextWriter xmlwriter, int position)
		{
			if (position == 0)
			{
				xmlwriter.WriteStartDocument();
				xmlwriter.WriteStartElement(this.NameType.ToString());
				xmlwriter.WriteRaw(System.Environment.NewLine);
			}

			string f = this.FileName;
			xmlwriter.WriteStartElement(this.NameType.ToString());
			xmlwriter.WriteAttributeString("FileName", f);
			xmlwriter.WriteAttributeString("ID", this.Id);
			xmlwriter.WriteRaw(System.Environment.NewLine);

			if (position != int.MaxValue)
			{
				position++;
			}
			for (int i = 0;i <= DefaultChildren.Count - 1;i++)
			{
				string key = (string)DefaultChildrenKeys[i];
				Node node = DefaultChildren[key];
				if (node.NameType == nBrowser.NodeType.DefaultBrowser)
				{
					node.Tree(xmlwriter, position);
				}
			}

			for (int i = 0;i <= Children.Count - 1;i++)
			{
				string key = (string)ChildrenKeys[i];
				Node node = Children[key];
				if (node.NameType == nBrowser.NodeType.Gateway)
				{
					node.Tree(xmlwriter, position);
				}
			}

			for (int i = 0;i <= Children.Count - 1;i++)
			{
				string key = (string)ChildrenKeys[i];
				Node node = Children[key];
				if (node.NameType == nBrowser.NodeType.Browser)
				{
					node.Tree(xmlwriter, position);
				}
			}
			if (position != int.MinValue)
			{
				position--;
			}
			xmlwriter.WriteEndElement();
			xmlwriter.WriteRaw(System.Environment.NewLine);
			if (position == 0)
			{
				xmlwriter.WriteEndDocument();
				xmlwriter.Flush();
			}
		}
Example #17
0
 protected override void WriteXmlData(System.Xml.XmlWriter writer)
 {
     writer.WriteRaw(GetRawXml());
 }
Example #18
0
		protected string ToXmlBaseString(bool useXMLLang, System.Xml.XmlTextWriter xmlOutput)
		{
			string result = "<field ";
			result += "sfm=\"" + m_Sfm + "\" ";

			if (m_AutoSfm.Length > 0)
				result += "autoSfm=\"" + m_AutoSfm + "\" ";

			result += "name=\"" + m_Name + "\" ";
			result += "type=\"" + m_Type + "\" ";
			if (xmlOutput != null)
			{
				xmlOutput.WriteStartElement("field");
				xmlOutput.WriteAttributeString("sfm", m_Sfm);
				if (m_AutoSfm.Length > 0)
					xmlOutput.WriteAttributeString("autoSfm", m_AutoSfm);
				xmlOutput.WriteAttributeString("name", m_Name);
				xmlOutput.WriteAttributeString("type", m_Type);
			}

			if (useXMLLang)
			{
				result += "xml:lang=\"" + m_xmlLanguage + "\" ";
				if (xmlOutput != null)
					xmlOutput.WriteAttributeString("xml:lang", m_xmlLanguage);
			}
			else
			{
				result += "lang=\"" + m_Language + "\" ";
				if (xmlOutput != null)
					xmlOutput.WriteAttributeString("lang", m_Language);
			}

			if (IsAbbrField)	// only put out if it's a field that can have the abbr attribute
			{
				result += "abbr=\"";
				if (m_Abbr)
					result += "True";
				else
					result += "False";
				result += "\" ";

				if (xmlOutput != null)
					xmlOutput.WriteAttributeString("abbr", m_Abbr?"True":"False");
			}

			if (IsExcluded)	// only put out if true
			{
				result += "exclude=\"True\" ";
				if (xmlOutput != null)
					xmlOutput.WriteAttributeString("exclude", "True");
			}

			if (IsAutoImportField)	// only put out if true
			{
				result += "autoImport=\"True\" ";
				if (xmlOutput != null)
					xmlOutput.WriteAttributeString("autoImport", "True");

				if (m_autoFieldClass.Length > 0)
				{
					result += "autoImportClassName=\"" + m_autoFieldClass + "\" ";
					if (xmlOutput != null)
						xmlOutput.WriteAttributeString("autoImportClassName", m_autoFieldClass);
				}
			}

			result += m_OtherAttributes + ">" + System.Environment.NewLine;
			result += m_Meaning + System.Environment.NewLine;
			result += "</field>";
			if (xmlOutput != null)
			{
				if (m_OtherAttributes.Length > 0)
					xmlOutput.WriteRaw(m_OtherAttributes);
				RebuildMeaningEntry(xmlOutput, DefaultTopAnalysisWS);		// puts out the meaning element
				xmlOutput.WriteEndElement();		// end the field element
			}
			return result;
		}
        public override void buildXml(System.Xml.XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("messageBody");
                xmlWriter.WriteElementString("msg_type", "gridCalculation");
                xmlWriter.WriteStartElement("gridCalculation");
            
                    xmlWriter.WriteElementString("inst_code", this.inst_code_);
                    xmlWriter.WriteElementString("inst_name", this.inst_name_);
                    xmlWriter.WriteElementString("inst_type", this.inst_type_);
                    xmlWriter.WriteElementString("para_refDate", StringConverter.xmlDateTimeToDateString(this.para_refDate_));

                    xmlWriter.WriteStartElement("productInnerXml");
                        xmlWriter.WriteRaw(this.InnerXml_);
                        
                    xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
            xmlWriter.WriteEndElement();
        }
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            if (FeedType != FeedType.ResourceEntry && FeedType != FeedType.LinkedSingle)
            {
                writer.WriteStartElement("feed", Namespaces.atomNamespace);
                writer.WriteElementString("title", Namespaces.atomNamespace, this.Title);
                writer.WriteElementString("id", Namespaces.atomNamespace, this.Id);
                foreach (FeedLink link in this.Links)
                {
                    writer.WriteStartElement("link", Namespaces.atomNamespace);
                    writer.WriteAttributeString("rel", link.LinkType.ToString().ToLower());
            #warning get xmlenum descrition
                    writer.WriteAttributeString("type", link.Type.ToString());
                    writer.WriteAttributeString("title", link.Title);
                    writer.WriteAttributeString("href", link.Uri);
                    writer.WriteEndElement();
                }

                /* OPENSEARCH */
                if (null != this.Opensearch_ItemsPerPageElement)
                    writer.WriteRaw(this.Opensearch_ItemsPerPageElement.ToXml());
                if (null != this.Opensearch_StartIndexElement)
                    writer.WriteRaw(this.Opensearch_StartIndexElement.ToXml());
                if (null != this.Opensearch_TotalResultsElement)
                    writer.WriteRaw(this.Opensearch_TotalResultsElement.ToXml());

                #region SyncDigest

                if (this.FeedType == FeedType.SyncSource)
                {
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(SyncFeedDigest));
                    serializer.Serialize(writer, this.Digest);
                }

                #endregion
            }
            foreach (object entryObj in this.Entries)
            {
                if (entryObj is SyncFeedEntry)
                    (entryObj as SyncFeedEntry).WriteXml(writer, this.FeedType);
            }
            if (FeedType != FeedType.ResourceEntry && FeedType != FeedType.LinkedSingle)
            {
                writer.WriteEndElement();
            }
        }
Example #21
0
        /// <summary>
        /// Graph the object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        /// <param name="s">The XmlWriter to write the object to</param>
        /// <param name="o">The object to graph</param>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            // Get an instance ref
            ED instance_ed = (ED)o;

            // Do a base format
            ANYFormatter baseFormatter = new ANYFormatter();
            baseFormatter.Graph(s, o, result);

            // Null flavor
            if (((ANY)o).NullFlavor != null)
            {
                return;
            }

            // Attributes
            s.WriteAttributeString("representation", Util.ToWireFormat(instance_ed.Representation));
            if (instance_ed.MediaType != null)
                s.WriteAttributeString("mediaType", Util.ToWireFormat(instance_ed.MediaType));
            if (instance_ed.Language != null)
                s.WriteAttributeString("language", instance_ed.Language);
            if (instance_ed.Compression != null)
                s.WriteAttributeString("compression", Util.ToWireFormat(instance_ed.Compression));
            if (instance_ed.IntegrityCheck != null)
                s.WriteAttributeString("integrityCheck", Convert.ToBase64String(instance_ed.IntegrityCheck));
            if (instance_ed.Description != null)
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Description", "ED", s.ToString()));
            if (instance_ed.IntegrityCheckAlgorithm != null)
            {
                // Incorrect representation of the SHA1 and SHA256 names in r1
                switch ((EncapsulatedDataIntegrityAlgorithm)instance_ed.IntegrityCheckAlgorithm)
                {
                    case EncapsulatedDataIntegrityAlgorithm.SHA1:
                        s.WriteAttributeString("integrityCheckAlgorithm", "SHA-1");
                        break;
                    case EncapsulatedDataIntegrityAlgorithm.SHA256:
                        s.WriteAttributeString("integrityCheckAlgorithm", "SHA-256");
                        break;
                }
            }

            // Elements
            if (instance_ed.Reference != null)
            {
                TELFormatter refFormatter = new TELFormatter();
                s.WriteStartElement("reference", "urn:hl7-org:v3");
                refFormatter.Graph(s, instance_ed.Reference, result);
                s.WriteEndElement();
            }
            if (instance_ed.Thumbnail != null)
            {
                EDFormatter thumbFormatter = new EDFormatter();
                s.WriteStartElement("thumbnail", "urn:hl7-org:v3");
                thumbFormatter.Graph(s, instance_ed.Thumbnail, result);
                s.WriteEndElement();
            }
            if (instance_ed.Translation != null)
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Translation", "ED", s.ToString()));
            Encoding textEncoding = System.Text.Encoding.UTF8;

            // Value
            if (instance_ed.Data != null && instance_ed.Data.Length > 0)
            {
                if (instance_ed.Representation == EncapsulatedDataRepresentation.B64)
                    s.WriteBase64(instance_ed.Data, 0, instance_ed.Data.Length);
                else if (instance_ed.Representation == EncapsulatedDataRepresentation.TXT)
                    s.WriteString(textEncoding.GetString(instance_ed.Data));
                else
                {
                    char[] charBuffer = textEncoding.GetChars(instance_ed.Data);
                    s.WriteRaw(charBuffer, 0, charBuffer.Length);
                }
            }
        }
Example #22
0
		/// <summary>
		/// Export a font html element with the specified font and text
		/// </summary>
		/// <param name="p_Writer"></param>
		/// <param name="p_DisplayText"></param>
		/// <param name="p_Font"></param>
		public static void ExportHTML_Element_Font(System.Xml.XmlTextWriter p_Writer, string p_DisplayText, System.Drawing.Font p_Font)
		{
			if (p_Font != null)
			{
				p_Writer.WriteAttributeString("style","font-size:" + p_Font.SizeInPoints + "pt");

				if (p_Font.Bold)
					p_Writer.WriteStartElement("b");

				if (p_Font.Underline)
					p_Writer.WriteStartElement("u");

				if (p_Font.Italic)
					p_Writer.WriteStartElement("i");
			}

			//displaytext
			if (p_DisplayText == null || p_DisplayText.Trim().Length <= 0)
				p_Writer.WriteRaw("&nbsp;");
			else
			{
				//l_Display = l_Display.Replace("\r\n","<br>");
				p_Writer.WriteString(p_DisplayText);
			}

			if (p_Font != null)
			{
				//i
				if (p_Font.Italic)
					p_Writer.WriteEndElement();

				//u
				if (p_Font.Underline)
					p_Writer.WriteEndElement();

				//b
				if (p_Font.Bold)
					p_Writer.WriteEndElement();
			}
		}
Example #23
0
 protected override void ExportData(System.Xml.XmlWriter writer, ExportContext context)
 {
     writer.WriteRaw(GetRawXml());
 }
Example #24
0
 public override void WriteTo(System.Xml.XmlWriter writer)
 {
     writer.WriteRaw(this.Value);
 }
 protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
 {
     writer.WriteRaw(_msg);
 }
Example #26
0
		private void OutputWarningElement(System.Xml.XmlTextWriter xmlOutput)
		{
			int ttlWarnings = m_Warnings.Count;// + m_sfmsWithOutData;	// warnings and sfm's w/o data
			xmlOutput.WriteStartElement("Warnings");
			xmlOutput.WriteAttributeString("count", ttlWarnings.ToString());
			foreach (WrnErrInfo info in m_Warnings)
			{
				if (info == null)	// end of real messages, rest are null for a total count
					break;
				xmlOutput.WriteStartElement("Warning");
				xmlOutput.WriteAttributeString("File", info.FileName);
				xmlOutput.WriteAttributeString("Line", info.LineNumber.ToString());
				xmlOutput.WriteRaw(info.Message);
				xmlOutput.WriteEndElement();
			}
			xmlOutput.WriteEndElement();
		}
        /// <summary>
        /// Converts a TimeChangeType object into its XML representation
        /// </summary>
        /// <param name="writer">XmlWriter positioned at the point 
        /// to which the XML for this object is to be written to
        /// </param>
        public void WriteXml(System.Xml.XmlWriter writer)
        {
            string xsTypes =
                "http://schemas.microsoft.com/exchange/services/2006/types";

            // Our position in the writer already includes a StartElement
            // for our type, therefore, our job is to pickup writing to the
            // stream all of our content starting with the attributes of
            // the StartElement.

            // Write TimeZoneName attribute
            if (!String.IsNullOrEmpty(this.timeZoneNameField))
            {
                writer.WriteAttributeString("TimeZoneName",
                    this.timeZoneNameField);
            }

            // Write Offset
            writer.WriteElementString("Offset", xsTypes, this.offsetField);

            // Write TimeChangeType, which can be either a
            // RelativeYearlyRecurrencePattern or an AbsoluteDate
            //
            if (this.Item is RelativeYearlyRecurrencePatternType)
            {
                string innerNodeValues;

                // For the RelativeYearlyRecurrencePattern portion, we will
                // simply create an XmlSerializer to do the work for us.  We
                // will need a buffer to hold the XML, one 4k buffer should be
                // sufficient.
                //
                using (System.IO.MemoryStream buffer = new
                    System.IO.MemoryStream(4096))
                {
                    // Create a new Serializer. The .NET Framework internally
                    // has a 'cache' of these (each XmlSerializer instance lives
                    // in a dynamically generated assembly), so even though we
                    // are requesting a 'new' one, the .NET Framework is
                    // actually reusing instances for us.
                    //
                    XmlSerializer xmls = new
                         XmlSerializer(typeof(
                             RelativeYearlyRecurrencePatternType));
                    xmls.Serialize(buffer, this.Item);

                    // Reset the buffer position, and then hookup an XmlReader
                    buffer.Seek(0, System.IO.SeekOrigin.Begin);
                    XmlTextReader xmlrdr = new XmlTextReader(buffer);
                    xmlrdr.Read();

                    // The first node should always be the XmlDeclaration, and
                    // we do not want that
                    if (xmlrdr.NodeType == XmlNodeType.XmlDeclaration)
                    {
                        xmlrdr.Read();

                        // The XmlSerializer likes to put in some whitespace
                        // as well.
                        //
                        if (xmlrdr.NodeType == XmlNodeType.Whitespace)
                        {
                            xmlrdr.Read();
                        }
                    }

                    // Here is the node we are interested in, however, we can't
                    // just take the node 'as-is'.  The reason is that the
                    // XmlSerializer named the outer node
                    // "RelativeYearlyRecurrencePatternType" (the name of the
                    // type) but our request must pass this as
                    // "RelativeYearlyRecurrence".
                    //
                    // The InnerXml however, is all valid, so we'll save that
                    // information and handle the outer-node part ourselves.
                    //
                    innerNodeValues = xmlrdr.ReadInnerXml();
                }

                // Write out our recurrence pattern node
                //
                writer.WriteStartElement("RelativeYearlyRecurrence", xsTypes);
                writer.WriteRaw(innerNodeValues);
                writer.WriteEndElement();
            }
            else
            {
                writer.WriteElementString("AbsoluteDate",
                    System.Xml.XmlConvert.ToString((DateTime)this.Item,
                        XmlDateTimeSerializationMode.RoundtripKind));
            }

            // Write the Time Element
            //
            // This is the primary reason for implementing IXmlSerializable.
            // For it is here where we control the XML output of the Time
            // element of our type to include the 'correct' offset.
            //
            string correctXsTimeString = String.Empty;
            switch (this.timeField.Kind)
            {
                case DateTimeKind.Local:
                    correctXsTimeString =
                        this.timeField.ToString(@"HH"":""mm"":""sszzzzzz");
                    break;
                case DateTimeKind.Utc:
                    correctXsTimeString =
                        this.timeField.ToString(@"HH"":""mm"":""ssZ");
                    break;
                case DateTimeKind.Unspecified:
                default:
                    correctXsTimeString =
                        this.timeField.ToString(@"HH"":""mm"":""ss");
                    break;
            }

            writer.WriteElementString("Time", xsTypes, correctXsTimeString);

            // No need to write an "EndElement", simply exit.
        }