private void CreateConfig() { this.ConfigFileLocation = Path.Combine(this.ThemeDirectory, "Theme.config"); using (var xml = new XmlTextWriter(this.ConfigFileLocation, Encoding.UTF8)) { xml.WriteStartDocument(true); xml.Formatting = Formatting.Indented; xml.Indentation = 4; xml.WriteStartElement("configuration"); xml.WriteStartElement("appSettings"); this.AddKey(xml, "ThemeName", this.Info.ThemeName); this.AddKey(xml, "Author", this.Info.Author); this.AddKey(xml, "AuthorUrl", this.Info.AuthorUrl); this.AddKey(xml, "AuthorEmail", this.Info.AuthorEmail); this.AddKey(xml, "ConvertedBy", this.Info.ConvertedBy); this.AddKey(xml, "ReleasedOn", this.Info.ReleasedOn); this.AddKey(xml, "Version", this.Info.Version); this.AddKey(xml, "Category", this.Info.Category); this.AddKey(xml, "Responsive", this.Info.Responsive ? "Yes" : "No"); this.AddKey(xml, "Framework", this.Info.Framework); this.AddKey(xml, "Tags", string.Join(",", this.Info.Tags)); this.AddKey(xml, "HomepageLayout", this.Info.HomepageLayout); this.AddKey(xml, "DefaultLayout", this.Info.DefaultLayout); xml.WriteEndElement(); //appSettings xml.WriteEndElement(); //configuration xml.Close(); } }
public static string Serialize(IEnumerable<MicroDataEntry> entries) { StringBuilder sb = new StringBuilder(3000); using (StringWriter sw = new StringWriter(sb)) { using (XmlTextWriter xw = new XmlTextWriter(sw)) { xw.WriteStartElement("microData"); foreach (MicroDataEntry microDataEntry in entries) { xw.WriteStartElement("entry"); if (microDataEntry.ContentType.HasValue) { xw.WriteAttributeString("contentType", microDataEntry.ContentType.Value.ToString()); } xw.WriteAttributeString("entryType", microDataEntry.Type.ToString()); xw.WriteAttributeString("selector", microDataEntry.Selector); xw.WriteAttributeString("value", microDataEntry.Value); xw.WriteEndElement(); } xw.WriteEndElement(); } } return sb.ToString(); }
public static void Save(VProject vProject, XmlTextWriter xml) { Debug.Assert(vProject.ProjectDescriptor != null); Debug.Assert(vProject.ProjectDescriptor.Code != null); Debug.Assert(vProject.Items != null); xml.WriteStartElement("Code"); xml.WriteValue(vProject.ProjectDescriptor.Code); xml.WriteEndElement(); xml.WriteStartElement("ProjectItems"); foreach (var item in vProject.Items) { xml.WriteStartElement("ProjectItem"); xml.WriteStartElement("DisplayName"); xml.WriteValue(item.DisplayName); xml.WriteEndElement(); xml.WriteStartElement("Code"); xml.WriteValue(item.Descriptor.Code); xml.WriteEndElement(); xml.WriteEndElement(); } xml.WriteEndElement(); }
private bool SaveRegister(string RegisterKey) { try { Encryption enc = new Encryption(); FileStream fs = new FileStream("reqlkd.dll", FileMode.Create); XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8); // Khởi động tài liệu. w.WriteStartDocument(); w.WriteStartElement("QLCV"); // Ghi một product. w.WriteStartElement("Register"); w.WriteAttributeString("GuiNumber", enc.EncryptData(sGuiID)); w.WriteAttributeString("Serialnumber", enc.EncryptData(sSerial)); w.WriteAttributeString("KeyRegister", enc.EncryptData(RegisterKey, sSerial + sGuiID)); w.WriteEndElement(); // Kết thúc tài liệu. w.WriteEndElement(); w.WriteEndDocument(); w.Flush(); w.Close(); fs.Close(); return true; } catch (Exception ex) { return false; } }
public override string Serialize(Node node, Type typeAttr) { XpcaProxy proxy = new XpcaProxy(node); StringWriter sw = new StringWriter(); using(XmlWriter xmlWriter = new XmlTextWriter(sw)) { xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); xmlWriter.WriteStartElement("root"); foreach (KeyValuePair<string, PropertyInfo> property in proxy.GetPropertiesFor(typeAttr)) { object value = proxy[property.Key]; if (value != null) { xmlWriter.WriteStartElement(property.Key); if(value is IEnumerable<object>) { foreach (object obj in (value as IEnumerable<object>)) { xmlWriter.WriteStartElement("item"); XmlWriteValue(xmlWriter, obj); xmlWriter.WriteEndElement(); } } else { XmlWriteValue(xmlWriter, value); } xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); } return sw.ToString(); }
/// <summary>Serialize the <c>XmlRpcResponse</c> to the output stream.</summary> /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param> /// <param name="obj">An <c>Object</c> to serialize.</param> /// <seealso cref="XmlRpcResponse"/> public override void Serialize(XmlTextWriter output, Object obj) { XmlRpcResponse response = (XmlRpcResponse) obj; output.WriteStartDocument(); output.WriteStartElement(METHOD_RESPONSE); if (response.IsFault) output.WriteStartElement(FAULT); else { output.WriteStartElement(PARAMS); output.WriteStartElement(PARAM); } output.WriteStartElement(VALUE); SerializeObject(output,response.Value); output.WriteEndElement(); output.WriteEndElement(); if (!response.IsFault) output.WriteEndElement(); output.WriteEndElement(); }
public override void writeToXml(XmlTextWriter writer) { JamaMatrix jamaMatrix = IPolyPointTransformer.PolyExps(this.polynomialDegree); string[] array = new string[] { "x", "y" }; for (int i = 0; i < 2; i++) { writer.WriteStartElement("Sum"); writer.WriteAttributeString("Name", array[i]); for (int j = 0; j < jamaMatrix.RowDimension; j++) { writer.WriteStartElement("Term"); writer.WriteAttributeString("Coefficient", this.transformCoefficients.GetElement(i * jamaMatrix.RowDimension + j, 0).ToString(CultureInfo.InvariantCulture)); for (int k = 0; k < 2; k++) { writer.WriteAttributeString(array[k] + "_power", jamaMatrix.GetElement(j, k).ToString(CultureInfo.InvariantCulture)); } writer.WriteEndElement(); } writer.WriteEndElement(); } }
private void button_OK_Click(object sender, EventArgs e) { if (!Desc.Convex) MessageBox.Show("Útvar není konvexní a při detekci kolizí bude nahrazen jeho konvexním obalem.","Konvexnost",MessageBoxButtons.OK,MessageBoxIcon.Information); using (XmlTextWriter Object = new XmlTextWriter("objects\\" + text_objName.Text + ".xml", Encoding.UTF8)) { Object.WriteStartDocument(); Object.WriteStartElement("Geometry"); Object.WriteAttributeString("W", Desc.Width.ToString()); Object.WriteAttributeString("H", Desc.Height.ToString()); Object.WriteAttributeString("D", text_objDepth.Text); Object.WriteAttributeString("C", text_objDrag.Text); Object.WriteAttributeString("Color", col); Object.WriteAttributeString("Tension", text_objTension.Text); Object.WriteAttributeString("ID", System.Guid.NewGuid().ToString()); Object.WriteStartElement("COG"); Object.WriteAttributeString("X", (COG.Value.X-Desc.Centroid.X).ToString()); Object.WriteAttributeString("Y", (COG.Value.Y-Desc.Centroid.Y).ToString()); Object.WriteEndElement(); for (int i = 0; i < pts.Count; i++) { Object.WriteStartElement("Vertex"); Object.WriteAttributeString("X", (((PointF)pts[i]).X - Desc.Centroid.X).ToString()); Object.WriteAttributeString("Y", (((PointF)pts[i]).Y - Desc.Centroid.Y).ToString()); Object.WriteEndElement(); } Object.WriteEndElement(); Object.WriteEndDocument(); } Close(); }
private void WriteFeed(IEnumerable<DonaldEpisode> episodes, Stream responseStream, string url) { XmlTextWriter objX = new XmlTextWriter(responseStream, Encoding.UTF8); objX.WriteStartDocument(); objX.WriteStartElement("rss"); objX.WriteAttributeString("version", "2.0"); objX.WriteStartElement("channel"); objX.WriteElementString("title", "Donald Inc."); objX.WriteElementString("link", url); objX.WriteElementString("description", "Your custom donald feed!"); objX.WriteElementString("copyright", "(c) 2011, Chuck Norris."); objX.WriteElementString("ttl", "5"); foreach (var episode in episodes) { objX.WriteStartElement("item"); objX.WriteElementString("title", episode.Title); objX.WriteElementString("description", episode.Content); objX.WriteElementString("link", Configuration.ApiUri + "/" + episode.Id); objX.WriteElementString("pubDate", episode.ReleaseDate.Value.ToString("R")); objX.WriteStartElement("enclosure"); objX.WriteAttributeString("url", Configuration.ApiUri + "/" + episode.Id + "/jpg"); objX.WriteAttributeString("type", "application/jpg"); objX.WriteEndElement(); objX.WriteEndElement(); } objX.WriteEndElement(); objX.WriteEndElement(); objX.WriteEndDocument(); objX.Flush(); }
public void XMLCheck() { try { if (!File.Exists(SettingsFile)) { xwriter = new XmlTextWriter(SettingsFile, null); xwriter.Formatting = Formatting.Indented; xwriter.WriteStartDocument(); xwriter.WriteStartElement("settings"); xwriter.WriteStartElement("twitch_server"); xwriter.WriteAttributeString("value", null); xwriter.WriteEndElement(); xwriter.WriteStartElement("twitch_name"); xwriter.WriteAttributeString("value", null); xwriter.WriteEndElement(); xwriter.WriteStartElement("twitch_auth"); xwriter.WriteAttributeString("value", null); xwriter.WriteEndElement(); xwriter.WriteEndDocument(); xwriter.Close(); } } catch (Exception ex) { } finally { //Nothing yet } }
public XmlWriter() { string filename = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"/Table1.xml"; XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(filename); } catch (System.IO.FileNotFoundException ex) { Console.WriteLine(ex); XmlTextWriter xmlWriter = new XmlTextWriter(filename, System.Text.Encoding.UTF8); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); xmlWriter.WriteStartElement("Table"); xmlWriter.WriteStartElement("Players"); xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("Dealer"); xmlWriter.WriteStartElement("DealerCards"); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.Close(); xmlDoc.Load(filename); } }
private static void SaveManToXml(IList<Man> people) { string fileName = "../../peoples.xml"; using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.GetEncoding("windows-1251"))) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; writer.WriteStartDocument(); writer.WriteStartElement("people"); foreach (var man in people) { writer.WriteStartElement("person"); writer.WriteElementString("name", man.Name); writer.WriteElementString("address", man.Address); writer.WriteElementString("phone", man.Phone); writer.WriteEndElement(); } writer.WriteEndElement(); } }
/// <summary> /// Export a MacGui style plist preset. /// </summary> /// <param name="path"> /// The path. /// </param> /// <param name="preset"> /// The preset. /// </param> public static void Export(string path, Preset preset) { EncodeTask parsed = QueryParserUtility.Parse(preset.Query); XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented }; // Header xmlWriter.WriteStartDocument(); xmlWriter.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); xmlWriter.WriteStartElement("plist"); xmlWriter.WriteStartElement("array"); // Add New Preset Here. Can write multiple presets here if required in future. WritePreset(xmlWriter, parsed, preset); // Footer xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); // Closeout xmlWriter.Close(); }
public void Send(string serviceUrl, string postUrl, string blogName) { try { var request = (HttpWebRequest)WebRequest.Create(serviceUrl); request.Method = "POST"; request.ContentType = "text/xml"; request.Timeout = 3000; request.Credentials = CredentialCache.DefaultNetworkCredentials; var stream = request.GetRequestStream(); using (var writer = new XmlTextWriter(stream, Encoding.ASCII)) { writer.WriteStartDocument(); writer.WriteStartElement("methodCall"); writer.WriteElementString("methodName", "weblogUpdates.ping"); writer.WriteStartElement("params"); writer.WriteStartElement("param"); writer.WriteElementString("value", blogName); writer.WriteEndElement(); writer.WriteStartElement("param"); writer.WriteElementString("value", postUrl); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } request.GetResponse(); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(new NotSupportedException()); } }
public void saveSettingsButton_Click(object sender, EventArgs e) { Form1 parent = (Form1)Application.OpenForms["Form1"]; FileStream fs = new FileStream("artsin_launcher.cfg", FileMode.Create); XmlTextWriter writer = new XmlTextWriter(fs, Encoding.Unicode); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("ArtSinLauncherCfg"); writer.WriteAttributeString("version", "1.1"); writer.WriteStartElement("Memory"); writer.WriteAttributeString("minMemory", ((int)minMemNumericUpDown.Value).ToString()); writer.WriteAttributeString("maxMemory", ((int)maxMemNumericUpDown.Value).ToString()); writer.WriteEndElement(); writer.WriteStartElement("SaveSettings"); writer.WriteAttributeString("isTrue", saveSettingsCheckBox.Checked.ToString()); writer.WriteEndElement(); writer.WriteStartElement("Login"); writer.WriteAttributeString("value", parent.loginTextBox.Text); writer.WriteEndElement(); writer.WriteStartElement("License"); writer.WriteAttributeString("isTrue", parent.licenseCheckBox.Checked.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); fs.Close(); }
public string writeXML(string rootElement, Dictionary<string, object> keyValueDictionary) { try { StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter); //xmlWriter.Formatting = Formatting.Indented; //xmlWriter.Indentation = indentation; // write root element xmlWriter.WriteStartElement(rootElement); xmlWriter.WriteAttributeString("xmlns", "ns", null, "http://ilab.mit.edu/iLab"); foreach (string s in keyValueDictionary.Keys) { xmlWriter.WriteStartElement(s); object value = new object(); keyValueDictionary.TryGetValue(s, out value); xmlWriter.WriteString(value.ToString()); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); return stringWriter.ToString(); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } return null; }
public void ProcessRequest(HttpContext context) { string configName = context.Request.QueryString["configuration"]; _configuration = CodeGenerationSettings.Instance.GetConfiguration(configName); context.Response.ContentType = "text/plain"; using (XmlTextWriter writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"); writer.WriteStartElement("namespaces"); _templates = _configuration.GetTemplateSettings().ToDictionary(t => t.Path); foreach (var nameSpace in _templates.Values.GroupBy(c => c.NameSpace)) { writer.WriteStartElement("namespace"); writer.WriteAttributeString("name", nameSpace.Key); foreach (var template in nameSpace) WriteTemplate(template, writer); writer.WriteEndElement(); } writer.WriteEndElement(); } }
private void PingService(string ping, string name, string url) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ping); request.Method = "POST"; request.ContentType = "text/xml"; using (Stream stream = (Stream)request.GetRequestStream()) { using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.UTF8)) { xml.WriteStartDocument(); xml.WriteStartElement("methodCall"); xml.WriteElementString("methodName", "weblogUpdates.ping"); xml.WriteStartElement("params"); xml.WriteStartElement("param"); xml.WriteElementString("value", name); xml.WriteEndElement(); xml.WriteStartElement("param"); xml.WriteElementString("value", url); xml.WriteEndElement(); xml.WriteEndElement(); xml.WriteEndElement(); xml.WriteEndDocument(); } } } catch (Exception ex) { Log.Add(LogTypes.Debug, -1, "pinger: url: " + ping + " exception:" + ex.ToString()); } }
private void button1_Click(object sender, RoutedEventArgs e) { int dauer = 10; try { dauer = Convert.ToInt32(txt_dauer.Text); } catch (Exception) { } if (!Directory.Exists(Directory.GetCurrentDirectory() + "/quizxml/")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/quizxml/"); } if (File.Exists(Directory.GetCurrentDirectory() + "/quizxml/" + txt_name.Text + ".xml")) { if (!bearbeiten) { MessageBox.Show("Ein Quiz mit diesem Namen existiert bereits! Bitte wählen Sie einen anderen Namen."); return; } } else { XmlTextWriter myXmlTextWriter = new XmlTextWriter(Directory.GetCurrentDirectory() + "/quizxml/" + txt_name.Text + ".xml", System.Text.Encoding.UTF8); myXmlTextWriter.Formatting = Formatting.Indented; myXmlTextWriter.WriteStartDocument(false); myXmlTextWriter.WriteStartElement("Quiz"); myXmlTextWriter.WriteElementString("quizname", txt_name.Text); myXmlTextWriter.WriteElementString("sounddatei", txt_name.Text + ".mp3"); myXmlTextWriter.WriteElementString("clipdauer", dauer.ToString()); myXmlTextWriter.WriteElementString("quiztyp", lb_kato.SelectedValue.ToString()); myXmlTextWriter.WriteStartElement("Items"); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.Close(); bearbeiten = true; } // index = 0 für sound if (lb_kato.SelectedIndex == 0) { MainWindow begriffe_window = new MainWindow(txt_name.Text); begriffe_window.Owner = this; begriffe_window.Show(); } // index = 1 für text if (lb_kato.SelectedIndex == 1) { fragenquiz begriffe_window = new fragenquiz(txt_name.Text); begriffe_window.Owner = this; begriffe_window.Show(); } }
/// <summary>Serializes a graph into a file</summary> /// <param name="g">Graph to serialize</param> /// <param name="file">Target file</param> public static void Serialize(Graph g, string file) { using (XmlTextWriter writer = new XmlTextWriter(file, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.Indentation = 1; writer.IndentChar = '\t'; writer.WriteStartDocument(true); writer.WriteStartElement("GraphXML"); writer.WriteStartElement("graph"); writer.WriteAttributeString("id", "autogenerated_webgraph_10"); writer.WriteAttributeString("meta", g.Tag.ToString()); g.ForAllNodes(node => { writer.WriteStartElement("node"); writer.WriteAttributeString("name", string.Format("n{0:D4}", node.Id)); writer.WriteElementString("label", node.Label); writer.WriteEndElement(); // node }); g.ForAllEdges(edge => { writer.WriteStartElement("edge"); writer.WriteAttributeString("source", string.Format("n{0:D4}", edge.From.Id)); writer.WriteAttributeString("target", string.Format("n{0:D4}", edge.To.Id)); writer.WriteEndElement(); // edge }); writer.WriteEndElement(); // graph writer.WriteEndElement(); // GraphXML writer.Close(); } }
//overload that takes string[] public static void EncodeTextFile(string saveFileName, HeaderInformation info, string[] paragraphs, bool tagPunctuation) { //creating xml file xmlWriter = new XmlTextWriter(saveFileName, Encoding.UTF8); //starting the document (intro) WriteDocIntro(saveFileName); //process header EncodeHeader(info); //process text xmlWriter.WriteStartElement("text"); //<text> xmlWriter.WriteStartElement("group"); //<group> xmlWriter.WriteStartElement("body"); //<body> EncodeSentencesOrParagraphs(paragraphs, tagPunctuation, false); xmlWriter.WriteEndElement();//closing <body> xmlWriter.WriteEndElement();//closing <group> xmlWriter.WriteEndElement();//closing <text> //ending the document (outro) xmlWriter.WriteEndElement();//closing <TEI.2> xmlWriter.Close(); }
public static void ConvetTextToXml() { string[] lines; const int NumberOfTagsForEachPerson = 3; using (var writer = new XmlTextWriter("../../toXml.xml", Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; using (StreamReader reader = new StreamReader("../../fromText.txt")) { lines = reader.ReadToEnd().Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); writer.WriteStartDocument(); writer.WriteStartElement("Persons"); for (int i = 0; i < lines.Length; i += NumberOfTagsForEachPerson) { writer.WriteStartElement("Person"); writer.WriteElementString("name", lines[i]); writer.WriteElementString("adress", lines[i + 1]); writer.WriteElementString("telephone", lines[i + 2]); writer.WriteEndElement(); } writer.WriteEndElement(); } } Console.WriteLine("\tDONE!!! Check file!"); }
/// <summary> /// Adds a single item to the XmlTextWriter supplied /// </summary> /// <param name="writer">The XmlTextWriter to be written to</param> /// <param name="sItemTitle">The title of the RSS item</param> /// <param name="sItemLink">The URL of the RSS item</param> /// <param name="sItemDescription">The RSS item text itself</param> /// <param name="sPubDate"></param> /// <param name="bDescAsCdata">Write description as CDATA</param> /// <returns>The XmlTextWriter with the item info written to it</returns> public XmlTextWriter AddRssItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, DateTime sPubDate, bool bDescAsCdata) { writer.WriteStartElement("item"); writer.WriteElementString("title", sItemTitle); writer.WriteElementString("link", sItemLink); if (bDescAsCdata) { // Now we can write the description as CDATA to support html content. // We find this used quite often in aggregators writer.WriteStartElement("description"); writer.WriteCData(sItemDescription); writer.WriteEndElement(); } else { writer.WriteElementString("description", sItemDescription); } writer.WriteElementString("pubDate", sPubDate.ToString("r")); writer.WriteEndElement(); return writer; }
public static void CreateXml(string path) { XmlTextWriter writer = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented }; writer.WriteStartDocument(); writer.WriteStartElement("root"); for (int i = 0; i < 5; i++) { writer.WriteStartElement("Node"); writer.WriteAttributeString("Text", "这是文章内容!~!!~~"); writer.WriteAttributeString("ImageUrl", ""); writer.WriteAttributeString("NavigateUrl", "Url..." + i.ToString()); writer.WriteAttributeString("Expand", "true"); for (int j = 0; j < 5; j++) { writer.WriteStartElement("Node"); writer.WriteAttributeString("Text", "......名称"); writer.WriteAttributeString("NavigateUrl", "Url..." + i.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteFullEndElement(); writer.Close(); }
private static void PingServices(IEnumerable<Uri> Services, Uri Blog, string BlogName) { foreach (Uri Service in Services) { HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(Service); Request.Credentials = CredentialCache.DefaultNetworkCredentials; Request.ContentType = "text/xml"; Request.Method = "POST"; Request.Timeout = 10000; using (XmlTextWriter XMLWriter = new XmlTextWriter(Request.GetRequestStream(), Encoding.ASCII)) { XMLWriter.WriteStartDocument(); XMLWriter.WriteStartElement("methodCall"); XMLWriter.WriteElementString("methodName", "weblogUpdates.ping"); XMLWriter.WriteStartElement("params"); XMLWriter.WriteStartElement("param"); XMLWriter.WriteElementString("value", BlogName); XMLWriter.WriteEndElement(); XMLWriter.WriteStartElement("param"); XMLWriter.WriteElementString("value", Blog.ToString()); XMLWriter.WriteEndElement(); XMLWriter.WriteEndElement(); XMLWriter.WriteEndElement(); } } }
public void CreateXml() { if ( ( m_SeasonList.Count > 0 ) ) { const string fileName = "NFL.xml"; XmlTextWriter writer = new XmlTextWriter(string.Format("{0}{1}", Utility.OutputDirectory() + "xml\\", fileName), null); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteComment( "Comments: NFL Season List" ); writer.WriteStartElement( "nfl" ); writer.WriteStartElement("season-list"); foreach ( NflSeason s in m_SeasonList ) { WriteSeasonNode( writer, s ); } writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); RosterLib.Utility.Announce( fileName + " created" ); } }
static void WriteMyAssetSet(FileInfo[] files) { string shortfile; XmlTextWriter xmlwriter = new XmlTextWriter("MyAssetSet.xml", null); xmlwriter.Formatting = System.Xml.Formatting.Indented; xmlwriter.IndentChar = ' '; xmlwriter.Indentation = 2; xmlwriter.WriteStartElement("Nini"); foreach (FileInfo f in files) { shortfile = Path.GetFileNameWithoutExtension(f.FullName); xmlwriter.WriteStartElement("Section"); xmlwriter.WriteStartAttribute("Name"); xmlwriter.WriteValue(shortfile); xmlwriter.WriteEndAttribute(); WriteKey(xmlwriter, "assetID", shortfile); WriteKey(xmlwriter, "name", shortfile); WriteKey(xmlwriter, "assetType", "0"); WriteKey(xmlwriter, "inventoryType", "0"); WriteKey(xmlwriter, "fileName", f.Name); xmlwriter.WriteEndElement(); } xmlwriter.WriteEndElement(); xmlwriter.Close(); }
private void GenerateDescription(string host = null) { MemoryStream memStream = new MemoryStream(); using (XmlTextWriter descWriter = new XmlTextWriter(memStream, new UTF8Encoding(false))) { descWriter.Formatting = Formatting.Indented; descWriter.WriteRaw("<?xml version=\"1.0\"?>"); descWriter.WriteStartElement("root", "urn:schemas-upnp-org:device-1-0"); descWriter.WriteStartElement("specVersion"); descWriter.WriteElementString("major", "1"); descWriter.WriteElementString("minor", "0"); descWriter.WriteEndElement(); descWriter.WriteStartElement("device"); rootDevice.WriteDescription(descWriter, host); descWriter.WriteEndElement(); descWriter.WriteEndElement(); descWriter.Flush(); descArray = memStream.ToArray(); } }
public void Gravar(Aluguel aluguel) { XmlTextWriter arquivo; arquivo = new XmlTextWriter(@"C:\Users\Lucas\Desktop\Aluguel.txt", Encoding.UTF8); var carros = singleton.BuscarTodosCarros(); var clientes = singleton.BuscarTodosClientes(); foreach (var item in clientes) { arquivo.WriteStartElement("Cliente"); arquivo.WriteElementString("Nome", item.Nome); arquivo.WriteElementString("Documento", item.Documento); arquivo.WriteElementString("Codigo", item.CodigoAluguel); arquivo.WriteEndElement(); } foreach (var item in carros) { arquivo.WriteStartElement("Carro"); arquivo.WriteElementString("Modelo", item.Modelo); arquivo.WriteElementString("Placa", item.Placa); arquivo.WriteElementString("Codigo", item.CodigoAluguel); arquivo.WriteEndElement(); } arquivo.Close(); }
/// <summary> /// Export a MacGui style plist preset. /// </summary> /// <param name="path"> /// The path. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="build"> /// The build.PictureModulusPictureModulus /// </param> public static void Export(string path, Preset preset, string build) { if (string.IsNullOrEmpty(path)) { return; } EncodeTask parsed = new EncodeTask(preset.Task); using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented }) { // Header xmlWriter.WriteStartDocument(); xmlWriter.WriteDocType( "plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); xmlWriter.WriteStartElement("plist"); xmlWriter.WriteStartElement("array"); // Add New Preset Here. Can write multiple presets here if required in future. WritePreset(xmlWriter, parsed, preset, build); // Footer xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); // Closeout xmlWriter.Close(); } }
private void WriteFile_Click(object sender, System.EventArgs e) { string XmlFile; System.IO.DirectoryInfo directoryInfo; System.IO.DirectoryInfo directoryXML; //Get the applications startup path directoryInfo = System.IO.Directory.GetParent(Application.StartupPath); //Set the output path if (directoryInfo.Name.ToString() == "bin") { directoryXML = System.IO.Directory.GetParent(directoryInfo.FullName); XmlFile = directoryXML.FullName + "\\" + OutputFileName.Text; } else { XmlFile = directoryInfo.FullName + "\\" + OutputFileName.Text; } //create the xml text writer object by providing the filename to write to //and the desired encoding. If the encoding is left null, then the writer //assumes UTF-8. XmlTextWriter XmlWtr = new System.Xml.XmlTextWriter(XmlFile, null); //set the formatting option of the xml file. The default indentation is 2 character spaces. //To change the default, use the Indentation property to set the number of IndentChars to use //and use the IndentChar property to set the character to use for indentation, such as the //tab character. Here the default is used. XmlWtr.Formatting = Formatting.Indented; //begin to write the xml document. This creates the xml declaration with the version attribute //set to "1.0". XmlWtr.WriteStartDocument(); //start the first element. XmlWtr.WriteStartElement("customers"); //create our first customer element. //this is a child element of the customers element. XmlWtr.WriteStartElement("customer"); //writes the entire element with the specified element name and //string value respectively. XmlWtr.WriteElementString("name", "Kevin Anders"); XmlWtr.WriteElementString("phone", "555.555.5555"); //end the customer element. XmlWtr.WriteEndElement(); //create another customer. XmlWtr.WriteStartElement("customer"); XmlWtr.WriteElementString("name", "Staci Richard"); XmlWtr.WriteElementString("phone", "555.122.1552"); //end the second customer element. XmlWtr.WriteEndElement(); //end the customers element. XmlWtr.WriteEndElement(); //now end the document. XmlWtr.WriteEndDocument(); //now flush the contents of the stream. XmlWtr.Flush(); //close the text writerj and write the xml file. XmlWtr.Close(); statusBar1.Text = "Output file has been written"; }
public string CriarXmlRequisicao(string strMatricSistema, string usuarioSistema, string ipusuario, string usuariorede, string strAutenticacaoCriptografada = "", string strCaminhoCPR = "", string pSenha = "") { //Rotina que Gera a string de Requisição da Autenticação string strRetorno = ""; string strNomeArquivoXML = ""; XmlTextWriter xmlRequisicao = default(XmlTextWriter); XmlDocument docXML = default(XmlDocument); StreamReader SR = default(StreamReader); try { if (!System.IO.Directory.Exists(ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\")) { System.IO.Directory.CreateDirectory(ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\"); } //Procura por um nome de arquivo que ainda não exista //strNomeArquivoXML = AppDomain.CurrentDomain.BaseDirectory + "\\XML\\XML_REQ_AUT_" + String.Format(DateTime.Now, "ddMMyyyyhhmmss") + ".xml"; strNomeArquivoXML = ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\XML_REQ_AUT_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xml"; while (System.IO.File.Exists(strNomeArquivoXML)) { strNomeArquivoXML = AppDomain.CurrentDomain.BaseDirectory + "\\XML\\XML_REQ_AUT_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xml"; } xmlRequisicao = new System.Xml.XmlTextWriter(strNomeArquivoXML, System.Text.Encoding.UTF8); //INÍCIO DO DOCUMENTO XML xmlRequisicao.WriteStartDocument(); //INÍCIO DA TAG 'REQUISICAO' xmlRequisicao.WriteStartElement("requisicao"); xmlRequisicao.WriteAttributeString("xmlns", "http://ntconsult.com.br/webservices/"); xmlRequisicao.WriteAttributeString("versao", "0.10"); //Caso a Autenticação seja criptografia RSA então este elemento deverá ser criado: AutenticacaoCriptografada //Caso o parâmetro tenha sido informado e não esteja em branco efetua a autenticação através de RSA if ((strAutenticacaoCriptografada != null)) { if (!string.IsNullOrEmpty(strAutenticacaoCriptografada.Trim())) { xmlRequisicao.WriteElementString("AutenticacaoCriptografada", strAutenticacaoCriptografada); } } else { xmlRequisicao.WriteElementString("usr", usuarioSistema); xmlRequisicao.WriteElementString("senha", pSenha); } xmlRequisicao.WriteElementString("matricsistema", strMatricSistema); xmlRequisicao.WriteElementString("usuariorede", usuariorede); xmlRequisicao.WriteElementString("ipusuario", ipusuario); //FIM DA TAG 'REQUISICAO' xmlRequisicao.WriteEndElement(); //FIM DO DOCUMENTO XML xmlRequisicao.WriteEndDocument(); xmlRequisicao.Flush(); xmlRequisicao.Close(); docXML = new XmlDocument(); docXML.PreserveWhitespace = false; SR = File.OpenText(strNomeArquivoXML); docXML.LoadXml(SR.ReadToEnd()); SR.Close(); strRetorno = docXML.InnerXml.ToString(); //apos usar o arquivo, apaga-lo File.Delete(strNomeArquivoXML); return(strRetorno); } catch (Exception ex) { throw ex; } }
/// <summary> /// Writes the XML. /// </summary> /// <param name="writer">The writer.</param> public void WriteXML(System.Xml.XmlTextWriter writer) { writer.WriteStartElement("resource"); WriteXMLElement(writer); writer.WriteEndElement(); }
private void GeneraXML(System.Xml.XmlTextWriter writer) // As System.Xml.XmlTextWriter { try { writer.WriteStartDocument(); writer.WriteStartElement("FacturaElectronica"); writer.WriteAttributeString("xmlns", "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica"); writer.WriteAttributeString("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#"); writer.WriteAttributeString("xmlns:vc", "http://www.w3.org/2007/XMLSchema-versioning"); writer.WriteAttributeString("xmlns:xs", "http://www.w3.org/2001/XMLSchema"); // La clave se crea con la función CreaClave de la clase Datos writer.WriteElementString("Clave", _numeroClave); // 'El numero de secuencia es de 20 caracteres, // 'Se debe de crear con la función CreaNumeroSecuencia de la clase Datos writer.WriteElementString("NumeroConsecutivo", _numeroConsecutivo); // 'El formato de la fecha es yyyy-MM-ddTHH:mm:sszzz writer.WriteElementString("FechaEmision", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); writer.WriteStartElement("Emisor"); writer.WriteElementString("Nombre", _emisor.Nombre); writer.WriteStartElement("Identificacion"); writer.WriteElementString("Tipo", _emisor.Identificacion_Tipo); writer.WriteElementString("Numero", _emisor.Identificacion_Numero); writer.WriteEndElement(); // 'Identificacion // '----------------------------------- // 'Los datos de las ubicaciones los puede tomar de las tablas de datos, // 'Debe ser exacto al que hacienda tiene registrado para su compañia writer.WriteStartElement("Ubicacion"); writer.WriteElementString("Provincia", _emisor.Ubicacion_Provincia); writer.WriteElementString("Canton", _emisor.Ubicacion_Canton); writer.WriteElementString("Distrito", _emisor.Ubicacion_Distrito); writer.WriteElementString("Barrio", _emisor.Ubicacion_Barrio); writer.WriteElementString("OtrasSenas", _emisor.Ubicacion_OtrasSenas); writer.WriteEndElement(); // 'Ubicacion writer.WriteStartElement("Telefono"); writer.WriteElementString("CodigoPais", _emisor.Telefono_CodigoPais); writer.WriteElementString("NumTelefono", _emisor.Telefono_Numero.ToString()); writer.WriteEndElement(); // 'Telefono writer.WriteElementString("CorreoElectronico", _emisor.CorreoElectronico); writer.WriteEndElement(); // Emisor // '------------------------------------ // 'Receptor es similar con emisor, los datos opcionales siempre siempre siempre omitirlos. // 'La ubicacion para el receptor es opcional por ejemplo writer.WriteStartElement("Receptor"); writer.WriteElementString("Nombre", _receptor.Nombre); writer.WriteStartElement("Identificacion"); // 'Los tipos de identificacion los puede ver en la tabla de datos writer.WriteElementString("Tipo", _receptor.Identificacion_Tipo); writer.WriteElementString("Numero", _receptor.Identificacion_Numero); writer.WriteEndElement(); // 'Identificacion writer.WriteStartElement("Telefono"); writer.WriteElementString("CodigoPais", _receptor.Telefono_CodigoPais); writer.WriteElementString("NumTelefono", _receptor.Telefono_Numero.ToString()); writer.WriteEndElement(); // 'Telefono writer.WriteElementString("CorreoElectronico", _receptor.CorreoElectronico); writer.WriteEndElement(); // Receptor // '------------------------------------ // 'Loa datos estan en la tabla correspondiente writer.WriteElementString("CondicionVenta", _condicionVenta); // '01: Contado // '02: Credito // '03: Consignación // '04: Apartado // '05: Arrendamiento con opcion de compra // '06: Arrendamiento con función financiera // '99: Otros // 'Este dato se muestra si la condicion venta es credito writer.WriteElementString("PlazoCredito", _plazoCredito); writer.WriteElementString("MedioPago", _medioPago); // '01: Efectivo // '02: Tarjeta // '03: Cheque // '04: Transferecia - deposito bancario // '05: Recaudado por terceros // '99: Otros writer.WriteStartElement("DetalleServicio"); // '------------------------------------- foreach (var xt in _dsDetalle) { writer.WriteStartElement("LineaDetalle"); writer.WriteElementString("NumeroLinea", xt.numeroDeLinea.ToString()); writer.WriteStartElement("Codigo"); writer.WriteElementString("Tipo", xt.tipoDeArticulo.ToString()); writer.WriteElementString("Codigo", xt.codigoArticulo.ToString()); writer.WriteEndElement(); // 'Codigo writer.WriteElementString("Cantidad", xt.cantidad.ToString()); // 'Para las unidades de medida ver la tabla correspondiente writer.WriteElementString("UnidadMedida", xt.unidadDeMedida.ToString()); writer.WriteElementString("Detalle", xt.detalle.ToString()); writer.WriteElementString("PrecioUnitario", String.Format("{0:N3}", xt.precioUnitario.ToString())); writer.WriteElementString("MontoTotal", String.Format("{0:N3}", xt.montoTotal.ToString())); writer.WriteElementString("MontoDescuento", String.Format("{0:N3}", xt.montoDescuento.ToString())); writer.WriteElementString("NaturalezaDescuento", xt.NaturalezaDescuento.ToString()); writer.WriteElementString("SubTotal", String.Format("{0:N3}", xt.subtotal.ToString())); writer.WriteStartElement("Impuesto"); writer.WriteElementString("Codigo", xt.codigoImpuesto.ToString()); writer.WriteElementString("Tarifa", xt.impuestoTarifa.ToString()); writer.WriteElementString("Monto", xt.impuestoMonto.ToString()); writer.WriteEndElement(); // Impuesto writer.WriteElementString("MontoTotalLinea", String.Format("{0:N3}", xt.montoTotalLinea.ToString())); writer.WriteEndElement(); // LineaDetalle } // '------------------------------------- writer.WriteEndElement(); // DetalleServicio writer.WriteStartElement("ResumenFactura"); // Estos campos son opcionales, solo fin desea facturar en dólares writer.WriteElementString("CodigoMoneda", _codigoMoneda); writer.WriteElementString("TipoCambio", "1.00000"); // ================= //SACAR CALCULOS PARA FACTURA double totalComprobante = 0; double montoTotalImpuesto = 0; foreach (var y in _dsDetalle) { montoTotalImpuesto = montoTotalImpuesto + y.impuestoMonto; } totalComprobante = 0 + montoTotalImpuesto; // 'En esta parte los totales se pueden ir sumando linea a linea cuando se carga el detalle // 'ó se pasa como parametros al inicio writer.WriteElementString("TotalServGravados", "0.00000"); writer.WriteElementString("TotalServExentos", "0.00000"); writer.WriteElementString("TotalMercanciasGravadas", "0.00000"); writer.WriteElementString("TotalMercanciasExentas", "0.00000"); writer.WriteElementString("TotalGravado", "0.00000"); writer.WriteElementString("TotalExento", "0.00000"); writer.WriteElementString("TotalVenta", "0.00000"); writer.WriteElementString("TotalDescuentos", "0.00000"); writer.WriteElementString("TotalVentaNeta", "0.00000"); writer.WriteElementString("TotalImpuesto", String.Format("{0:N3}", montoTotalImpuesto.ToString())); writer.WriteElementString("TotalComprobante", String.Format("{0:N3}", totalComprobante.ToString())); writer.WriteEndElement(); // ResumenFactura // 'Estos datos te los tiene que brindar los encargados del area financiera writer.WriteStartElement("Normativa"); writer.WriteElementString("NumeroResolucion", "DGT-R-48-2016"); writer.WriteElementString("FechaResolucion", "07-10-2016 01:00:00"); writer.WriteEndElement(); // Normativa // 'Aqui va la firma, despues la agregamos. writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } catch (Exception ex) { throw ex; } }
/// <summary> /// 将DataTable的内容写入到XML文件中 /// </summary> /// <param name="dt">数据源</param> /// <param name="address">XML文件地址</param> public static bool DBWriteToXml(System.Data.DataTable dt, string address) { try { //如果文件DataTable.xml存在则直接删除 if (System.IO.File.Exists(address)) { System.IO.File.Delete(address); } System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(address, Encoding.GetEncoding("GBK")); writer.Formatting = System.Xml.Formatting.Indented; //XML文档创建开始 writer.WriteStartDocument(); writer.WriteComment("DataTable: " + dt.TableName); writer.WriteStartElement("DataTable"); //DataTable开始 writer.WriteAttributeString("TableName", dt.TableName); writer.WriteAttributeString("CountOfRows", dt.Rows.Count.ToString()); writer.WriteAttributeString("CountOfColumns", dt.Columns.Count.ToString()); writer.WriteStartElement("ClomunName", ""); //ColumnName开始 for (int i = 0; i < dt.Columns.Count; i++) { writer.WriteAttributeString( "Column" + i.ToString(), dt.Columns[i].ColumnName); } writer.WriteEndElement(); //ColumnName结束 //按行各行 for (int j = 0; j < dt.Rows.Count; j++) { writer.WriteStartElement("Row" + j.ToString(), ""); //打印各列 for (int k = 0; k < dt.Columns.Count; k++) { writer.WriteAttributeString( "Column" + k.ToString(), dt.Rows[j][k].ToString()); } writer.WriteEndElement(); } writer.WriteEndElement(); //DataTable结束 writer.WriteEndDocument(); writer.Close(); //XML文档创建结束 } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } return(true); }
private void SaveXmlCommandFile(string filename) { if (this.MergeListFileArray.Count < 1) { return; } System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(filename, new System.Text.UnicodeEncoding()); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("merge"); // Write sub-elements foreach (MergeListFiles mergeItem in this.MergeListFileArray) { writer.WriteStartElement("file"); if (mergeItem.Include == false) { writer.WriteAttributeString("exclude", "1"); } writer.WriteElementString("path", mergeItem.Path); writer.WriteElementString("pages", mergeItem.Pages); if (mergeItem.Bookmark != null) { writer.WriteElementString("bookmark", mergeItem.Bookmark); } if (mergeItem.Level > 0) { writer.WriteElementString("level", XmlConvert.ToString(mergeItem.Level)); } writer.WriteEndElement(); } #region write info and options if (this.MergeListInfo.HasInfo == true) { writer.WriteStartElement("info"); if (this.MergeListInfo.InfoAuthor.Length > 0) { writer.WriteElementString("author", this.MergeListInfo.InfoAuthor); } if (this.MergeListInfo.InfoSubject.Length > 0) { writer.WriteElementString("subject", this.MergeListInfo.InfoSubject); } if (this.MergeListInfo.InfoTitle.Length > 0) { writer.WriteElementString("title", this.MergeListInfo.InfoTitle); } writer.WriteEndElement(); } writer.WriteStartElement("options"); if (string.IsNullOrEmpty(this.MergeListInfo.OutFilename) == false) { writer.WriteElementString("outfile", this.MergeListInfo.OutFilename); } if (string.IsNullOrEmpty(this.MergeListInfo.Annotation) == false) { writer.WriteElementString("annotation", this.MergeListInfo.Annotation); } if (this.MergeListInfo.NumberPages == true) { writer.WriteElementString("startpage", this.MergeListInfo.StartPage.ToString()); } writer.WriteElementString("paginationformat", ((int)this.MergeListInfo.PaginationFormat).ToString()); writer.WriteEndElement(); #endregion writer.WriteFullEndElement(); writer.Close(); }
public static void GenerateEntityXmlFromTable(TableInfo table, string outputPath, string prefix, string suffix) { if (table == null || !Directory.Exists(outputPath)) { return; } Log4Helper.Write("GenerateEntityXmlFromTable", String.Format("Process of table {0} starts at {1}.", table.TableName, System.DateTime.Now.ToString("s")), LogSeverity.Info); string entityName = GetModelName(table.TableName); using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(System.IO.Path.Combine(outputPath, String.Concat(entityName, ".xml")), System.Text.Encoding.UTF8)) { xtw.Formatting = System.Xml.Formatting.Indented; xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); //generate entity calss xtw.WriteStartElement("entity"); xtw.WriteAttributeString("name", entityName); xtw.WriteAttributeString("modelName", string.Concat(prefix, ".OM.", suffix, ".", entityName)); xtw.WriteAttributeString("namespaceBLL", string.Concat(prefix, ".BLL.", suffix)); xtw.WriteAttributeString("namespaceDAL", string.Concat(prefix, ".DAL.", suffix)); xtw.WriteAttributeString("namespaceModel", string.Concat(prefix, ".OM.", suffix)); xtw.WriteAttributeString("author", UtilityHelper.GetCurrentIdentityName()); xtw.WriteAttributeString("createdDateTime", System.DateTime.Now.ToString("s")); xtw.WriteAttributeString("schema", table.Schema); xtw.WriteAttributeString("tableName", table.TableName); xtw.WriteAttributeString("description", table.TableName); #region primary key xtw.WriteStartElement("primaryKey"); foreach (ColumnInfo col in table.Columns) { if (col.IsPrimaryKey) { xtw.WriteStartElement("column"); xtw.WriteAttributeString("columnName", col.ColumnName); xtw.WriteAttributeString("lowerName", col.ColumnName.ToLower()); xtw.WriteAttributeString("sqlParameter", GetParameter(col.DataType, col.ColumnLength)); xtw.WriteEndElement(); } } xtw.WriteEndElement(); #endregion #region ForeignKeys //xtw.WriteStartElement("foreignKeys"); //foreach (ForeignKey fk in table.ForeignKeys) //{ // xtw.WriteStartElement("foreignKey"); // xtw.WriteAttributeString("name", fk.Name); // xtw.WriteAttributeString("referencedTableSchema", fk.ReferencedTableSchema); // xtw.WriteAttributeString("referencedTable", fk.ReferencedTable); // xtw.WriteAttributeString("referencedKey", fk.ReferencedKey); // foreach (ForeignKeyColumn fkCol in fk.Columns) // { // xtw.WriteStartElement("column"); // xtw.WriteAttributeString("columnName", fkCol.Name); // xtw.WriteAttributeString("referencedColumn", fkCol.ReferencedColumn); // xtw.WriteEndElement(); // } // xtw.WriteEndElement(); //} //xtw.WriteEndElement(); //#endregion //#region indexes //xtw.WriteStartElement("indexes"); //foreach (Index idx in table.Indexes) //{ // xtw.WriteStartElement("index"); // xtw.WriteAttributeString("name", idx.Name); // xtw.WriteAttributeString("isClustered", idx.IsClustered.ToString(System.Globalization.CultureInfo.InvariantCulture)); // xtw.WriteAttributeString("isUnique", idx.IsUnique.ToString(System.Globalization.CultureInfo.InvariantCulture)); // xtw.WriteAttributeString("ignoreDuplicateKeys", idx.IgnoreDuplicateKeys.ToString(System.Globalization.CultureInfo.InvariantCulture)); // foreach (IndexedColumn idxcol in idx.IndexedColumns) // { // xtw.WriteStartElement("column"); // xtw.WriteAttributeString("columnName", idxcol.Name); // xtw.WriteAttributeString("descending", idxcol.Descending.ToString(System.Globalization.CultureInfo.InvariantCulture)); // //xtw.WriteAttributeString("isIncluded", idxcol.IsIncluded.ToString(System.Globalization.CultureInfo.InvariantCulture)); // xtw.WriteEndElement(); // } // xtw.WriteEndElement(); //} //xtw.WriteEndElement(); #endregion #region columns/properties xtw.WriteStartElement("columns"); foreach (ColumnInfo c in table.Columns) { GenerateXmlElementFromColumn(c, xtw); } xtw.WriteEndElement(); #endregion xtw.WriteEndElement(); xtw.Flush(); xtw.Close(); } Log4Helper.Write("GenerateEntityXmlFromTable", String.Format("Process of table {0} ends at {1}.", table.TableName, System.DateTime.Now.ToString("s")), LogSeverity.Info); }
protected override void OutputResults(TestResultGrp resultGrp, object[] ConfigSettings) { TestResult[] Results = resultGrp.Results; string procName = ""; uint L2CacheSize = 0; uint L2CacheSpeed = 0; int procNo = 0; ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT Name, L2CacheSize, L2CacheSpeed FROM Win32_Processor"); ManagementObjectCollection moc = mos.Get(); foreach (ManagementObject mob in moc) { ++procNo; procName = mob.Properties["Name"].Value.ToString(); L2CacheSize = Convert.ToUInt32(mob.Properties["L2CacheSize"].Value); L2CacheSpeed = Convert.ToUInt32(mob.Properties["L2CacheSpeed"].Value); } if (Results == null) { return; } string xmlFileName = (string)ConfigSettings[0]; if (xmlFileName == String.Empty) { xmlFileName = "c:\\" + resultGrp.TestName + ".xml"; } System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8); writer.WriteStartElement("testresults"); writer.WriteAttributeString("Name", resultGrp.TestName); if (resultGrp.Motivation != String.Empty) { writer.WriteAttributeString("Motivation", resultGrp.Motivation); } writer.WriteAttributeString("TestTime", DateTime.UtcNow.ToString("r")); writer.WriteAttributeString("MachineName", System.Environment.MachineName); writer.WriteAttributeString("CLR_Version", System.Environment.Version.ToString()); writer.WriteAttributeString("OS", System.Environment.OSVersion.ToString()); writer.WriteAttributeString("NoProcessors", procNo.ToString()); writer.WriteAttributeString("ProcName", procName); writer.WriteAttributeString("L2CacheSize_Kilobytes", L2CacheSize.ToString()); writer.WriteAttributeString("L2CacheSpeed_MegaHertz", L2CacheSpeed.ToString()); foreach (DotNetPerformance.TestResult tr in Results) { writer.WriteStartElement("testresult"); writer.WriteAttributeString("Name", tr.TestName); writer.WriteAttributeString("Min", tr.Min.TotalMilliseconds.ToString()); writer.WriteAttributeString("Median", tr.Median.TotalMilliseconds.ToString()); writer.WriteAttributeString("Max", tr.Max.TotalMilliseconds.ToString()); writer.WriteAttributeString("NormalizedTestDuration", tr.NormalizedTestDuration.ToString()); foreach (TimeSpan ts in tr.TestResults) { writer.WriteElementString("testrun", ts.TotalMilliseconds.ToString()); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.Close(); System.Diagnostics.Process.Start(xmlFileName); }
/// <summary> Writes the mapping of all mapped classes of the specified assembly in the specified stream. </summary> /// <param name="stream">Where the xml is written.</param> /// <param name="assembly">Assembly used to extract user-defined types containing a valid attribute (can be [Class] or [xSubclass]).</param> public virtual void Serialize(System.IO.Stream stream, System.Reflection.Assembly assembly) { if (stream == null) { throw new System.ArgumentNullException("stream"); } if (assembly == null) { throw new System.ArgumentNullException("assembly"); } System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8); writer.Formatting = System.Xml.Formatting.Indented; writer.WriteStartDocument(); if (WriteDateComment) { writer.WriteComment(string.Format("Generated from NHibernate.Mapping.Attributes on {0}.", System.DateTime.Now.ToString("u"))); } WriteHibernateMapping(writer, null); // Write imports (classes decorated with the [ImportAttribute]) foreach (System.Type type in assembly.GetTypes()) { object[] imports = type.GetCustomAttributes(typeof(ImportAttribute), false); foreach (ImportAttribute import in imports) { writer.WriteStartElement("import"); if (import.Class != null && import.Class != string.Empty) { writer.WriteAttributeString("class", import.Class); } else // Assume that it is the current type that must be imported { writer.WriteAttributeString("class", HbmWriterHelper.GetNameWithAssembly(type)); } if (import.Rename != null && import.Rename != string.Empty) { writer.WriteAttributeString("rename", import.Rename); } writer.WriteEndElement(); } } // Write classes and x-subclasses (classes must come first if inherited by "external" subclasses) int classCount = 0; System.Collections.ArrayList mappedClassesNames = new System.Collections.ArrayList(); foreach (System.Type type in assembly.GetTypes()) { if (!IsClass(type)) { continue; } HbmWriter.WriteClass(writer, type); mappedClassesNames.Add(HbmWriterHelper.GetNameWithAssembly(type)); classCount++; } System.Collections.ArrayList subclasses = new System.Collections.ArrayList(); System.Collections.Specialized.StringCollection extendedClassesNames = new System.Collections.Specialized.StringCollection(); foreach (System.Type type in assembly.GetTypes()) { if (!IsSubclass(type)) { continue; } bool map = true; System.Type t = type; while ((t = t.DeclaringType) != null) { if (IsClass(t) || AreSameSubclass(type, t)) // If a base class is also mapped... (Note: A x-subclass can only contain x-subclasses of the same family) { map = false; // This class's mapping is already included in the mapping of the base class break; } } if (map) { subclasses.Add(type); if (IsSubclass(type, typeof(SubclassAttribute))) { extendedClassesNames.Add((type.GetCustomAttributes(typeof(SubclassAttribute), false)[0] as SubclassAttribute).Extends); } else if (IsSubclass(type, typeof(JoinedSubclassAttribute))) { extendedClassesNames.Add((type.GetCustomAttributes(typeof(JoinedSubclassAttribute), false)[0] as JoinedSubclassAttribute).Extends); } else if (IsSubclass(type, typeof(UnionSubclassAttribute))) { extendedClassesNames.Add((type.GetCustomAttributes(typeof(UnionSubclassAttribute), false)[0] as UnionSubclassAttribute).Extends); } } } classCount += subclasses.Count; MapSubclasses(subclasses, extendedClassesNames, mappedClassesNames, writer); writer.WriteEndElement(); // </hibernate-mapping> writer.WriteEndDocument(); writer.Flush(); if (classCount == 0) { throw new MappingException("The following assembly contains no mapped classes: " + assembly.FullName); } if (!Validate) { return; } // Validate the generated XML stream try { writer.BaseStream.Position = 0; System.Xml.XmlTextReader tr = new System.Xml.XmlTextReader(writer.BaseStream); var reader = CreateReader(tr); _stop = false; while (reader.Read() && !_stop) // Read to validate (stop at the first error) { ; } } catch (System.Exception ex) { Error.Append(ex.ToString()).Append(System.Environment.NewLine + System.Environment.NewLine); } }
private void GeneraXML(System.Xml.XmlTextWriter writer) // As System.Xml.XmlTextWriter { try { writer.WriteStartDocument(); writer.WriteStartElement("FacturaElectronica"); writer.WriteAttributeString("xmlns", "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica"); writer.WriteAttributeString("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#"); writer.WriteAttributeString("xmlns:vc", "http://www.w3.org/2007/XMLSchema-versioning"); writer.WriteAttributeString("xmlns:xs", "http://www.w3.org/2001/XMLSchema"); // La clave se crea con la función CreaClave de la clase Datos writer.WriteElementString("Clave", _numeroClave); // 'El numero de secuencia es de 20 caracteres, // 'Se debe de crear con la función CreaNumeroSecuencia de la clase Datos writer.WriteElementString("NumeroConsecutivo", _numeroConsecutivo); // 'El formato de la fecha es yyyy-MM-ddTHH:mm:sszzz writer.WriteElementString("FechaEmision", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); writer.WriteStartElement("Emisor"); writer.WriteElementString("Nombre", _emisor.Nombre); writer.WriteStartElement("Identificacion"); writer.WriteElementString("Tipo", _emisor.Tipo_Identificacion); writer.WriteElementString("Numero", _emisor.Numero_Identificacion); writer.WriteEndElement(); // 'Identificacion // '----------------------------------- // 'Los datos de las ubicaciones los puede tomar de las tablas de datos, // 'Debe ser exacto al que hacienda tiene registrado para su compañia writer.WriteStartElement("Ubicacion"); writer.WriteElementString("Provincia", _emisor.Provincia); writer.WriteElementString("Canton", _emisor.Canton); writer.WriteElementString("Distrito", _emisor.Distrito); writer.WriteElementString("Barrio", _emisor.Barrio); writer.WriteElementString("OtrasSenas", _emisor.OtrasSenas); writer.WriteEndElement(); // 'Ubicacion writer.WriteStartElement("Telefono"); writer.WriteElementString("CodigoPais", _emisor.CodigoPaisTel); writer.WriteElementString("NumTelefono", _emisor.NumTelefono.ToString()); writer.WriteEndElement(); // 'Telefono writer.WriteElementString("CorreoElectronico", _emisor.CorreoElectronico); writer.WriteEndElement(); // Emisor // '------------------------------------ // 'Receptor es similar con emisor, los datos opcionales siempre siempre siempre omitirlos. // 'La ubicacion para el receptor es opcional por ejemplo writer.WriteStartElement("Receptor"); writer.WriteElementString("Nombre", _receptor.Nombre); writer.WriteStartElement("Identificacion"); // 'Los tipos de identificacion los puede ver en la tabla de datos writer.WriteElementString("Tipo", _receptor.Tipo_Identificacion); writer.WriteElementString("Numero", _receptor.Numero_Identificacion); writer.WriteEndElement(); // 'Identificacion writer.WriteStartElement("Telefono"); writer.WriteElementString("CodigoPais", _receptor.CodigoPaisTel); writer.WriteElementString("NumTelefono", _receptor.NumTelefono.ToString()); writer.WriteEndElement(); // 'Telefono writer.WriteElementString("CorreoElectronico", _receptor.CorreoElectronico); writer.WriteEndElement(); // Receptor // '------------------------------------ // 'Loa datos estan en la tabla correspondiente writer.WriteElementString("CondicionVenta", _condicionVenta); // '01: Contado // '02: Credito // '03: Consignación // '04: Apartado // '05: Arrendamiento con opcion de compra // '06: Arrendamiento con función financiera // '99: Otros // 'Este dato se muestra si la condicion venta es credito writer.WriteElementString("PlazoCredito", _plazoCredito); writer.WriteElementString("MedioPago", _medioPago); // '01: Efectivo // '02: Tarjeta // '03: Cheque // '04: Transferecia - deposito bancario // '05: Recaudado por terceros // '99: Otros writer.WriteStartElement("DetalleServicio"); // '------------------------------------- /* foreach (DataRow dr in _dsDetalle.Tables["detalle"].Rows) * { * writer.WriteStartElement("LineaDetalle"); * * writer.WriteElementString("NumeropLinea", dr["numero_linea"].ToString()); * * writer.WriteStartElement("Codigo"); * writer.WriteElementString("Tipo", dr["articulo_tipo"].ToString()); * writer.WriteElementString("Codigo", dr["articulo_codigo"].ToString()); * writer.WriteEndElement(); // 'Codigo * * writer.WriteElementString("Cantidad", dr["cantidad"].ToString()); * // 'Para las unidades de medida ver la tabla correspondiente * writer.WriteElementString("UnidadMedida", dr["unidad_medida"].ToString()); * writer.WriteElementString("Detalle", dr["detalle_articulo"].ToString()); * writer.WriteElementString("PrecioUnitario", String.Format("{0:N3}", dr["precio_unitario"].ToString())); * writer.WriteElementString("MontoTotal", String.Format("{0:N3}", dr["monto_total"].ToString())); * writer.WriteElementString("MontoDescuento", String.Format("{0:N3}", dr["nonto_descuento"].ToString())); * writer.WriteElementString("NaturalezaDescuento", dr["naturaleza_descuento"].ToString()); * writer.WriteElementString("SubTotal", String.Format("{0:N3}", dr["sub_total"].ToString())); * * writer.WriteStartElement("Impuesto"); * writer.WriteElementString("Codigo", dr["impuesto_codigo"].ToString()); * writer.WriteElementString("Tarifa", dr["impuesto_tarifa"].ToString()); * writer.WriteElementString("Monto", dr["impuesto_monto"].ToString()); * writer.WriteEndElement(); // Impuesto * * writer.WriteElementString("MontoTotalLinea", String.Format("{0:N3}", dr["monto_linea"].ToString())); * * writer.WriteEndElement(); // LineaDetalle * } * // '------------------------------------- * * writer.WriteEndElement(); // DetalleServicio*/ writer.WriteStartElement("ResumenFactura"); // Estos campos son opcionales, solo fin desea facturar en dólares //writer.WriteElementString("CodigoMoneda", _codigoMoneda); // writer.WriteElementString("TipoCambio", "aqui_tipo_cambio"); // ================= // 'En esta parte los totales se pueden ir sumando linea a linea cuando se carga el detalle // 'ó se pasa como parametros al inicio writer.WriteElementString("TotalServGravados", ""); writer.WriteElementString("TotalServExentos", ""); writer.WriteElementString("TotalMercanciasGravadas", ""); writer.WriteElementString("TotalMercanciasExentas", ""); writer.WriteElementString("TotalGravado", ""); writer.WriteElementString("TotalExento", ""); writer.WriteElementString("TotalVenta", ""); writer.WriteElementString("TotalDescuentos", ""); writer.WriteElementString("TotalVentaNeta", ""); writer.WriteElementString("TotalImpuesto", ""); writer.WriteElementString("TotalComprobante", ""); writer.WriteEndElement(); // ResumenFactura // 'Estos datos te los tiene que brindar los encargados del area financiera writer.WriteStartElement("Normativa"); writer.WriteElementString("NumeroResolucion", ""); writer.WriteElementString("FechaResolucion", ""); writer.WriteEndElement(); // Normativa // 'Aqui va la firma, despues la agregamos. writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } catch (Exception ex) { throw ex; } }
public static void writeGPX(string filename, List <CurrentState> flightdata) { System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter( Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + ".gpx", Encoding.ASCII); xw.WriteStartElement("gpx"); xw.WriteAttributeString("creator", MainV2.instance.Text); xw.WriteAttributeString("xmlns", "http://www.topografix.com/GPX/1/1"); xw.WriteStartElement("trk"); xw.WriteStartElement("trkseg"); foreach (CurrentState cs in flightdata) { xw.WriteStartElement("trkpt"); xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("ele", cs.altasl.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("ele2", cs.alt.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz")); xw.WriteElementString("course", (cs.yaw).ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("roll", cs.roll.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("pitch", cs.pitch.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("mode", cs.mode.ToString(new System.Globalization.CultureInfo("en-US"))); //xw.WriteElementString("speed", mod.model.Orientation.); //xw.WriteElementString("fix", cs.altitude); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteEndElement(); int a = 0; DateTime lastsample = DateTime.MinValue; foreach (CurrentState cs in flightdata) { if (cs.datetime.Second != lastsample.Second) { lastsample = cs.datetime; } else { //continue; } xw.WriteStartElement("wpt"); xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("name", (a++).ToString()); xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz")); xw.WriteElementString("ele", cs.altasl.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteEndElement(); //wpt } xw.WriteEndElement(); xw.Close(); }
/// <summary> /// GenerateXmlElementFromColumn generate a xml element from column's definition. /// </summary> /// <param name="schema">schema name,</param> /// <param name="table">table name</param> /// <param name="c">column</param> /// <param name="keepSymbol">whether keep symbol when convert column anme to property name.</param> /// <param name="xtw">xml text writer</param> /// <param name="elementName">name of the xml element</param> /// <param name="sqlOnly">whether only generate the xml attributes that related to sql.</param> private static void GenerateXmlElementFromColumn(ColumnInfo column, System.Xml.XmlTextWriter xtw) { string initialValue, cSharpType, sqlDefaultValue; initialValue = ""; cSharpType = ""; #region initial type depended attributes switch (GetDataType(column.DataType)) { case SqlDataType.BigInt: cSharpType = "long"; initialValue = "0"; sqlDefaultValue = "0"; //uiLength = Utility.SafeToString(long.MaxValue).Length + 1; break; case SqlDataType.Int: cSharpType = "int"; initialValue = "0"; sqlDefaultValue = "0"; //uiLength = Utility.SafeToString(int.MaxValue).Length + 1; break; case SqlDataType.SmallInt: cSharpType = "short"; initialValue = "0"; sqlDefaultValue = "0"; //uiLength = Utility.SafeToString(short.MaxValue).Length + 1; break; case SqlDataType.TinyInt: cSharpType = "byte"; initialValue = "0"; sqlDefaultValue = "0"; //uiLength = Utility.SafeToString(byte.MaxValue).Length; break; case SqlDataType.Bit: cSharpType = "bool"; initialValue = "false"; sqlDefaultValue = "0"; //uiLength = 5; break; case SqlDataType.Decimal: case SqlDataType.Numeric: cSharpType = "decimal"; initialValue = "0M"; sqlDefaultValue = "0"; //uiLength = Utility.SafeToString(decimal.MaxValue).Length + 1; //sqlType += "(" + c.DataType.NumericPrecision.ToString() + ", " + c.DataType.NumericScale.ToString() + ")"; break; case SqlDataType.Money: case SqlDataType.SmallMoney: cSharpType = "decimal"; initialValue = "0M"; sqlDefaultValue = "0"; //uiLength = Utility.SafeToString(decimal.MaxValue).Length + 1; break; case SqlDataType.Float: cSharpType = "float"; initialValue = "0D"; sqlDefaultValue = "0"; //uiLength = Utility.SafeToString(double.MaxValue).Length + 1; break; case SqlDataType.Real: cSharpType = "float"; initialValue = "0F"; sqlDefaultValue = "0"; //uiLength = Utility.SafeToString(double.MaxValue).Length + 1; break; case SqlDataType.DateTime: case SqlDataType.SmallDateTime: cSharpType = "DateTime"; initialValue = "System.DateTime.MinValue"; sqlDefaultValue = "null"; //uiLength = 10; break; case SqlDataType.UniqueIdentifier: cSharpType = "System.Guid"; initialValue = "System.Guid.Empty"; sqlDefaultValue = "null"; //uiLength = 32; break; case SqlDataType.Char: case SqlDataType.NChar: case SqlDataType.VarChar: case SqlDataType.VarCharMax: case SqlDataType.NVarChar: case SqlDataType.NVarCharMax: case SqlDataType.Text: case SqlDataType.NText: cSharpType = "string"; initialValue = "\"\""; sqlDefaultValue = "''''"; //uiLength = c.DataType.MaximumLength; //if (uiLength <= 0) uiLength = 0; //if (c.DataType.SqlDataType != SqlDataType.Text // && c.DataType.SqlDataType != SqlDataType.NText) //{ // if (c.DataType.MaximumLength > 0) // sqlType += "(" + c.DataType.MaximumLength.ToString() + ")"; // else // { // sqlType = sqlType.Remove(sqlType.Length - 3) + "(max)"; // } //} break; //following SqlDataType are not processed in this version case SqlDataType.Binary: case SqlDataType.Image: case SqlDataType.SysName: case SqlDataType.Timestamp: case SqlDataType.VarBinary: case SqlDataType.VarBinaryMax: case SqlDataType.Variant: case SqlDataType.Xml: case SqlDataType.UserDefinedType: case SqlDataType.UserDefinedDataType: cSharpType = "string"; initialValue = "\"\""; sqlDefaultValue = "''''"; break; default: cSharpType = "string"; initialValue = "\"\""; sqlDefaultValue = "''''"; break; } #endregion //#region process nullable //if (c.Nullable) //{ // //if (!type.Equals("string", StringComparison.InvariantCultureIgnoreCase)) // //{ // // type = string.Concat(type, "?"); // //} // initialValue = "null"; // sqlDefaultValue = "null"; //} //#endregion #region write xml element xtw.WriteStartElement("property"); xtw.WriteAttributeString("sequence", column.Sequence.ToString()); xtw.WriteAttributeString("columnName", column.ColumnName); xtw.WriteAttributeString("dataType", column.DataType); xtw.WriteAttributeString("columnLength", column.ColumnLength.ToString()); xtw.WriteAttributeString("precisionLength", column.PrecisionLength.ToString()); xtw.WriteAttributeString("scale", column.Scale.ToString()); xtw.WriteAttributeString("defaultValue", column.DefaultValue); xtw.WriteAttributeString("columnDescription", column.ColumnDescription); xtw.WriteAttributeString("isIdentity", column.IsIdentity.ToString(System.Globalization.CultureInfo.InvariantCulture)); xtw.WriteAttributeString("isPrimaryKey", column.IsPrimaryKey.ToString(System.Globalization.CultureInfo.InvariantCulture)); xtw.WriteAttributeString("isNullable", column.IsNullable.ToString(System.Globalization.CultureInfo.InvariantCulture)); xtw.WriteAttributeString("lowerName", column.ColumnName.ToLower()); xtw.WriteAttributeString("field", string.Concat("_", column.ColumnName.ToLower())); if (column.DataType == "nvarchar" || column.DataType == "varchar") { xtw.WriteAttributeString("sqlParameter", GetParameter(column.DataType, column.PrecisionLength)); } else { xtw.WriteAttributeString("sqlParameter", GetParameter(column.DataType, column.ColumnLength)); } xtw.WriteAttributeString("csharptype", cSharpType); xtw.WriteAttributeString("getMethod", UtilityHelper.GetXxxMethod(column)); xtw.WriteAttributeString("pattern", UtilityHelper.GetPattern(column.DataType)); xtw.WriteAttributeString("initialValue", initialValue); xtw.WriteEndElement(); #endregion }