WriteProcessingInstruction() public method

public WriteProcessingInstruction ( string name, string text ) : void
name string
text string
return void
Example #1
0
 public override void Serialize(XmlTextWriter xtw)
 {            
     xtw.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
     xtw.WriteStartElement("xCal", "iCalendar", "urn:ietf:params:xml:ns:xcal");
     base.Serialize(xtw);
     xtw.WriteEndElement();
 }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/opensearchdescription+xml";

            using (XmlTextWriter writer = new XmlTextWriter(context.Response.OutputStream, System.Text.Encoding.UTF8))
            {
                //get the details from host object
                Host host = HostCache.GetHost(HostHelper.GetHostAndPort(context.Request.Url));

                writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                writer.WriteStartElement("OpenSearchDescription", "http://a9.com/-/spec/opensearch/1.1/");
                writer.WriteElementString("ShortName", host.SiteTitle);
                writer.WriteElementString("Description", host.SiteDescription);
                writer.WriteElementString("Contact", host.Email);

                writer.WriteStartElement("Image");
                writer.WriteAttributeString("height", "16");
                writer.WriteAttributeString("weight", "16");
                writer.WriteAttributeString("type", "image/x-icon");
                writer.WriteString(string.Format("{0}/favicon.ico", host.RootUrl));
                writer.WriteEndElement();

                writer.WriteStartElement("Url");
                writer.WriteAttributeString("type", "text/html");
                writer.WriteAttributeString("method", "GET");
                writer.WriteAttributeString("template", string.Format("{0}/search?q={{searchTerms}}&user=False&page={{startPage?}}", host.RootUrl));
                writer.WriteEndElement();

                writer.Flush();
            }
        }
Example #3
0
        public override string ToString()
        {
            string doc;

            using (var sw = new StringWriter()) {
                using (var writer = new XmlTextWriter(sw)) {
                    writer.Formatting = Formatting.Indented;
                    //writer.WriteStartDocument();
                    writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
                    writer.WriteStartElement("D", "multistatus", "DAV:");
                    for (int i = 0; i < _nameSpaceList.Count; i++) {
                        string tag = string.Format("ns{0}", i);
                        writer.WriteAttributeString("xmlns", tag, null, _nameSpaceList[i]);
                    }

                    foreach (var oneResponse in _ar) {
                        oneResponse.Xml(writer);
                    }
                    writer.WriteEndElement();
                    //writer.WriteEndDocument();
                    writer.Flush();
                    writer.Close();
                    doc = sw.ToString();
                    writer.Flush();
                    writer.Close();
                }
                sw.Flush();
                sw.Close();
            }
            return doc;
        }
Example #4
0
 public GlobalXMLManipulatorWriter(string fileName, bool scrabled)
     : base(null)
 {
     try
     {
         if (scrabled)
         {
             Exception exception = new Exception("Incorrect file!");
             throw exception;
         }
         this._xmlDoc = new XmlDocument();
         this._fileName = fileName;
         XmlTextWriter writer = new XmlTextWriter(this._fileName, Encoding.UTF8) {
             Formatting = Formatting.Indented
         };
         writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
         writer.Close();
         this._xmlDoc.Load(this._fileName);
         XmlNode documentElement = this._xmlDoc.DocumentElement;
         base._parentNode = base._iteratorNode = (XmlElement) documentElement;
         if (base._parentNode != null)
         {
             base.isInitialized = true;
         }
     }
     catch (Exception exception2)
     {
         GlobalXMLManipulator._log.Error("Invalid File to load! GlobalXMLManipulatorWriter()\n" + exception2.Message);
     }
 }
Example #5
0
        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();
        }
 public void writeOptions()
 {
     Directory.CreateDirectory(OPTIONS_PATH);
     XmlDocument xmlDoc = new XmlDocument();
     try
     {
         xmlDoc.Load(OPTIONS_FILE);
     }
     catch (System.IO.FileNotFoundException)
     {
         //if file is not found, create a new xml file
         XmlTextWriter xmlWriter = new XmlTextWriter(OPTIONS_FILE, System.Text.Encoding.UTF8);
         xmlWriter.Formatting = Formatting.Indented;
         xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
         xmlWriter.WriteStartElement("root");
         //If WriteProcessingInstruction is used as above,
         //Do not use WriteEndElement() here
         //xmlWriter.WriteEndElement();
         //it will cause the <Root> to be &ltRoot />
         xmlWriter.Close();
         xmlDoc.Load(OPTIONS_FILE);
     }
     XmlNode root = xmlDoc.DocumentElement;
     root.AppendChild(asXML(root));
     xmlDoc.Save(OPTIONS_FILE);
 }
Example #7
0
		/// <summary>
		/// This function retuns list of states for a given country as XML Document in a string 
		/// and this value is used in client side java script to populate state combo box.
		/// Functionality: Transform the CountriesAndStates xml string into another XML string having the single country 
		/// and states under that country. 
		/// </summary>
		public string GetStatesXMLString(string countryName)
		{
			//Creates a XslTransform object and load the CountriesAndStates.xsl file
			XslTransform transformToCountryNode = new XslTransform();
			transformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver());
			//TransformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver(), this.GetType().Assembly.Evidence);

			//Creating the XSLT parameter country-name and setting the value
			XsltArgumentList xslArgs = new XsltArgumentList();
			xslArgs.AddParam("country-name", "", countryName);
				
			// Memory stream to store the result of XSL transform 
			MemoryStream countryNodeMemoryStream = new MemoryStream(); 
			XmlTextWriter countryNodeXmlTextWriter = new XmlTextWriter(countryNodeMemoryStream, Encoding.UTF8); 
			countryNodeXmlTextWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");

			//transforming the current XML string to get the state XML string
			transformToCountryNode.Transform(xPathDoc, xslArgs,  countryNodeXmlTextWriter);
			//TransformToCountryNode.Transform(XPathDoc, XslArgs,  CountryNodeXmlTextWriter, null);

			//reading the XML string using StreamReader and return the same
			countryNodeXmlTextWriter.Flush(); 
			countryNodeMemoryStream.Position = 0; 
			StreamReader countryNodeStreamReader = new StreamReader(countryNodeMemoryStream); 
			return  countryNodeStreamReader.ReadToEnd(); 
		}
