public void Close() { if (writer != null) { writer.Close(); writer = null; } else { throw new NotSupportedException("Already closed."); } }
private void WriteListXML(List <DB.Visits> list, string path, string filename) { System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(path + @"\" + filename + ".xml"); writer.WriteStartDocument(); writer.WriteStartElement("Visits"); foreach (var i in list) { writer.WriteStartElement("Visit"); writer.WriteElementString("Patient", i.Patients.FIO); writer.WriteElementString("Doctor", i.Doctors.FullName); writer.WriteElementString("DateStart", i.DateStart.Date + ""); writer.WriteElementString("TimeStart", i.TimeStart + ""); writer.WriteElementString("Cost", i.Cost + ""); writer.WriteElementString("Exempt", i.Exempts.Name); writer.WriteElementString("Summa", i.Summa + ""); writer.WriteElementString("Comment", i.Comment); writer.WriteEndElement(); writer.Flush(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); }
public void Execute(params object[] list) { try { System.Threading.Thread P1 = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(delegate(object obj) { try { var l = ((System.Collections.Generic.Dictionary <string, string>)(((object[])obj)[1])); System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; settings.Encoding = System.Text.Encoding.UTF8; string dataName = "/tmp/" + l.GetHashCode().ToString() + "-" + (System.Guid.NewGuid().ToString()) + ".xml"; using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(dataName, settings)) { System.Runtime.Serialization.DataContractSerializer serializer = new System.Runtime.Serialization.DataContractSerializer(typeof(System.Collections.Generic.Dictionary <string, string>)); serializer.WriteObject(writer, ((System.Collections.Generic.Dictionary <string, string>)(object) list[1])); writer.Close(); } System.Diagnostics.Process PP = new System.Diagnostics.Process(); PP.StartInfo.FileName = "printxls.sh"; PP.StartInfo.Arguments = dataName + " " + list[0]; PP.Start(); PP.WaitForExit(); } catch (Exception ex) { } })); P1.Start(list); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; FeuerwehrCloud.Helper.Logger.WriteLine(ex.ToString()); Console.ForegroundColor = ConsoleColor.Gray; } }
public static void Export(TLArtifactsCollection artifactsCollection, string outputPath, string collectionId, string name, string version, string description) { if (artifactsCollection == null) { throw new TraceLabSDK.ComponentException("Received null artifacts collection."); } System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; settings.CloseOutput = true; settings.CheckCharacters = true; //create file using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(outputPath, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("artifacts_collection"); WriteCollectionInfo(writer, collectionId, name, version, description); WriteArtifacts(artifactsCollection, writer); writer.WriteEndElement(); //artifacts_collection writer.WriteEndDocument(); writer.Close(); } System.Diagnostics.Trace.WriteLine("File created , you can find the file " + outputPath); }
private void _configsave() { string fname = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lircconfig.xml"); if (File.Exists(fname)) { File.Delete(fname); } System.Xml.XmlWriterSettings ws = new System.Xml.XmlWriterSettings(); ws.Indent = true; System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(_remotesconfig.GetType()); System.Xml.XmlWriter wri = System.Xml.XmlWriter.Create(fname, ws); x.Serialize(wri, _remotesconfig); wri.Close(); // try { string lircconfig = ""; foreach (LircRemoteData r in _remotesconfig) { lircconfig += GetString(r.Configuration) + "\n"; } File.WriteAllText("/etc/lirc/lircd.conf", lircconfig); ShellCommand("/etc/init.d/lirc", " force-reload"); } catch { } }
protected static void _StreamXMLPlainLevel(object obj, out SqlXml entry) { entry = SqlXml.Null; Dictionary <string, string> dRow = obj as Dictionary <string, string>; #region Row Output System.IO.MemoryStream ms = new System.IO.MemoryStream(); using (System.Xml.XmlWriter wr = System.Xml.XmlWriter.Create(ms)) { wr.WriteStartElement("Row"); foreach (KeyValuePair <string, string> kvp in dRow) { wr.WriteStartElement(kvp.Key); wr.WriteString(kvp.Value); wr.WriteEndElement(); } wr.WriteEndElement(); wr.Flush(); wr.Close(); } #endregion ms.Seek(0, System.IO.SeekOrigin.Begin); entry = new SqlXml(ms); }
public override void WriteObject(System.Xml.XmlDictionaryWriter writer, object graph) { if (this.info.IsWrapped) { this.serializer.Serialize(writer, graph); } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.OmitXmlDeclaration = true; System.Xml.XmlWriter innerWriter = System.Xml.XmlDictionaryWriter.Create(ms, settings); this.serializer.Serialize(innerWriter, graph); innerWriter.Close(); ms.Position = 0; System.Xml.XmlReader innerReader = System.Xml.XmlDictionaryReader.Create(ms); innerReader.Read(); writer.WriteAttributes(innerReader, false); if ((innerReader.IsEmptyElement == false)) { innerReader.Read(); for ( ; ((innerReader.NodeType == System.Xml.XmlNodeType.EndElement) == false); ) { writer.WriteNode(innerReader, false); } } innerReader.Close(); } }
private void WriteXml(DataSet oDataSet, string sName) { string sXmlPath = string.Empty; System.Xml.XmlWriterSettings oSettings = null; System.Xml.XmlWriter oXmlWriter = null; try { sXmlPath = this.WorkingFolder + sName + ".xml"; oSettings = new System.Xml.XmlWriterSettings(); oSettings.Indent = false; oSettings.CheckCharacters = false; //System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream(); //oXmlWriter = System.Xml.XmlWriter.Create(oMemoryStream, oSettings); oXmlWriter = System.Xml.XmlWriter.Create(sXmlPath, oSettings); oDataSet.WriteXml(oXmlWriter); oXmlWriter.Flush(); oXmlWriter.Close(); } catch (Exception ex) { throw ex; } finally { oSettings = null; oXmlWriter = null; } }
public void WriteFiltered(System.Xml.XmlReader input) { System.Xml.XmlWriter filtered = System.Xml.XmlWriter.Create(FullPath(".filtered.xuk"), mFilter.OutputSettings); mFilter.Transform(input, filtered); filtered.Close(); filtered = null; }
/// <summary> /// Exports the Material Definition Properties to an xml file /// </summary> /// <param name="filename">The filename to write to</param> public void ExportProperties(string filename) { System.Xml.XmlWriterSettings xws = new System.Xml.XmlWriterSettings(); xws.CloseOutput = true; xws.Indent = true; xws.Encoding = System.Text.Encoding.UTF8; System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(filename, xws); try { xw.WriteStartElement("materialDefinition"); xw.WriteComment("Source: " + this.Parent.FileDescriptor.ExportFileName); xw.WriteComment("Block name: " + this.BlockName); xw.WriteComment("File description: " + this.FileDescription); xw.WriteComment("Material Type: " + this.MatterialType); foreach (MaterialDefinitionProperty p in this.properties) { xw.WriteStartElement("materialDefinitionProperty"); xw.WriteAttributeString("name", p.Name); xw.WriteValue(p.Value); xw.WriteEndElement(); } xw.WriteEndElement(); } finally { xw.Close(); xw = null; } }
public static string Serialize(object oObject, bool Indent = false) { System.Xml.Serialization.XmlSerializer oXmlSerializer = null; System.Text.StringBuilder oStringBuilder = null; System.Xml.XmlWriter oXmlWriter = null; string sXML = null; System.Xml.XmlWriterSettings oXmlWriterSettings = null; System.Xml.Serialization.XmlSerializerNamespaces oXmlSerializerNamespaces = null; // ----------------------------------------------------------------------------------------------------------------------- // Lage XML // ----------------------------------------------------------------------------------------------------------------------- oStringBuilder = new System.Text.StringBuilder(); oXmlSerializer = new System.Xml.Serialization.XmlSerializer(oObject.GetType()); oXmlWriterSettings = new System.Xml.XmlWriterSettings(); oXmlWriterSettings.OmitXmlDeclaration = true; oXmlWriterSettings.Indent = Indent; oXmlWriter = System.Xml.XmlWriter.Create(new System.IO.StringWriter(oStringBuilder), oXmlWriterSettings); oXmlSerializerNamespaces = new System.Xml.Serialization.XmlSerializerNamespaces(); oXmlSerializerNamespaces.Add(string.Empty, string.Empty); oXmlSerializer.Serialize(oXmlWriter, oObject, oXmlSerializerNamespaces); oXmlWriter.Close(); sXML = oStringBuilder.ToString(); return(sXML); }
public static void Export(TLSimilarityMatrix answerSet, string sourceId, string targetId, string outputPath) { if (answerSet == null) { throw new TraceLabSDK.ComponentException("Received null answer similarity matrix"); } System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; settings.CloseOutput = true; settings.CheckCharacters = true; //create file using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(outputPath, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("answer_set"); WriteAnswerSetInfo(writer, sourceId, targetId); WriteLinks(answerSet, writer); writer.WriteEndElement(); //answer_set writer.WriteEndDocument(); writer.Close(); } System.Diagnostics.Trace.WriteLine("File created , you can find the file " + outputPath); }
/// <summary> /// Outputs the specified query as an xml document onto the console /// </summary> /// <param name="query"></param> /// <param name="name"></param> private string OutputXML(DBQuery query, string name) { Console.WriteLine("XML statement for :{0} ", name); Console.WriteLine(); System.IO.StringWriter sw = new System.IO.StringWriter(); System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; settings.NewLineHandling = System.Xml.NewLineHandling.Entitize; settings.NewLineOnAttributes = false; settings.ConformanceLevel = System.Xml.ConformanceLevel.Document; settings.CheckCharacters = true; System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(sw, settings); query.WriteXml(writer); writer.Close(); sw.Close(); string all = sw.ToString(); Console.WriteLine(all); ((IDisposable)writer).Dispose(); sw.Dispose(); Console.WriteLine(); return(all); }
static void Main(string[] args) { MyClassProxy p = new MyClassProxy(); p.DSize = new System.Drawing.Size(100, 100); p.WSize = new Size(400, 400); string xml = ""; using (StringWriter sw = new StringWriter()) { System.Xml.XmlWriter wr = System.Xml.XmlWriter.Create(sw); p.WriteXml(wr); wr.Close(); xml = sw.ToString(); } MyClassProxy p2 = new MyClassProxy(); using (StringReader sr = new StringReader(xml)) { System.Xml.XmlReader r = System.Xml.XmlReader.Create(sr); p2.ReadXml(r); } MyClass baseClass = (MyClass)p2; Print(baseClass); Console.ReadKey(); }
/// <summary> /// 序列化对象为xml字符串 /// </summary> /// <param name="obj">要序列化的对象</param> /// <returns>xml格式字符串</returns> public static string Serialize(this object obj) { if (obj == null) { return(""); } Type type = obj.GetType(); if (type.IsSerializable) { try { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type); XmlWriterSettings xset = new XmlWriterSettings(); xset.CloseOutput = true; xset.Encoding = Encoding.UTF8; xset.Indent = true; xset.CheckCharacters = false; System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(sb, xset); xs.Serialize(xw, obj); xw.Flush(); xw.Close(); return(sb.ToString()); } catch { return(""); } } else { return(""); } }
private Boolean isExists() { System.Xml.XmlWriter writer = null; try { if (!File.Exists(FileName)) { System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; writer = System.Xml.XmlWriter.Create(FileName, settings); writer.WriteStartDocument(); writer.WriteStartElement("WebAddresses"); writer.WriteEndElement(); writer.WriteEndDocument(); } } catch (Exception e) { PrintConsole.LOG(e.StackTrace, e.Message); return(false); } finally { if (writer != null) { writer.Flush(); writer.Close(); } } return(true); }
public void Close() { if (!finished) { Finish(); } writer.Close(); }
/// <summary> /// Write the full fileset for the XUK input. /// </summary> public void WriteFileset(System.Xml.XmlReader input) { System.IO.StringWriter writer = new System.IO.StringWriter(); System.Xml.XmlWriter output = System.Xml.XmlWriter.Create(writer); mFilter.Transform(input, output); System.Xml.XPath.XPathDocument filtered = new System.Xml.XPath.XPathDocument(new System.IO.StringReader(writer.ToString())); output.Close(); writer.Close(); writer = new System.IO.StringWriter(); output = System.Xml.XmlWriter.Create(writer); mTransformer.Transform(filtered, mTransformationArguments, output); System.Xml.XPath.XPathDocument z = new System.Xml.XPath.XPathDocument(new System.IO.StringReader(writer.ToString())); output.Close(); writer.Close(); WriteXSLT(z, PACKAGE_XSLT, ".opf"); WriteXSLT(z, NCX_XSLT, ".ncx"); WriteSMILFiles(z); }
} // End Function DownloadPdf public static string BeautifyXML(System.Xml.XmlDocument doc) { string strRetValue = null; System.Text.Encoding enc = System.Text.Encoding.UTF8; // enc = new System.Text.UTF8Encoding(false); System.Xml.XmlWriterSettings xmlWriterSettings = new System.Xml.XmlWriterSettings(); xmlWriterSettings.Encoding = enc; xmlWriterSettings.Indent = true; xmlWriterSettings.IndentChars = " "; xmlWriterSettings.NewLineChars = "\r\n"; xmlWriterSettings.NewLineHandling = System.Xml.NewLineHandling.Replace; //xmlWriterSettings.OmitXmlDeclaration = true; xmlWriterSettings.ConformanceLevel = System.Xml.ConformanceLevel.Document; using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(ms, xmlWriterSettings)) { doc.Save(writer); writer.Flush(); ms.Flush(); writer.Close(); } // End Using writer ms.Position = 0; using (System.IO.StreamReader sr = new System.IO.StreamReader(ms, enc)) { // Extract the text from the StreamReader. strRetValue = sr.ReadToEnd(); sr.Close(); } // End Using sr ms.Close(); } // End Using ms /* * System.Text.StringBuilder sb = new System.Text.StringBuilder(); // Always yields UTF-16, no matter the set encoding * using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(sb, settings)) * { * doc.Save(writer); * writer.Close(); * } // End Using writer * strRetValue = sb.ToString(); * sb.Length = 0; * sb = null; */ xmlWriterSettings = null; return(strRetValue); } // End Function BeautifyXML
private void SerializeParams <T>(XDocument doc, List <T> paramList) { XmlSerializer serializer = new XmlSerializer(paramList.GetType()); System.Xml.XmlWriter writer = doc.CreateWriter(); serializer.Serialize(writer, paramList); writer.Close(); }
public XDocument Serialize(T obj) { XDocument target = new XDocument(); XmlSerializer s = new XmlSerializer(_type); System.Xml.XmlWriter writer = target.CreateWriter(); s.Serialize(writer, obj); writer.Close(); return(target); }
// // .ctor // public System.Xml.XPath.XPathNavigator TransformData(System.Xml.XPath.XPathNavigator nav, int cacheduration, IPDFDataSource source, PDFDataContext context) { //Check we have something to use for a transformation. if (string.IsNullOrEmpty(this.XSLTPath) && null == this.Transformer) { return(nav); } System.Xml.XmlWriter xmlWriter = null; System.IO.MemoryStream memoryStream = null; System.IO.StreamWriter streamWriter = null; System.Xml.XmlDocument result = null; System.Xml.XmlDocument output = new System.Xml.XmlDocument(); try { System.Xml.Xsl.XslCompiledTransform trans = this.DoGetTransformer(cacheduration, source, context); System.Xml.Xsl.XsltArgumentList args = this.DoGetArguments(context); memoryStream = new System.IO.MemoryStream(); streamWriter = new System.IO.StreamWriter(memoryStream, Encoding.UTF8); System.Xml.XmlWriterSettings writerSettings = CreateWriterSettings(); xmlWriter = System.Xml.XmlWriter.Create(streamWriter, writerSettings); trans.Transform(nav, args, xmlWriter); xmlWriter.Flush(); streamWriter.Flush(); result = new System.Xml.XmlDocument(); memoryStream.Position = 0; result.Load(memoryStream); } catch (Exception ex) { throw new PDFDataException(Errors.CouldNotTransformInputData, ex); } finally { if (null != xmlWriter) { xmlWriter.Close(); } if (null != streamWriter) { streamWriter.Dispose(); } if (null != memoryStream) { memoryStream.Dispose(); } } return(result.CreateNavigator()); }
public static XDocument SerializeListToXDocument <T>(List <T> list) { XDocument xDocument = new XDocument(); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(list.GetType()); using (System.Xml.XmlWriter writer = xDocument.CreateWriter()) { serializer.Serialize(writer, list); writer.Close(); } return(xDocument); }
private void Serialize <T>(T obj, string sConfigFilePath) { System.Xml.Serialization.XmlSerializer XmlBuddy = new System.Xml.Serialization.XmlSerializer(typeof(T)); System.Xml.XmlWriterSettings MySettings = new System.Xml.XmlWriterSettings(); MySettings.Indent = true; MySettings.CloseOutput = true; MySettings.OmitXmlDeclaration = true; System.Xml.XmlWriter MyWriter = System.Xml.XmlWriter.Create(sConfigFilePath, MySettings); XmlBuddy.Serialize(MyWriter, obj); MyWriter.Flush(); MyWriter.Close(); }
private void Click_Export(object sender, RoutedEventArgs e) { if (tbxPath.Text.Length == 0) { MessageBox.Show("Выберите папку для сохраения файла!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (rbXLS.IsChecked == true) { string connectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Extended properties = Excel 8.0; Data Source = " + tbxPath.Text + @"\Export.xls"; OleDbConnection conn = new OleDbConnection(connectionString); conn.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = conn; cmd.CommandText = "Create Table [Sponsorships] (Name Varchar, Championship Varchar, Skill Varchar, SponsorClassName Varchar, Sponsor Varchar, Amount Varchar, Picture Varchar)"; cmd.ExecuteNonQuery(); foreach (var i in cs.StaticClass.SponsorshipList) { cmd.CommandText = "Insert Into [Sponsorships] (Name , Championship , Skill , SponsorClassName , Sponsor , Amount , Picture) Values ('" + i.Name + "', '" + i.Championship.Name + "', '" + i.Competition.NameRussian + "', '" + i.SponsorClassName + "', '" + i.Sponsor + "', '" + i.Amount + "', '" + i.Picture + "')"; cmd.ExecuteNonQuery(); } conn.Close(); } else if (rbXML.IsChecked == true) { System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(tbxPath.Text + @"\Export.xml"); writer.WriteStartDocument(); writer.WriteStartElement("Sponsorships"); foreach (var i in cs.StaticClass.SponsorshipList) { writer.WriteStartElement("Sponsorship"); writer.WriteElementString("Name", i.Name); writer.WriteElementString("Championship", i.Championship.Name); writer.WriteElementString("Skill", i.Competition.NameRussian); writer.WriteElementString("SponsorClassName", i.SponsorClassName); writer.WriteElementString("Sponsor", i.Sponsor); writer.WriteElementString("Amount", i.Amount + ""); writer.WriteElementString("Picture", i.Picture + ""); writer.WriteEndElement(); writer.Flush(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); } MessageBox.Show("Экспорт совершён!", "Perfect", MessageBoxButton.OK, MessageBoxImage.Information); }
/* * public MIGServiceConfiguration.Interface GetInterface(string domain) * { * MIGServiceConfiguration.Interface res = MIGService.Interfaces.Find(i => i.Domain == domain); * return res; * } * * public MIGServiceConfiguration.Interface.Option GetInterfaceOption(string domain, string option) * { * return GetInterfaceOptions(domain).Find(o => o.Name == option); * } * * public List<MIGServiceConfiguration.Interface.Option> GetInterfaceOptions(string domain) * { * MIGServiceConfiguration.Interface mi = MIGService.Interfaces.Find(i => i.Domain == domain); * return mi.Options; * } */ public bool Update() { bool success = false; try { SystemConfiguration syscopy = (SystemConfiguration)this.Clone(); foreach (ModuleParameter p in syscopy.HomeGenie.Settings) { try { if (!String.IsNullOrEmpty(p.Value)) { p.Value = StringCipher.Encrypt(p.Value, GetPassPhrase()); } if (!String.IsNullOrEmpty(p.LastValue)) { p.LastValue = StringCipher.Encrypt( p.LastValue, GetPassPhrase() ); } } catch { } } string fname = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "systemconfig.xml"); if (File.Exists(fname)) { File.Delete(fname); } System.Xml.XmlWriterSettings ws = new System.Xml.XmlWriterSettings(); ws.Indent = true; System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(syscopy.GetType()); System.Xml.XmlWriter wri = System.Xml.XmlWriter.Create(fname, ws); x.Serialize(wri, syscopy); wri.Close(); success = true; } catch (Exception) { } // if (OnUpdate != null) { OnUpdate(success); } // return(success); }
private Grammar init() { SrgsRule ruleImie = new SrgsRule("Imię"); SrgsOneOf imie = new SrgsOneOf(new SrgsItem[] { new SrgsItem(1, 1, "Damian"), new SrgsItem(1, 1, "Jan"), new SrgsItem(1, 1, "Katarzyna"), new SrgsItem(1, 1, "Paweł"), new SrgsItem(1, 1, "Adam"), new SrgsItem(1, 1, "Maciej"), new SrgsItem(1, 1, "Maja"), new SrgsItem(1, 1, "Grzegorz") }); ruleImie.Add(imie); SrgsRule ruleNazwisko = new SrgsRule("Nazwisko"); SrgsOneOf nazwisko = new SrgsOneOf(new SrgsItem[] { new SrgsItem(1, 1, "Redkiewicz"), new SrgsItem(1, 1, "Piechota"), new SrgsItem(1, 1, "Klatka"), new SrgsItem(1, 1, "Kowalski"), new SrgsItem(1, 1, "Nowak"), new SrgsItem(1, 1, "Brzęczyszczykiewicz") }); ruleNazwisko.Add(nazwisko); SrgsRule rootRule = new SrgsRule("rootBiletomat"); rootRule.Scope = SrgsRuleScope.Public; rootRule.Add(new SrgsRuleRef(ruleImie, "IMIE")); rootRule.Add(new SrgsRuleRef(ruleNazwisko, "NAZWISKO")); SrgsDocument docBiletomat = new SrgsDocument(); docBiletomat.Culture = pRecognitionLanguage; docBiletomat.Rules.Add(new SrgsRule[] { rootRule, ruleImie, ruleNazwisko } ); docBiletomat.Root = rootRule; System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create("srgsDocument.xml"); docBiletomat.WriteSrgs(writer); writer.Close(); Grammar gramatyka = new Grammar(docBiletomat, "rootBiletomat"); return(gramatyka); }
public void WriteInFile(String filename) { try { System.Xml.Linq.XDocument xDoc = new System.Xml.Linq.XDocument(new System.Xml.Linq.XDeclaration("1.0", "UTF-16", null), xelement); System.IO.StringWriter sw = new System.IO.StringWriter(); System.Xml.XmlWriter xWrite = System.Xml.XmlWriter.Create(sw); xDoc.Save(xWrite); xWrite.Close(); xDoc.Save(filename); } catch { } }
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue); Message msg = buffer.CreateMessage(); StringBuilder sb = new StringBuilder(); using (System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(sb)) { msg.WriteMessage(xw); xw.Close(); } var s = sb.ToString(); HttpContext.Current.Items.Add("requestBody", s); return null; }
private void frm_main_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing && !minimized && !forceclose) { minimize(); e.Cancel = true; } xConfig c = new xConfig(); System.Xml.Serialization.XmlSerializer xser = new System.Xml.Serialization.XmlSerializer(typeof(xConfig)); System.Xml.XmlWriter xwri = System.Xml.XmlWriter.Create(Application.StartupPath + "\\config.xml"); xser.Serialize(xwri, c); xwri.Close(); }
public void Export(string filename) { _writer = new System.Xml.XmlTextWriter(filename, System.Text.Encoding.UTF8); _writer.WriteStartDocument(); _writer.WriteStartElement("LinearPredictionModel"); WriteProperties(); WriteSpectralPreprocessing(); WriteLinearPredictionData(); _writer.WriteEndElement(); // PLSCalibrationModel _writer.WriteEndDocument(); _writer.Close(); }