Example #8
0
        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);
            }
        }
		public override void SaveSettings()
		{
            if (!this.writeable)
                throw new InvalidOperationException("Attempted to write to a non-writeable Settings Storage");

			string dirPath = Path.GetDirectoryName( filePath );
			if ( !Directory.Exists( dirPath ) )
				Directory.CreateDirectory( dirPath );

			XmlTextWriter writer = new XmlTextWriter(  filePath, System.Text.Encoding.UTF8 );
			writer.Formatting = Formatting.Indented;

			writer.WriteProcessingInstruction( "xml", "version=\"1.0\"" );
			writer.WriteStartElement( "NUnitSettings" );
			writer.WriteStartElement( "Settings" );

			ArrayList keys = new ArrayList( settings.Keys );
			keys.Sort();

			foreach( string name in keys )
			{
				object val = settings[name];
				if ( val != null )
				{
					writer.WriteStartElement( "Setting");
					writer.WriteAttributeString( "name", name );
					writer.WriteAttributeString( "value", val.ToString() );
					writer.WriteEndElement();
				}
			}

			writer.WriteEndElement();
			writer.WriteEndElement();
			writer.Close();
		}
Example #10
0
        static public bool SimpleDumper(string XMLFileName, Type type)
        {
            using (XmlTextWriter writer = new XmlTextWriter(XMLFileName, null))
            {
                Type[] types = { typeof(EffectInstanceDice) };// asm.GetTypes().Where(entry => entry.Namespace != null && entry.GetConstructor(System.Type.EmptyTypes) != null && entry.Namespace.StartsWith("BiM.Protocol.Data")).ToArray<Type>();
                try
                {
                    writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"");

                    XmlSerializer d2oSerializer = new XmlSerializer(type, types);
                    writer.WriteStartElement(type.Name + "_root");
                    // write
                    //using (var stream = File.Create(XMLFileName))
                    {
                        foreach (object obj in ObjectDataManager.Instance.EnumerateObjects(type))
                        {
                            d2oSerializer.Serialize(writer, obj); // your instance
                        }
                    }
                    writer.WriteEndElement();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }

            }
            // Open a file for reading
            cleanXML(XMLFileName, false);
            return true;
        }
Example #11
0
        public XmlFile(FileInfo file, bool create, string root_name) {
            this.File = file;
            file.Refresh();
            if (!file.Exists) {
				if(create) {
                	XmlTextWriter write_here = new XmlTextWriter(file.FullName, System.Text.Encoding.UTF8);
                	write_here.Formatting = Formatting.Indented;
                	write_here.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
					//write_here.WriteStartElement(root_name);
					//write_here.WriteEndElement();
					write_here.Close();
				} else {
					throw new FileNotFoundException("XMl file not found",file.FullName);
				}
            }
            XmlReader parse_me = XmlReader.Create(file.FullName, xml_settings);
            try {
                this.Load(parse_me);
            } catch (Exception ex) {
                IXmlLineInfo info = parse_me as IXmlLineInfo;
                throw new XmlException(file.FullName + Environment.NewLine + Environment.NewLine + "Line: " + info.LineNumber + " Column: " + info.LinePosition, ex);
            } finally {
                parse_me.Close();
            }
        }
Example #12
0
		public void Save (System.IO.Stream stream)
		{
			try {
				XmlTextWriter text;
				RdfXmlWriter writer;
                                XmlDocument rdfdoc = new XmlDocument();

                                // first, construct the rdf guts, semweb style
                                writer = new XmpWriter (rdfdoc);
				//writer.Namespaces.Parent = MetadataStore.Namespaces;
				writer.Write (store);
				writer.Close ();
			       
                                // now construct the xmp wrapper packet
				text = new XmlTextWriter (stream, System.Text.Encoding.UTF8);
 				text.Formatting = Formatting.Indented;
                        
                                text.WriteProcessingInstruction ("xpacket", "begin=\"\ufeff\" id=\"W5M0MpCehiHzreSzNTczkc9d\"");
                                text.WriteStartElement ("x:xmpmeta");
                                text.WriteAttributeString ("xmlns", "x", null, "adobe:ns:meta/");

				((XmlElement)rdfdoc.ChildNodes[1]).RemoveAttribute ("xml:base");
				rdfdoc.ChildNodes[1].WriteTo (text);

                                // now close off the xmp packet
                                text.WriteEndElement ();
                                text.WriteProcessingInstruction ("xpacket", "end=\"r\"");
				text.Close ();
				
			} catch (System.Exception e) {
				//System.Console.WriteLine (e);
			}
		}
Example #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            // OpenFileDialog openFileDlg = new OpenFileDialog();
            //openFileDlg.InitialDirectory = "c:\\";
            //openFileDlg.RestoreDirectory = true;

            //连接到数据资源
            OleDbConnection objConnect = new OleDbConnection(strConnect);

            try
            {
                objConnect.Open();
                //记录填补一个客户表格的数据
                OleDbCommand     objCmd     = new OleDbCommand("select * from [Sheet1$]", objConnect);
                OleDbDataAdapter objAdapter = new OleDbDataAdapter();
                objAdapter.SelectCommand = objCmd;
                DataSet objDataSet = new DataSet();
                objAdapter.Fill(objDataSet);
                System.IO.FileStream     fs        = new System.IO.FileStream("C:\\Customers.xml", System.IO.FileMode.Create);
                System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(fs, System.Text.Encoding.Unicode);
                xmlWriter.WriteProcessingInstruction("xml", "version='1.0'");
                objDataSet.WriteXml(xmlWriter);
                xmlWriter.Close();
                objConnect.Close();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #14
0
        /// <summary>
        /// 
        /// </summary>
        protected override void WriteHeader()
        {
            writer = base.GetXmlTextWriter();
            writer.Formatting = Formatting.Indented;

            writer.WriteProcessingInstruction("xml", "version=\"1.0\"");
            writer.WriteProcessingInstruction("zpl", "version=\"1.0\"");
            writer.WriteStartElement("smil");

            writer.WriteStartElement("head");
            writer.WriteElementString("title", base.name + " Playlist");
            writer.WriteElementString("generator", App.NameVersion);
            writer.WriteEndElement(); // head

            writer.WriteStartElement("body");
            writer.WriteStartElement("seq");
        }
 protected override bool createConfig(string file_name) {
     XmlTextWriter write_here = new XmlTextWriter(file_name, System.Text.Encoding.UTF8);
     write_here.Formatting = Formatting.Indented;
     write_here.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
     write_here.WriteStartElement("settings");
     write_here.Close();
     return true;
 }
Example #16
0
 protected internal override bool OnNext()
 {
     string text = this._fileNameTextBox.Text;
     if (text.Length == 0)
     {
         MessageBox.Show(base.WizardForm, "You must specify a filename", "Export Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         return false;
     }
     if (text.IndexOfAny(Path.InvalidPathChars) != -1)
     {
         MessageBox.Show(base.WizardForm, "The specified filename contains invalid characters.", "Export Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         return false;
     }
     ListSnippetsWizardPanel snippetList = ((ExportSnippetsWizard) base.WizardForm).SnippetList;
     FileStream stream = null;
     bool flag = false;
     try
     {
         if (Path.GetExtension(text).Length == 0)
         {
             text = text + ".snippets";
         }
         stream = new FileStream(text, FileMode.Create, FileAccess.Write, FileShare.Write);
         XmlTextWriter writer = new XmlTextWriter(new StreamWriter(stream, Encoding.UTF8));
         writer.Formatting = Formatting.Indented;
         writer.Indentation = 4;
         writer.IndentChar = ' ';
         writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
         writer.WriteStartElement("Snippets");
         foreach (SnippetToolboxDataItem item in snippetList.CheckedToolboxDataItems)
         {
             writer.WriteStartElement("Snippet");
             if (item.InternalDisplayName.Length > 0)
             {
                 writer.WriteAttributeString("name", item.InternalDisplayName);
             }
             writer.WriteString(item.ToolboxData);
             writer.WriteEndElement();
         }
         writer.WriteEndElement();
         writer.Flush();
         writer.Close();
     }
     catch
     {
         MessageBox.Show(base.WizardForm, "The specified file could not be written.", "Export Snippets", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         flag = true;
     }
     finally
     {
         if (stream != null)
         {
             stream.Close();
         }
     }
     return !flag;
 }
Example #17
0
        public void LogIt(DateTime exceptionDate, string exceptionSource, string exceptionMessage)
        {
            Console.WriteLine(" XML Logger ");

            try
            {
                const string fileName = "appLog.xml";
                var xmlDocument = new XmlDocument();

                try
                {
                    xmlDocument.Load(fileName);
                }
                catch (FileNotFoundException)
                {
                    var xmlWriter = new XmlTextWriter(fileName, System.Text.Encoding.UTF8) { Formatting = Formatting.Indented };
                    xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                    xmlWriter.WriteStartElement("Logs");
                    xmlWriter.Close();
                    xmlDocument.Load(fileName);
                }

                XmlNode logRoot = xmlDocument.DocumentElement;
                XmlElement logElement = xmlDocument.CreateElement("log");
                XmlElement dateElement = xmlDocument.CreateElement("exceptionDate");
                XmlElement sourceElement = xmlDocument.CreateElement("exceptionSource");
                XmlElement messageElement = xmlDocument.CreateElement("exceptionMessage");

                XmlText dateText = xmlDocument.CreateTextNode("date");
                dateText.Value = exceptionDate.ToString();
                XmlText sourceText = xmlDocument.CreateTextNode("source");
                sourceText.Value = exceptionSource;
                XmlText messageText = xmlDocument.CreateTextNode("message");
                messageText.Value = exceptionMessage;

                logRoot.AppendChild(logElement);

                dateElement.AppendChild(dateText);
                sourceElement.AppendChild(sourceText);
                messageElement.AppendChild(messageText);

                logElement.AppendChild(dateElement);
                logElement.AppendChild(sourceElement);
                logElement.AppendChild(messageElement);

                xmlDocument.Save(fileName);
            }
            catch (Exception)
            {
                Console.WriteLine(" Ya mejor lo escribo en pantalla ");
            }
        }
        public override void ProcessRequest(string request, ref Socket socket, bool authenticated, string body)
        {
            QueryString query = new QueryString(request);

            String sMimeType = "text/xml";
            string data="";

            string id = query.GetValues("id")[0];
            int hash = 0;
            try
            {
                hash = Convert.ToInt32(id);
                if (Earth3d.ImagesetHashTable.ContainsKey(hash))
                {

                    StringBuilder sb = new StringBuilder();
                    StringWriter sw = new StringWriter(sb);
                    using (XmlTextWriter xmlWriter = new XmlTextWriter( sw ))
                    {
                        xmlWriter.Formatting = Formatting.Indented;
                        xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                        xmlWriter.WriteStartElement("Folder");

                        IImageSet imageset = (IImageSet)Earth3d.ImagesetHashTable[hash];
                        string alternateUrl = "";

                        try
                        {
                            if (File.Exists(imageset.Url))
                            {
                                alternateUrl = string.Format("http://{0}:5050/imageset/{1}/{2}", MyWebServer.IpAddress, hash, Path.GetFileName(imageset.Url));
                            }
                        }
                        catch
                        {
                        }
                        ImageSetHelper.SaveToXml(xmlWriter, imageset, alternateUrl);
                        xmlWriter.WriteFullEndElement();
                        xmlWriter.Close();
                    }
                    data = sb.ToString();
                }
            }
            catch
            {
            }

            SendHeaderAndData(data, ref socket, sMimeType);
        }
        public static string GenerateEntityXml(string outputPath, EntityInfo entity)
        {
            string ret = String.Empty;

            if (entity == null || !Directory.Exists(outputPath))
            {
                return(ret);
            }

            Log4Helper.Write("GenerateEntityXml", String.Format("Process of entity {0} starts at {1}.", entity.ClassName, System.DateTime.Now.ToString("s")), LogSeverity.Info);

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(System.IO.Path.Combine(outputPath, String.Concat(entity.ClassName, ".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("namespace", entity.NameSpace);
                xtw.WriteAttributeString("name", entity.ClassName);

                #region columns/properties
                //generate property node
                xtw.WriteStartElement("fields");
                foreach (FieldInfo field in entity.Fileds)
                {
                    xtw.WriteStartElement("property");
                    xtw.WriteAttributeString("type", field.Type);
                    xtw.WriteAttributeString("name", field.Name);
                    xtw.WriteAttributeString("privateFieldName", field.PrivateFieldName);
                    xtw.WriteAttributeString("paramName", field.ParamName);
                    xtw.WriteAttributeString("propetyName", field.PropertyName);
                    xtw.WriteAttributeString("csharpType", field.CSharpType);
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                #endregion
                ret = xtw.ToString();
                xtw.WriteEndElement();
                xtw.Flush();
                xtw.Close();
            }

            Log4Helper.Write("GenerateEntityXmlFromTable", String.Format("Process of table {0} ends at {1}.", entity.ClassName, System.DateTime.Now.ToString("s")), LogSeverity.Info);
            return(ret);
        }
Example #20
0
        public static void MesajLogla(string uri, ArrayList mesajlar)
        {
            string kisiURI = Regex.Replace(uri, @"\W", "_");
            istemciKlasorYolu = Regex.Replace(istemciURI, @"\W", "_");

            StringBuilder dosyaAdi = new StringBuilder();
            dosyaAdi.Append("mesajlar_").Append(kisiURI).Append(".xml");

            if (!Directory.Exists(gecerliDizin)) // Mesajlar klasörü yoksa oluþtur...
            {
                Directory.CreateDirectory(gecerliDizin);
            }

            if (!Directory.Exists(gecerliDizin + "\\" + istemciKlasorYolu)) // istemcinin klasörü yoksa oluþtur...
            {
                Directory.CreateDirectory(gecerliDizin + "\\" + istemciKlasorYolu);
            }

            if (!File.Exists(gecerliDizin + "\\" + istemciKlasorYolu + "\\MesajlarXSL.xsl"))
            {
                try
                {
                    File.Copy(gecerliDizin + "\\MesajlarXSL.xsl", gecerliDizin + "\\" + istemciKlasorYolu + "\\MesajlarXSL.xsl");
                }
                catch (IOException)
                {
                }
            }

            if (!File.Exists(gecerliDizin + "\\" + istemciKlasorYolu + "\\" + dosyaAdi)) // log dosyasý yoksa oluþtur...
            {
                XmlTextWriter writer = new XmlTextWriter(gecerliDizin + "\\" + istemciKlasorYolu + "\\" + dosyaAdi, Encoding.GetEncoding(1254));
                
                writer.WriteStartDocument();
                    writer.WriteProcessingInstruction("xml-stylesheet", "type='text/xsl' href='MesajlarXSL.xsl'");
                    writer.WriteStartElement("Log"); // kök elemaný oluþtur
                    writer.WriteEndElement();
                writer.WriteEndDocument();

                writer.Close();
                writer = null;
            }

            Loging(mesajlar, dosyaAdi);
        }
Example #21
0
        /// <summary>
        /// װ��Xml�ĵ�����������򴴽�
        /// </summary>
        /// <param name="path"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static XmlDocument Load(string filepath)
        {
            string path = Path.GetDirectoryName(filepath);
            string filename = Path.GetFileName(filepath);
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);

            if (!File.Exists(filepath))
            {
                XmlTextWriter writer = null;

                writer = new XmlTextWriter(filepath, Encoding.UTF8);

                //Write the XML delcaration.
                writer.WriteStartDocument();

                //Write the ProcessingInstruction node.
                String PItext = "type='text/xsl'";
                writer.WriteProcessingInstruction("xml-stylesheet", PItext);

                //Write a Comment node.
                writer.WriteComment("user XML");

                writer.WriteStartElement(filename.Substring(0, filename.LastIndexOf('.')));
                writer.WriteAttributeString("UpdateDate", DateTime.Now.ToString());

                writer.WriteEndElement();

                writer.WriteEndDocument();

                //Write the XML to file and close the writer.
                writer.Flush();
                writer.Close();
            }
            XmlDocument doc = new XmlDocument();
            while (true)
            {
                try
                {
                    doc.Load(filepath);
                    return doc;
                }
                catch { }
            }
        }
Example #22
0
        /// <summary>
        /// creates logfile
        /// </summary>
        private void open()
        {
            if (this.opened_)
            {
                return;
            }
            try
            {
                if (theSwitch.Level > TraceLevel.Off)
                {
                    xmlwriter            = new System.Xml.XmlTextWriter(this.file_path, null);
                    xmlwriter.Formatting = System.Xml.Formatting.Indented;
                    xmlwriter.WriteStartDocument();
                    //Write the ProcessingInstruction node.
                    string PItext = theSwitch.style_instruction_pitext(string.Empty);
                    if (PItext != string.Empty)
                    {
                        xmlwriter.WriteProcessingInstruction("xml-stylesheet", PItext);
                    }

                    xmlwriter.WriteStartElement("trace");
                    xmlwriter.WriteAttributeString("timestamp", timestamp());
                    xmlwriter.WriteAttributeString("assembly", this.asm.FullName);
                    xmlwriter.WriteStartElement("switch");
                    // xmlwriter.WriteAttributeString( "displayname" , theSwitch.DisplayName) ;
                    // xmlwriter.WriteAttributeString( "description" , theSwitch.Description ) ;
                    xmlwriter.WriteAttributeString("level", theSwitch.Level.ToString());
                    xmlwriter.WriteEndElement();                     // close 'switch'
                }
                this.opened_ = true;
            }
            catch (Exception x)
            {
                evlog.internal_log.error(x); x = null;
            }
            finally
            {
                if (this.xmlwriter != null)
                {
                    xmlwriter.Close();
                }
                this.xmlwriter = null;
            }
        }
Example #23
0
        public static string returnXmlXslTransformation(string sXmlPath, string sXslPath, string sTargetFilePath)
        {
            XmlTextReader xtrXslFile = new XmlTextReader(sXslPath);
            XPathDocument myXPathDoc = null;
            XslCompiledTransform myXslTrans= null;
            XmlTextWriter myWriter= null;
            try
            {
                //load the Xml doc
                myXslTrans = new XslCompiledTransform() ;

                //load the Xsl into a  XmlTextReader and into the XslTransform
                myXslTrans.Load(xtrXslFile);

                // Create the XsltArgumentList.
                XsltArgumentList argList = new XsltArgumentList();
                argList.AddParam("date", "", DateTime.Now.ToString());

                //create the output stream
                myWriter = new XmlTextWriter(sTargetFilePath, null);
                myWriter.WriteProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");

                //do the actual transform of Xml
                myXslTrans.Transform(new XPathDocument(sXmlPath), argList, myWriter);
                myWriter.Close() ;
            }
            catch(Exception ex)
            {
                // clean up
                if (null != myXPathDoc)
                    myXPathDoc = null;
                if (null != myXslTrans)
                    myXslTrans = null;
                if (null != myWriter)
                    myWriter.Close();
                if (null !=xtrXslFile)
                    xtrXslFile.Close();
                return ex.ToString();

            }
            xtrXslFile.Close();
            return "";
        }
Example #24
0
        public void Form1_Load(object sender, EventArgs e)
        {
            #region Load interfaces xml
            try
            {
                interfaces.Load(executablePath + "\\" + Settings.Default.XMLFile);
            }

            catch(System.IO.FileNotFoundException)
            {
                XmlTextWriter xmlWriter = new XmlTextWriter(Settings.Default.XMLFile, System.Text.Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                xmlWriter.WriteStartElement("applications");
                xmlWriter.Close();
                interfaces.Load(executablePath + "\\" + Settings.Default.XMLFile);
            }
            #endregion

            #region Load configuration xml
            try
            {
                interfaces.Load(executablePath + "\\" + Settings.Default.ConfigXMLFile);
            }

            catch (System.IO.FileNotFoundException)
            {
                XmlTextWriter xmlWriter = new XmlTextWriter(Settings.Default.ConfigXMLFile, System.Text.Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                xmlWriter.WriteStartElement("settings");
                xmlWriter.Close();
                interfaces.Load(executablePath + "\\" + Settings.Default.ConfigXMLFile);

                ConfigureEmailForm configureEmail = new ConfigureEmailForm();
                configureEmail.ShowDialog();
            }
            #endregion

            loadComboBox();

            editLabel.Hide();
        }
Example #25
0
        public override string ToString()
        {
            string doc;

            using (var sw = new StringWriter()) {
                using (var writer = new XmlTextWriter(sw)) {
                    writer.Formatting = Formatting.Indented;

                    writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"");
                    writer.WriteStartElement("D", "multistatus", "DAV:");
                    for (var i = 0; i < _nameSpaceList.Count; i++) {
                        var tag = string.Format("ns{0}", i);
                        writer.WriteAttributeString("xmlns", tag, null, _nameSpaceList[i]);
                    }

                    writer.WriteStartElement("D", "response", "DAV:");
                    writer.WriteElementString("D", "href", "DAV:", _href);
                    foreach (OneProp oneProp in _ar) {
                        //1つの設定値を1つのpropstatエレメントに格納する
                        writer.WriteStartElement("D", "propstat", "DAV:");

                        writer.WriteStartElement("D", "prop", "DAV:");
                        writer.WriteElementString(oneProp.Tag, oneProp.Name, oneProp.NameSpace, "");
                        writer.WriteEndElement();//prop

                        writer.WriteElementString("D", "status", "DAV:", oneProp.StatusStr);
                        if (oneProp.ResponsedescriptionStr != null) {
                            writer.WriteElementString("D", "responsedescription", "DAV:", oneProp.ResponsedescriptionStr);
                        }
                        writer.WriteEndElement();//propstat
                    }
                    writer.WriteEndElement();//response
                    writer.WriteEndElement();//multistatus
                    writer.Flush();
                    writer.Close();
                    doc = sw.ToString();
                }
                sw.Flush();
                sw.Close();
            }
            return doc;
        }
Example #26
0
        public static string GetToursXML()
        {
            List<Tour> sqlTours = new List<Tour>();
            int rc = GetSQLTourArrayList(sqlTours);

            if (sqlTours.Count > 0)
            {
                using (StringWriter sw = new StringWriter())
                {
                    using (XmlTextWriter xmlWriter = new XmlTextWriter(sw))
                    {
                        xmlWriter.Formatting = Formatting.Indented;
                        xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
                        xmlWriter.WriteStartElement("Folder");
                        foreach (Tour tr in sqlTours)
                        {
                            xmlWriter.WriteStartElement("Tour");
                            xmlWriter.WriteAttributeString("Title", tr.TourTitle);
                            xmlWriter.WriteAttributeString("ID", tr.TourGuid.ToString());
                            xmlWriter.WriteAttributeString("Description", tr.TourDescription);
                            xmlWriter.WriteAttributeString("Classification", "Other");
                            xmlWriter.WriteAttributeString("AuthorEmail", tr.AuthorEmailAddress);
                            xmlWriter.WriteAttributeString("Author", tr.AuthorName);
                            xmlWriter.WriteAttributeString("AuthorUrl", tr.AuthorURL);
                            xmlWriter.WriteAttributeString("AverageRating", tr.AverageRating.ToString());
                            xmlWriter.WriteAttributeString("LengthInSecs", tr.LengthInSecs.ToString());
                            xmlWriter.WriteAttributeString("OrganizationUrl", tr.OrganizationURL);
                            xmlWriter.WriteAttributeString("OrganizationName", tr.OrganizationName);
                            xmlWriter.WriteEndElement();
                        }
                        xmlWriter.WriteEndElement();

                        xmlWriter.Close();
                    }
                    sw.Close();
                    return sw.ToString();
                }
            }
            return "";
        }
Example #27
0
        /// <summary>
        /// GenerateEntityXmlFromTable generates a xml file basing on the information of the table passed in.
        /// </summary>
        public static void GenerateEntityXmlFromTable(Table table, ArrayList columns, ArrayList extSettings, string outputFile)
        {
            if (table != null && System.IO.File.Exists(outputFile))
            {
                System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(outputFile, 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("tableName", table.TableName);
                xtw.WriteAttributeString("tableSchema", table.TableSchema);
                if (extSettings != null)
                {
                    foreach (ExtSetting e in extSettings)
                    {
                        xtw.WriteAttributeString(e.Name, e.Value);
                    }
                }
//					xtw.WriteAttributeString("namespace", codeNamespace);
//                    xtw.WriteAttributeString("author", Utility.GetCurrentIdentityName());
//                    xtw.WriteAttributeString("createdDateTime", System.DateTime.Now.ToString("s"));
                xtw.WriteAttributeString("BuildProject", BUILDPROJECT_VERSION);

                #region columns/properties
                //generate property node
                xtw.WriteStartElement("columns");
                for (int i = 0; i < columns.Count; i++)
                {
                    GenerateXmlElementFromColumn((Column)columns[i], xtw);
                }
                xtw.WriteEndElement();
                #endregion

                xtw.WriteEndElement();
                xtw.Flush();
                xtw.Close();
            }
        }
Example #28
0
        private void transformBtn_Click(object sender, EventArgs e)
        {
            try
            {               
                if (isInputValid())
                {
                    Cursor.Current = Cursors.WaitCursor;
                    this.toolStripStatusLabel.Text = "Transforming XML";
                    //load the Xml doc
                    XPathDocument myXPathDoc = new XPathDocument(this.inputXMLTxtBox.Text);
                    XslTransform myXslTrans = new XslTransform();

                    myXslTrans.Load(new XmlTextReader(new StringReader(Properties.Resources._4_to_4_1)));

                    //create the output stream
                    XmlTextWriter myWriter = new XmlTextWriter
                        (this.outputXMLTxtBox.Text, null);
                    myWriter.Formatting = Formatting.Indented;

                    myWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");

                    //do the actual transform of Xml
                    myXslTrans.Transform(myXPathDoc, null, myWriter);
                    myWriter.Close();
                    Cursor.Current = Cursors.Default;
                    this.toolStripStatusLabel.Text = "Transformation Complete";
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.ToString());
                Console.WriteLine(ex.StackTrace);
                Cursor.Current = Cursors.Default;
                this.toolStripStatusLabel.Text = ex.Message;
                MessageBox.Show("Error Transforming XML " + ex.Message);
            }
        }
        public static void GenerateTextXmlFromTable(TableInfo table, string outputPath)
        {
            if (table == null || !Directory.Exists(outputPath))
            {
                return;
            }

            Log4Helper.Write("GenerateTextXmlFromTable", 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("modeltext");

                #region columns/properties
                foreach (ColumnInfo c in table.Columns)
                {
                    xtw.WriteStartElement("field");
                    xtw.WriteAttributeString("key", entityName + "_" + c.ColumnName);
                    xtw.WriteAttributeString("value", c.ColumnDescription);
                    xtw.WriteEndElement();
                }
                xtw.WriteEndElement();
                #endregion

                xtw.Flush();
                xtw.Close();
            }

            Log4Helper.Write("GenerateTextXmlFromTable", String.Format("Process of table {0} ends at {1}.", table.TableName, System.DateTime.Now.ToString("s")), LogSeverity.Info);
        }
 /// <summary>
 /// This removes namespaces from an XML Element (Scott)
 /// </summary>
 /// <param name="xeElement"></param>
 /// <returns></returns>
 protected string RemoveNamespaces(XmlNode xeElement)
 {
     StringWriter swOutput = new System.IO.StringWriter();
     XmlTextWriter xtwWriter = new XmlTextWriter(swOutput);
     //xtwWriter.WriteStartDocument();
     XmlNodeReader xnrReader = new XmlNodeReader(xeElement);
     while (xnrReader.Read())
     {
         switch (xnrReader.NodeType)
         {
             case XmlNodeType.Element:
                 xtwWriter.WriteStartElement(xnrReader.Name);
                 if (xnrReader.HasAttributes)
                 {
                     while (xnrReader.MoveToNextAttribute())
                     {
                         if (xnrReader.Name != "xmlns")
                         {
                             xtwWriter.WriteAttributeString(xnrReader.Name, xnrReader.Value);
                         }
                     }
                     xnrReader.MoveToElement();
                 }
                 if (xnrReader.IsEmptyElement)
                 {
                     xtwWriter.WriteEndElement();
                 }
                 break;
             case XmlNodeType.Text:
                 xtwWriter.WriteString(xnrReader.Value);
                 break;
             case XmlNodeType.CDATA:
                 xtwWriter.WriteCData(xnrReader.Value);
                 break;
             case XmlNodeType.ProcessingInstruction:
                 xtwWriter.WriteProcessingInstruction(xnrReader.Name, xnrReader.Value);
                 break;
             case XmlNodeType.Comment:
                 xtwWriter.WriteComment(xnrReader.Value);
                 break;
             case XmlNodeType.EntityReference:
                 xtwWriter.WriteEntityRef(xnrReader.Name);
                 break;
             case XmlNodeType.EndElement:
                 xtwWriter.WriteEndElement();
                 break;
         }
     }
     //xtwWriter.WriteEndDocument();
     xtwWriter.Flush();
     xtwWriter.Close();
     xnrReader.Close();
     string sOutput = swOutput.ToString();
     return sOutput;
 }
Example #31
0
		/// <summary>
		/// 写入文件
		/// </summary>
		/// <returns></returns>
		public override string WriteFile()
		{
			
			if (this.SourceDataTable != null)
			{
				
				DateTime filenamedate = DateTime.Now; 
		
				string filename = this.FileOutPath + this.FileName; 
				XmlTextWriter PicXmlWriter = null;
				Encoding encode = Encoding.GetEncoding(this.FileEncode);
				CreatePath();
				PicXmlWriter = new XmlTextWriter (filename,encode);
			
				try
				{
				
					PicXmlWriter.Formatting = Formatting.Indented;
					PicXmlWriter.Indentation = this.Indentation;
					PicXmlWriter.Namespaces = false;
					PicXmlWriter.WriteStartDocument();
					//PicXmlWriter.WriteDocType("文档类型", null, ".xml", null);
					//PicXmlWriter.WriteComment("按在数据库中记录的ID进行记录读写");
					PicXmlWriter.WriteProcessingInstruction("xml-stylesheet","type='text/xsl' href='" + this.XslLink + "'") ;
				
					PicXmlWriter.WriteStartElement(this.SourceDataTable.TableName);
					PicXmlWriter.WriteAttributeString("", "version", null, this.Version);
			
					//写入channel
					foreach(DataRow r in this.SourceDataTable.Rows)   //依次取出所有行
					{
						PicXmlWriter.WriteStartElement("",this.StartElement,"");
						foreach(DataColumn c in this.SourceDataTable.Columns)  //依次找出当前记录的所有列属性
						{
							PicXmlWriter.WriteStartElement("",c.Caption.ToString().Trim().ToLower(),"");
							PicXmlWriter.WriteString(r[c].ToString().Trim());
							PicXmlWriter.WriteEndElement();
						}
						PicXmlWriter.WriteEndElement();
					}

					PicXmlWriter.WriteEndElement();
					PicXmlWriter.Flush();
					this.SourceDataTable.Dispose();
				}
				catch (Exception e)	{	Console.WriteLine ("异常:{0}", e.ToString()); }
				finally
				{
					Console.WriteLine("对文件 {0} 的处理已完成。");
					if (PicXmlWriter != null)
						PicXmlWriter.Close();
					
				}
				return filename;
			}	
			else
			{
				Console.WriteLine("对文件 {0} 的处理未完成。");
				return "";
			}
		}	
Example #32
0
        public static void ExportGUIToFile(GUI gui, string fileName, Game game)
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.Default);
            writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + Encoding.Default.WebName + "\"");
            writer.WriteComment("AGS Exported GUI file. DO NOT EDIT THIS FILE BY HAND, IT IS GENERATED AUTOMATICALLY BY THE AGS EDITOR.");
            writer.WriteStartElement(GUI_XML_ROOT_NODE);
            writer.WriteAttributeString(GUI_XML_VERSION_ATTRIBUTE, GUI_XML_CURRENT_VERSION);

            gui.ToXml(writer);

            writer.WriteStartElement(GUI_XML_SPRITES_NODE);
            ExportAllSpritesOnGUI(gui, writer);
            writer.WriteEndElement();

            game.WritePaletteToXML(writer);

            writer.WriteEndElement();
            writer.Close();
        }
Example #33
0
        public static void ExportCharacterNewFormat(Character character, string fileName, Game game)
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.Default);
            writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + Encoding.Default.WebName + "\"");
            writer.WriteComment("AGS Exported Character file. DO NOT EDIT THIS FILE BY HAND, IT IS GENERATED AUTOMATICALLY BY THE AGS EDITOR.");
            writer.WriteStartElement(CHARACTER_XML_ROOT_NODE);
            writer.WriteAttributeString(CHARACTER_XML_VERSION_ATTRIBUTE, CHARACTER_XML_CURRENT_VERSION);

            character.ToXml(writer);

            writer.WriteStartElement(CHARACTER_XML_VIEWS_NODE);

            Dictionary<int, object> spritesWritten = new Dictionary<int, object>();

            writer.WriteStartElement("NormalView");
            WriteNewStyleView(writer, game.FindViewByID(character.NormalView), spritesWritten);
            writer.WriteEndElement();

            if (character.SpeechView > 0)
            {
                writer.WriteStartElement("SpeechView");
                WriteNewStyleView(writer, game.FindViewByID(character.SpeechView), spritesWritten);
                writer.WriteEndElement();
            }
            if (character.IdleView > 0)
            {
                writer.WriteStartElement("IdleView");
                WriteNewStyleView(writer, game.FindViewByID(character.IdleView), spritesWritten);
                writer.WriteEndElement();
            }
            if (character.ThinkingView > 0)
            {
                writer.WriteStartElement("ThinkingView");
                WriteNewStyleView(writer, game.FindViewByID(character.ThinkingView), spritesWritten);
                writer.WriteEndElement();
            }
            if (character.BlinkingView > 0)
            {
                writer.WriteStartElement("BlinkingView");
                WriteNewStyleView(writer, game.FindViewByID(character.BlinkingView), spritesWritten);
                writer.WriteEndElement();
            }

            writer.WriteEndElement();

            game.WritePaletteToXML(writer);

            writer.WriteEndElement();
            writer.Close();
        }
Example #34
0
        private void SaveUserDataFile()
        {
            StringWriter sw = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(sw);
            writer.Formatting = Formatting.Indented;
            writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + Encoding.Default.WebName + "\"");
            writer.WriteComment("DO NOT EDIT THIS FILE. It is automatically generated by the AGS Editor, changing it manually could break your game");
            writer.WriteStartElement(XML_USER_DATA_ROOT_NODE_NAME);
            writer.WriteAttributeString(XML_ATTRIBUTE_VERSION, LATEST_USER_DATA_VERSION);

            Factory.Events.OnSavingUserData(writer);

            writer.WriteEndElement();
            writer.Flush();

            try
            {
                StreamWriter fileOutput = new StreamWriter(USER_DATA_FILE_NAME, false, Encoding.Default);
                fileOutput.Write(sw.ToString());
                fileOutput.Close();
                writer.Close();
            }
            catch (UnauthorizedAccessException ex)
            {
                Factory.GUIController.ShowMessage("Unable to write the user data file. Ensure that you have write access to the game folder, and that the file is not already open.\n\n" + ex.Message, MessageBoxIcon.Warning);
            }
            catch (IOException ex)
            {
                Factory.GUIController.ShowMessage("Unable to write the user data file. Ensure that you have write access to the game folder, and that the file is not already open.\n\n" + ex.Message, MessageBoxIcon.Warning);
            }
        }
Example #35
0
        private object SaveGameFilesProcess(object parameter)
        {
            WriteConfigFile();

            SaveUserDataFile();

            StringWriter sw = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(sw);
            writer.Formatting = Formatting.Indented;
            writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + Encoding.Default.WebName + "\"");
            writer.WriteComment("DO NOT EDIT THIS FILE. It is automatically generated by the AGS Editor, changing it manually could break your game");
            writer.WriteStartElement(XML_ROOT_NODE_NAME);
            writer.WriteAttributeString(XML_ATTRIBUTE_VERSION, LATEST_XML_VERSION);
            writer.WriteAttributeString(XML_ATTRIBUTE_VERSION_INDEX, LATEST_XML_VERSION_INDEX.ToString());
            writer.WriteAttributeString(XML_ATTRIBUTE_EDITOR_VERSION, AGS.Types.Version.AGS_EDITOR_FRIENDLY_VERSION);

            _game.SavedXmlVersion = LATEST_XML_VERSION;
            _game.SavedXmlVersionIndex = LATEST_XML_VERSION_INDEX;
            _game.ToXml(writer);

            Factory.Events.OnSavingGame(writer);

            writer.WriteEndElement();
            writer.Flush();

            BackupCurrentGameFile();

            string gameXml = sw.ToString();
            writer.Close();

            if (WriteMainGameFile(gameXml))
            {
                Factory.NativeProxy.SaveGame(_game);
            }
            else
            {
                return false;
            }

            DeleteObsoleteFilesFrom272();
            _game.FilesAddedOrRemoved = false;

            return true;
        }
        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);
        }