예제 #1
0
        private void saveConfigurationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var xml = Brain.KB.ToXML();
            var doc = new System.Xml.XmlDocument();

            doc.LoadXml(xml);
            var sw  = new System.IO.StringWriter();
            var xtw = new System.Xml.XmlTextWriter(sw);

            xtw.Formatting = System.Xml.Formatting.Indented;
            doc.WriteTo(xtw);

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "KickBrain File|*.kickb";
            saveFileDialog1.Title            = "Save Configuration";
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.ShowDialog();

            if (saveFileDialog1.FileName == "")
            {
                return;
            }

            System.IO.File.WriteAllText(saveFileDialog1.FileName, sw.ToString());
        }
예제 #2
0
        public static void ModifyProjectFile(string filename)
        {
            if (!filename.ToLower().EndsWith("proj"))
            {
                throw new System.ArgumentException("Internal Error: ModifyProjectFile called with a file that is not a project");
            }

            Console.WriteLine("Modifying Project : {0}", filename);

            // Load the Project file
            var doc = System.Xml.Linq.XDocument.Load(filename);

            // Modify the Source Control Elements
            RemoveSCCElementsAttributes(doc.Root);

            // Remove the read-only flag
            var original_attr = System.IO.File.GetAttributes(filename);
            System.IO.File.SetAttributes(filename, System.IO.FileAttributes.Normal);

            // Write out the XML
            using (var writer = new System.Xml.XmlTextWriter(filename, Encoding.UTF8))
            {
                writer.Formatting = System.Xml.Formatting.Indented;
                doc.Save(writer);
                writer.Close();
            }

            // Restore the original file attributes
            System.IO.File.SetAttributes(filename, original_attr);
        }
예제 #3
0
        private string SerializeAllValuesToString()
        {
            if (_storageFormat == StorageFormat.JSON)
            {
                string json = Procurios.Public.JSON.JsonEncode(_values);
                return(json);
            }
            else if (_storageFormat == StorageFormat.XML)
            {
                var serializer = new System.Runtime.Serialization.DataContractSerializer(_values.GetType());

                using (var sw = new System.IO.StringWriter())
                {
                    using (var writer = new System.Xml.XmlTextWriter(sw))
                    {
                        writer.Formatting = System.Xml.Formatting.Indented; // to make it easier to read
                        serializer.WriteObject(writer, _values);
                        writer.Flush();
                        return(sw.ToString());
                    }
                }
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
    private void EditorExportParameters()
    {
        var folder = UnityEditor.EditorPrefs.GetString("Time of Day Folder", Application.dataPath);
        var file   = UnityEditor.EditorPrefs.GetString("Time of Day File", "Time of Day.xml");
        var path   = UnityEditor.EditorUtility.SaveFilePanel("Export", folder, file, "xml");

        if (string.IsNullOrEmpty(path))
        {
            return;
        }

        var serializer = new System.Xml.Serialization.XmlSerializer(typeof(TOD_Parameters));

        using (var filestream = new System.IO.FileStream(path, System.IO.FileMode.Create))
        {
            var parameters = new TOD_Parameters(this);
            var writer     = new System.Xml.XmlTextWriter(filestream, System.Text.Encoding.UTF8);
            writer.Formatting = System.Xml.Formatting.Indented;
            serializer.Serialize(writer, parameters);
            UnityEditor.AssetDatabase.Refresh();
        }

        UnityEditor.EditorPrefs.SetString("Time of Day Folder", System.IO.Path.GetDirectoryName(path));
        UnityEditor.EditorPrefs.SetString("Time of Day File", System.IO.Path.GetFileName(path));
    }
예제 #5
0
        /// <summary>
        /// Generates the content of the notification.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public static string GenerateNotificationContent(string template, Dictionary<string, object> data)
        {
            using(var writer = new System.IO.StringWriter())
            {
                using (System.Xml.XmlWriter xml = new System.Xml.XmlTextWriter(writer))
                {
                    xml.WriteStartElement("root");

                    foreach (DictionaryEntry de in HostSettingManager.GetHostSettings())
                        xml.WriteElementString(string.Concat("HostSetting_", de.Key), de.Value.ToString());

                    foreach (var item in data.Keys)
                    {
                        if (item.StartsWith("RawXml"))
                        {
                            xml.WriteRaw(data[item].ToString());
                        }
                        else if (item.GetType().IsClass)
                        {
                            xml.WriteRaw(data[item].ToXml());
                        }
                        else
                        {
                            xml.WriteElementString(item, data[item].ToString());
                        }
                    }

                    xml.WriteEndElement();

                    return XmlXslTransform.Transform(writer.ToString(), template);
                }
            }
        }
 public static void GenerateCustomXmlPart1Content(CustomXmlPart customXmlPart1)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart1.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?><p:properties xmlns:p=\"http://schemas.microsoft.com/office/2006/metadata/properties\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\"><documentManagement/></p:properties>");
     writer.Flush();
     writer.Close();
 }
예제 #7
0
        static void Main(string[] args)
        {
            var items  = typeof(string).Assembly.GetTypes().Take(100);
            var items2 = items.Select(i => new { i.Name, i.IsClass, i.IsEnum, i.IsValueType });


            var datatable = Isotope.Data.DataUtil.DataTableFromEnumerable(items2);

            string out_filename = "out.xaml";
            var    encoding     = System.Text.Encoding.UTF8;

            var x = new System.Xml.XmlTextWriter(out_filename, encoding);

            var repdef = new Isotope.Reporting.ReportDefinition();


            repdef.ReportHeaderDefinition.ReportTitle.TextStyle.FontSize   = 18.0;
            repdef.ReportHeaderDefinition.ReportTitle.TextStyle.FontWeight = Isotope.Reporting.FontWeight.Bold;
            repdef.ReportHeaderDefinition.HeaderText.TextStyle.FontSize    = 8.0;

            var colstyle1 = new Isotope.Reporting.TableColumnStyle();

            colstyle1.DetailTextStyle.FontWeight = Isotope.Reporting.FontWeight.Bold;
            colstyle1.HorzontalAlignment         = Isotope.Reporting.HorzontalAlignment.Right;
            colstyle1.Width = 150;

            repdef.Table.ColumnStyles.Add(colstyle1);

            repdef.Table.TableStyle.CellSpacing = 10;
            repdef.WriteXML(x, datatable);
            x.Close();
        }
예제 #8
0
        } // Serialize

        public void SerializeToXML(ref string strFileNameAndPath)
        {
            Serialize();
            cDictionary ThisFacility = SerializationHelper;

            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(cDictionary));

            System.Xml.XmlTextWriter xtwXMLtextWriter = null;
            try
            {
                //xtwXMLtextWriter = New System.Xml.XmlTextWriter(strFileNameAndPath, System.Text.Encoding.UTF8)
                //xtwXMLtextWriter = New XmlTextWriterIndentedStandaloneNo("C:\Users\stefan.steiger\Desktop\furniture.xml", System.Text.Encoding.UTF8)

                //xtwXMLtextWriter.Formatting = System.Xml.Formatting.Indented

                System.Xml.Serialization.XmlSerializerNamespaces ns = new System.Xml.Serialization.XmlSerializerNamespaces();
                ns.Add("", "");

                serializer.Serialize(System.Web.HttpContext.Current.Response.OutputStream, ThisFacility, ns);
                //serializer.Serialize(xtwXMLtextWriter, MyAppConfig)

                //xtwXMLtextWriter.Flush()
                //xtwXMLtextWriter.Close() 'Write the XML to file and close the writer
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine("Encountered Exception in COR.XMLserialization.SerializeToXML()\r\nDetails:\r\n " + ex.Message);
            }


            //Dim swEncodingWriter As System.IO.StreamWriter = New System.IO.StreamWriter("C:\Users\stefan.steiger\Desktop\furniture.xml", False, System.Text.Encoding.UTF8)
            //serializer.Serialize(swEncodingWriter, MyAppConfig)
            //swEncodingWriter.Close()
            //swEncodingWriter.Dispose()
        } // SerializeToXML
예제 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();

                writer.WriteStartElement("Project");
                writer.WriteStartElement("Items");

                Dictionary <int, sProject> projectList;
                DB.LoadProject(out projectList);

                foreach (KeyValuePair <int, sProject> item in projectList)
                {
                    writer.WriteStartElement("Item");
                    writer.WriteAttributeString("uid", item.Key.ToString());
                    writer.WriteAttributeString("name", item.Value.name);
                    writer.WriteEndElement();
                }

                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int project_uid;
            short fromDate = 0;
            short toDate = 0;

            if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
                project_uid = 1;

            if (short.TryParse(Request.QueryString["from"], out fromDate) == false)
                fromDate = 0;

            if (short.TryParse(Request.QueryString["to"], out toDate) == false)
                toDate = 0;

            if (toDate > fromDate)
                return;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Counts");

                Dictionary<string, int> dailyCountList = new Dictionary<string, int>();

                for (int i = toDate; i < fromDate; i++)
                {
                    TimeSpan oneDay = new TimeSpan(i, 0, 0, 0);
                    DateTime saveDate = DateTime.Now.Subtract(oneDay);

                    string date = string.Format("{0:0000}-{1:00}-{2:00}", saveDate.Year, saveDate.Month, saveDate.Day);

                    dailyCountList[date] = 0;
                }

                DB.LoadDailyCount(project_uid, fromDate, toDate,
                    delegate(string date, int count)
                    {
                        dailyCountList[date] = count;
                    }
                );

                foreach (KeyValuePair<string,int> v in dailyCountList)
                {
                    writer.WriteStartElement("Count");
                    writer.WriteAttributeString("date", v.Key);
                    writer.WriteAttributeString("count", v.Value.ToString());
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
 public static void GenerateCustomXmlPart2Content(CustomXmlPart customXmlPart2)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart2.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?><ct:contentTypeSchema ct:_=\"\" ma:_=\"\" ma:contentTypeName=\"Document\" ma:contentTypeID=\"0x0101004B3CC135CC07AD41A19C6A3D7A557156\" ma:contentTypeVersion=\"\" ma:contentTypeDescription=\"Create a new document.\" ma:contentTypeScope=\"\" ma:versionID=\"ed709af8e00f2f37000702baf4108691\" xmlns:ct=\"http://schemas.microsoft.com/office/2006/metadata/contentType\" xmlns:ma=\"http://schemas.microsoft.com/office/2006/metadata/properties/metaAttributes\">\r\n<xsd:schema targetNamespace=\"http://schemas.microsoft.com/office/2006/metadata/properties\" ma:root=\"true\" ma:fieldsID=\"6d238f72868eae9cb05cfc0c92331025\" ns2:_=\"\" ns3:_=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:p=\"http://schemas.microsoft.com/office/2006/metadata/properties\" xmlns:ns2=\"4fc81810-4f98-4e7e-b20e-7b2a690091c4\" xmlns:ns3=\"067d236f-0129-4702-b692-531fc2f871d2\">\r\n<xsd:import namespace=\"4fc81810-4f98-4e7e-b20e-7b2a690091c4\"/>\r\n<xsd:import namespace=\"067d236f-0129-4702-b692-531fc2f871d2\"/>\r\n<xsd:element name=\"properties\">\r\n<xsd:complexType>\r\n<xsd:sequence>\r\n<xsd:element name=\"documentManagement\">\r\n<xsd:complexType>\r\n<xsd:all>\r\n<xsd:element ref=\"ns2:MediaServiceMetadata\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceFastMetadata\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceDateTaken\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceAutoTags\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceOCR\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceLocation\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns3:SharedWithUsers\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns3:SharedWithDetails\" minOccurs=\"0\"/>\r\n</xsd:all>\r\n</xsd:complexType>\r\n</xsd:element>\r\n</xsd:sequence>\r\n</xsd:complexType>\r\n</xsd:element>\r\n</xsd:schema>\r\n<xsd:schema targetNamespace=\"4fc81810-4f98-4e7e-b20e-7b2a690091c4\" elementFormDefault=\"qualified\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:dms=\"http://schemas.microsoft.com/office/2006/documentManagement/types\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\">\r\n<xsd:import namespace=\"http://schemas.microsoft.com/office/2006/documentManagement/types\"/>\r\n<xsd:import namespace=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\"/>\r\n<xsd:element name=\"MediaServiceMetadata\" ma:index=\"8\" nillable=\"true\" ma:displayName=\"MediaServiceMetadata\" ma:hidden=\"true\" ma:internalName=\"MediaServiceMetadata\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Note\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceFastMetadata\" ma:index=\"9\" nillable=\"true\" ma:displayName=\"MediaServiceFastMetadata\" ma:hidden=\"true\" ma:internalName=\"MediaServiceFastMetadata\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Note\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceDateTaken\" ma:index=\"10\" nillable=\"true\" ma:displayName=\"MediaServiceDateTaken\" ma:hidden=\"true\" ma:internalName=\"MediaServiceDateTaken\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Text\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceAutoTags\" ma:index=\"11\" nillable=\"true\" ma:displayName=\"Tags\" ma:internalName=\"MediaServiceAutoTags\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Text\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceOCR\" ma:index=\"12\" nillable=\"true\" ma:displayName=\"Extracted Text\" ma:internalName=\"MediaServiceOCR\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Note\">\r\n<xsd:maxLength value=\"255\"/>\r\n</xsd:restriction>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceLocation\" ma:index=\"13\" nillable=\"true\" ma:displayName=\"Location\" ma:internalName=\"MediaServiceLocation\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Text\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n</xsd:schema>\r\n<xsd:schema targetNamespace=\"067d236f-0129-4702-b692-531fc2f871d2\" elementFormDefault=\"qualified\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:dms=\"http://schemas.microsoft.com/office/2006/documentManagement/types\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\">\r\n<xsd:import namespace=\"http://schemas.microsoft.com/office/2006/documentManagement/types\"/>\r\n<xsd:import namespace=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\"/>\r\n<xsd:element name=\"SharedWithUsers\" ma:index=\"14\" nillable=\"true\" ma:displayName=\"Shared With\" ma:internalName=\"SharedWithUsers\" ma:readOnly=\"true\">\r\n<xsd:complexType>\r\n<xsd:complexContent>\r\n<xsd:extension base=\"dms:UserMulti\">\r\n<xsd:sequence>\r\n<xsd:element name=\"UserInfo\" minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n<xsd:complexType>\r\n<xsd:sequence>\r\n<xsd:element name=\"DisplayName\" type=\"xsd:string\" minOccurs=\"0\"/>\r\n<xsd:element name=\"AccountId\" type=\"dms:UserId\" minOccurs=\"0\" nillable=\"true\"/>\r\n<xsd:element name=\"AccountType\" type=\"xsd:string\" minOccurs=\"0\"/>\r\n</xsd:sequence>\r\n</xsd:complexType>\r\n</xsd:element>\r\n</xsd:sequence>\r\n</xsd:extension>\r\n</xsd:complexContent>\r\n</xsd:complexType>\r\n</xsd:element>\r\n<xsd:element name=\"SharedWithDetails\" ma:index=\"15\" nillable=\"true\" ma:displayName=\"Shared With Details\" ma:internalName=\"SharedWithDetails\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Note\">\r\n<xsd:maxLength value=\"255\"/>\r\n</xsd:restriction>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n</xsd:schema>\r\n<xsd:schema targetNamespace=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" blockDefault=\"#all\" xmlns=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:odoc=\"http://schemas.microsoft.com/internal/obd\">\r\n<xsd:import namespace=\"http://purl.org/dc/elements/1.1/\" schemaLocation=\"http://dublincore.org/schemas/xmls/qdc/2003/04/02/dc.xsd\"/>\r\n<xsd:import namespace=\"http://purl.org/dc/terms/\" schemaLocation=\"http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd\"/>\r\n<xsd:element name=\"coreProperties\" type=\"CT_coreProperties\"/>\r\n<xsd:complexType name=\"CT_coreProperties\">\r\n<xsd:all>\r\n<xsd:element ref=\"dc:creator\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element ref=\"dcterms:created\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element ref=\"dc:identifier\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element name=\"contentType\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\" ma:index=\"0\" ma:displayName=\"Content Type\"/>\r\n<xsd:element ref=\"dc:title\" minOccurs=\"0\" maxOccurs=\"1\" ma:index=\"4\" ma:displayName=\"Title\"/>\r\n<xsd:element ref=\"dc:subject\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element ref=\"dc:description\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element name=\"keywords\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n<xsd:element ref=\"dc:language\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element name=\"category\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n<xsd:element name=\"version\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n<xsd:element name=\"revision\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\">\r\n<xsd:annotation>\r\n<xsd:documentation>\r\n                        This value indicates the number of saves or revisions. The application is responsible for updating this value after each revision.\r\n                    </xsd:documentation>\r\n</xsd:annotation>\r\n</xsd:element>\r\n<xsd:element name=\"lastModifiedBy\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n<xsd:element ref=\"dcterms:modified\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element name=\"contentStatus\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n</xsd:all>\r\n</xsd:complexType>\r\n</xsd:schema>\r\n<xs:schema targetNamespace=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\r\n<xs:element name=\"Person\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:DisplayName\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:AccountId\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:AccountType\" minOccurs=\"0\"></xs:element>\r\n</xs:sequence>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:element name=\"DisplayName\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"AccountId\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"AccountType\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"BDCAssociatedEntity\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:BDCEntity\" minOccurs=\"0\" maxOccurs=\"unbounded\"></xs:element>\r\n</xs:sequence>\r\n<xs:attribute ref=\"pc:EntityNamespace\"></xs:attribute>\r\n<xs:attribute ref=\"pc:EntityName\"></xs:attribute>\r\n<xs:attribute ref=\"pc:SystemInstanceName\"></xs:attribute>\r\n<xs:attribute ref=\"pc:AssociationName\"></xs:attribute>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:attribute name=\"EntityNamespace\" type=\"xs:string\"></xs:attribute>\r\n<xs:attribute name=\"EntityName\" type=\"xs:string\"></xs:attribute>\r\n<xs:attribute name=\"SystemInstanceName\" type=\"xs:string\"></xs:attribute>\r\n<xs:attribute name=\"AssociationName\" type=\"xs:string\"></xs:attribute>\r\n<xs:element name=\"BDCEntity\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:EntityDisplayName\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityInstanceReference\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId1\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId2\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId3\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId4\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId5\" minOccurs=\"0\"></xs:element>\r\n</xs:sequence>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:element name=\"EntityDisplayName\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityInstanceReference\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId1\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId2\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId3\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId4\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId5\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"Terms\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:TermInfo\" minOccurs=\"0\" maxOccurs=\"unbounded\"></xs:element>\r\n</xs:sequence>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:element name=\"TermInfo\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:TermName\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:TermId\" minOccurs=\"0\"></xs:element>\r\n</xs:sequence>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:element name=\"TermName\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"TermId\" type=\"xs:string\"></xs:element>\r\n</xs:schema>\r\n</ct:contentTypeSchema>");
     writer.Flush();
     writer.Close();
 }
예제 #12
0
        public static void Export(string filename, Topic t, bool configOnly)
        {
            if (filename == null || t == null)
            {
                throw new ArgumentNullException();
            }
            XDocument doc = new XDocument(new XElement("xst", new XAttribute("path", t.path)));

            doc.Declaration = new XDeclaration("1.0", "utf-8", "yes");
            var s = t.GetState();

            if (s.Exists && (t.CheckAttribute(Topic.Attribute.Saved, Topic.Attribute.Config) || (!configOnly && t.CheckAttribute(Topic.Attribute.Saved, Topic.Attribute.DB))))
            {
                doc.Root.Add(new XAttribute("s", JsLib.Stringify(s)));
            }
            var m = t.GetField(null);

            doc.Root.Add(new XAttribute("m", JsLib.Stringify(m)));
            foreach (Topic c in t.children)
            {
                Export(doc.Root, c, configOnly);
            }
            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(filename, Encoding.UTF8)) {
                writer.Formatting = System.Xml.Formatting.Indented;
                writer.QuoteChar  = '\'';
                doc.WriteTo(writer);
                writer.Flush();
            }
        }
예제 #13
0
        private void RefreshOracle(String uid, String pwd)
        {
            String ConnectionString = //"Data Source="+ url.Text+";user Id="+uid+";Password="******"Data Source = (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST =" + url.Text + ")(PORT = "+port.Text+")))(CONNECT_DATA =(SERVICE_NAME = "+comboBox1.Text+" )));User ID = "+uid+" ;Password=  "******"Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = " + url.Text + ")(PORT = " + port.Text + "))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = " + comboBox1.Text + ")));User ID = " + uid + " ;Password=  "******"SELECT TABLE_NAME FROM USER_TABLES";


                System.IO.StringWriter   sw = new System.IO.StringWriter();
                System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(sw);
                //当前数据库所有的用户表
                DataTable dt = OracleHelper.GetDataTable(sql);
                dt.WriteXml(xw);
                string s = sw.ToString();
                conn_info.Text = "连接成功……\n所有的用户表展示如下:\n" + s;
            }
            catch (System.Exception ex)
            {
                conn_info.Text = "连接失败……";
                Console.WriteLine(ex.ToString());
            }
        }
예제 #14
0
        private void ExploreTests()
        {
            XmlNode testNode = runner.LoadedTest.ToXml(true);

            string     listFile   = commandLineOptions.ExploreFile;
            TextWriter textWriter = listFile != null && listFile.Length > 0
                                ? new StreamWriter(listFile)
                                        : Console.Out;

                        #if CLR_2_0 || CLR_4_0
            System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();
            settings.Indent   = true;
            settings.Encoding = System.Text.Encoding.UTF8;
            System.Xml.XmlWriter testWriter = System.Xml.XmlWriter.Create(textWriter, settings);
                        #else
            System.Xml.XmlTextWriter testWriter = new System.Xml.XmlTextWriter(textWriter);
            testWriter.Formatting = System.Xml.Formatting.Indented;
                        #endif

            testNode.WriteTo(testWriter);
            testWriter.Close();

            Console.WriteLine();
            Console.WriteLine("Test info saved as {0}.", listFile);
        }
예제 #15
0
파일: Program.cs 프로젝트: saveenr/saveenr
        static void Main(string[] args)
        {


            var items = typeof(string).Assembly.GetTypes().Take(100);
            var items2 = items.Select(i => new { i.Name, i.IsClass, i.IsEnum, i.IsValueType });


            var datatable = Isotope.Data.DataUtil.DataTableFromEnumerable(items2);

            string out_filename = "out.xaml";
            var encoding = System.Text.Encoding.UTF8;

            var x = new System.Xml.XmlTextWriter(out_filename, encoding);

            var repdef = new Isotope.Reporting.ReportDefinition();


            repdef.ReportHeaderDefinition.ReportTitle.TextStyle.FontSize = 18.0;
            repdef.ReportHeaderDefinition.ReportTitle.TextStyle.FontWeight = Isotope.Reporting.FontWeight.Bold;
            repdef.ReportHeaderDefinition.HeaderText.TextStyle.FontSize = 8.0;

            var colstyle1 = new Isotope.Reporting.TableColumnStyle();
            colstyle1.DetailTextStyle.FontWeight = Isotope.Reporting.FontWeight.Bold;
            colstyle1.HorzontalAlignment = Isotope.Reporting.HorzontalAlignment.Right;
            colstyle1.Width = 150;

            repdef.Table.ColumnStyles.Add(colstyle1);

            repdef.Table.TableStyle.CellSpacing = 10;
            repdef.WriteXML(x,datatable);
            x.Close();

        }
예제 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int report_uid;
            int new_state;

            if (int.TryParse(Request.QueryString["report_uid"], out report_uid) == false)
            {
                return;
            }

            if (int.TryParse(Request.QueryString["state"], out new_state) == false)
                new_state = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Outputs");

                DB.UpdateReportState(report_uid, new_state);

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
예제 #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int report_uid;
            int new_state;

            if (int.TryParse(Request.QueryString["report_uid"], out report_uid) == false)
            {
                return;
            }

            if (int.TryParse(Request.QueryString["state"], out new_state) == false)
            {
                new_state = 1;
            }

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Outputs");

                DB.UpdateReportState(report_uid, new_state);

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
예제 #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();

                writer.WriteStartElement("Project");
                writer.WriteStartElement("Items");

                Dictionary<int, sProject> projectList;
                DB.LoadProject(out projectList);

                foreach (KeyValuePair<int, sProject> item in projectList)
                {
                    writer.WriteStartElement("Item");
                    writer.WriteAttributeString("uid", item.Key.ToString());
                    writer.WriteAttributeString("name", item.Value.name);
                    writer.WriteEndElement();
                }

                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
예제 #19
0
        public static string FiltersToString(SAAdminTool.DocsPaWR.FiltroRicerca[][] filtriRicerca)
        {
            try
            {
                //Serializzazione del filtro di ricerca
                System.Xml.Serialization.XmlSerializer _serializer = new System.Xml.Serialization.XmlSerializer(filtriRicerca.GetType());
                System.IO.MemoryStream   _mStream = new System.IO.MemoryStream();
                System.Xml.XmlTextWriter _writer  = new System.Xml.XmlTextWriter(_mStream, System.Text.Encoding.ASCII);
                _serializer.Serialize(_writer, filtriRicerca);

                //A questo punto il mio oggetto serializzato è nello stream
                //estraiamo il buffer dello stream e lo convertiamo in stringa
                string outcome = System.Text.Encoding.ASCII.GetString(_mStream.GetBuffer());

                //Ripuliamo l'oggetto serializzato
                int tmp = outcome.IndexOf("\0");
                outcome = outcome.Remove(tmp, outcome.Length - tmp);

                return(outcome);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Fallita serializzazione dei criteri di ricerca");
            }
            return(null);
        }
예제 #20
0
        /// <summary>
        /// Construct an StreamContent from a provided populated OFX object
        /// </summary>
        /// <param name="ofxObject">A populated OFX message with request or response data</param>
        /// <returns>Created StreamContent ready to send with HttpClient.Post</returns>
        public static StreamContent Create(Protocol.OFX ofxObject)
        {
            // Serialized data will be written to a MemoryStream
            var memoryStream = new System.IO.MemoryStream();

            // XMLWriter will be used to encode the data using UTF8Encoding without a Byte Order Marker (BOM)
            var xmlWriter = new System.Xml.XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false));

            // Write xml processing instruction
            xmlWriter.WriteStartDocument();
            // Our OFX protocol uses a version 2.0.0 header with 2.1.1 protocol body
            xmlWriter.WriteProcessingInstruction("OFX", "OFXHEADER=\"200\" VERSION=\"211\" SECURITY=\"NONE\" OLDFILEUID=\"NONE\" NEWFILEUID=\"NONE\"");

            // Don't include namespaces in the root element
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            ns.Add("", "");

            // Generate XML to the stream
            m_serializer.Serialize(xmlWriter, ofxObject, ns);

            // Flush writer to stream
            xmlWriter.Flush();

            // Position the stream back to the start for reading
            memoryStream.Position = 0;

            // Wrap in our HttpContent-derived class to provide headers and other HTTP encoding information
            return new StreamContent(memoryStream);
        }
예제 #21
0
        public void Load(DCompilerConfiguration compiler)
        {
            configuration = compiler;

            if (compiler == null)
            {
                txtBinPath.Text                         =
                    txtCompiler.Text                    =
                        txtConsoleAppLinker.Text        =
                            txtSharedLibLinker.Text     =
                                txtStaticLibLinker.Text = null;

                text_DefaultLibraries.Buffer.Clear();
                text_Includes.Buffer.Clear();

                releaseArgumentsDialog.Load(null, false);
                debugArgumentsDialog.Load(null, true);

                btnMakeDefault.Sensitive = false;
                return;
            }
            //for now, using Executable target compiler command for all targets source compiling
            LinkTargetConfiguration targetConfig;

            targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.Executable);

            txtBinPath.Text  = compiler.BinPath;
            txtCompiler.Text = compiler.SourceCompilerCommand;
            check_enableLibPrefixing.Active = compiler.EnableGDCLibPrefixing;

            //linker targets
            targetConfig             = compiler.GetOrCreateTargetConfiguration(DCompileTarget.Executable);
            txtConsoleAppLinker.Text = targetConfig.Linker;

            targetConfig            = compiler.GetOrCreateTargetConfiguration(DCompileTarget.SharedLibrary);
            txtSharedLibLinker.Text = targetConfig.Linker;

            targetConfig            = compiler.GetOrCreateTargetConfiguration(DCompileTarget.StaticLibrary);
            txtStaticLibLinker.Text = targetConfig.Linker;

            releaseArgumentsDialog.Load(compiler, false);
            debugArgumentsDialog.Load(compiler, true);

            text_DefaultLibraries.Buffer.Text = string.Join(Environment.NewLine, compiler.DefaultLibraries);
            text_Includes.Buffer.Text         = string.Join(Environment.NewLine, compiler.IncludePaths);

            btnMakeDefault.Active =
                configuration.Vendor == defaultCompilerVendor;
            btnMakeDefault.Sensitive = true;

            using (var buf = new StringWriter())
                using (var xml = new System.Xml.XmlTextWriter(buf)) {
                    xml.Formatting = System.Xml.Formatting.Indented;
                    xml.WriteStartDocument();
                    xml.WriteStartElement("patterns");
                    compiler.ArgumentPatterns.SaveTo(xml);
                    xml.WriteEndDocument();
                    tb_ArgPatterns.Buffer.Text = buf.ToString();
                }
        }
예제 #22
0
        /// <summary>
        /// Método para criação do Arquivo XML com Configurações do usuário.
        /// </summary>
        public static void CriarArquivoXML()
        {
            try
            {
                System.Xml.XmlTextWriter xtrPrefs = new System.Xml.XmlTextWriter(Directories.UserPrefsDirectory + 
                    @"\UserPrefs.config", System.Text.Encoding.UTF8);

                // Inicia o documento XML.
                xtrPrefs.WriteStartDocument();

                // Escreve elemento raiz.
                xtrPrefs.WriteStartElement("Directories");
                // Escreve sub-Elementos.
                xtrPrefs.WriteElementString("Starbound", Directories.StarboundDirectory);
                xtrPrefs.WriteElementString("Mods", Directories.ModsDirectory);
                // Encerra o elemento raiz.
                xtrPrefs.WriteEndElement();
                // Escreve o XML para o arquivo e fecha o objeto escritor.
                xtrPrefs.Close();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);

            }
        }
예제 #23
0
/* -*- Mode: csharp; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */

//namespace {
        public void ToXml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement("match");

            if (this.ChannelId != null)
            {
                writer.WriteElementString("channel", this.ChannelId);
            }

            if (this.Dep != null)
            {
                this.Dep.ToXml(writer);
            }

            if (this.Glob != null)
            {
                writer.WriteElementString("glob", this.Glob);
            }

            bool gteq;
            PackageImportance imp = this.GetImportance(out gteq);

            if (imp != PackageImportance.Invalid)
            {
                writer.WriteStartElement("importance");
                writer.WriteAttributeString("gteq", gteq ? "1" : "0");
                writer.WriteString(Global.ImportanceToString(imp));
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
예제 #24
0
        private void SendCommand(string command, Dictionary <string, string> cmdParameters)
        {
            StringBuilder sb = new System.Text.StringBuilder();

            using (System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(new System.IO.StringWriter(sb, CultureInfo.InvariantCulture)))
            {
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("ndd");

                AddCommand(command, xmlWriter, cmdParameters);

                xmlWriter.WriteStartElement("Patients");
                AddGuiPatient(xmlWriter);
                xmlWriter.WriteEndElement();//Patients
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndDocument();

                xmlWriter.Flush();
                xmlWriter.Close();
            }
            _emrPlugIn.SendMessage(sb.ToString());

            // ndd internal code
            if (textBoxPatientID.Text.StartsWith("Exception", StringComparison.CurrentCultureIgnoreCase))
            {
                throw new Exception("This Exception is for testing purpose");
            }
        }
예제 #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int callstack_uid;

            if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
            {
                callstack_uid = 1;
            }

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Callstack");

                string callstack;
                if (DB.LoadCallstackPreview(callstack_uid, out callstack))
                {
                    writer.WriteCData(callstack);
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
예제 #26
0
 protected static void WriteParameter(System.Xml.XmlTextWriter xmlWriter, string strFeature, string strValue)
 {
     xmlWriter.WriteStartElement("Parameter");
     xmlWriter.WriteAttributeString("Name", strFeature);
     xmlWriter.WriteValue(strValue);
     xmlWriter.WriteEndElement();//parameter
 }
예제 #27
0
        public AnimationTarget Clone(Overlay newTarget)
        {
            StringBuilder sb = new StringBuilder();

            using (System.IO.StringWriter textWriter = new System.IO.StringWriter(sb))
            {
                using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(textWriter))
                {
                    writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");

                    this.SaveToXml(writer);
                }
            }

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(sb.ToString());

            AnimationTarget at = new AnimationTarget(owner);

            System.Xml.XmlNode node = doc["KeyFrames"];
            at.FromXml(node);
            at.Target   = newTarget;
            at.TargetID = newTarget.GetIndentifier();
            return(at);
        }
        public CFDIXmlTextWriter(Comprobante comprobante, string fileName, Encoding encoding) {
            this.comprobante = comprobante;
            this.fileName = fileName;
            this.encoding = encoding;

            this.writer = new System.Xml.XmlTextWriter(fileName, System.Text.Encoding.UTF8);
        }
예제 #29
0
        /// <summary>Serialize an object to an XML-string.</summary>
        /// <param name="obj">Object to serialize.</param>
        /// <returns>Object as XML-stringValid path</returns>
        public static string SerializeToString <T>(T obj)
        {
            if (obj == null)
            {
                throw new System.ArgumentNullException("obj");
            }

            try {
                System.IO.MemoryStream ms = new System.IO.MemoryStream();

                //Type yourType = Type.GetType("Statistic");
                //XmlSerializer xs = new XmlSerializer(yourType);
                //XmlSerializer xs = new XmlSerializer(typeof(T));

                System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(obj.GetType());
                System.Xml.XmlTextWriter xmlTextWriter    = new System.Xml.XmlTextWriter(ms, System.Text.Encoding.UTF8);
                xs.Serialize(xmlTextWriter, obj);

                ms = (System.IO.MemoryStream)xmlTextWriter.BaseStream;
                return(System.Text.Encoding.UTF8.GetString(ms.ToArray()));
            }
            catch (System.Exception ex)
            {
                Debug.LogError("Could not serialize the object to a string: " + ex);
            }

            return(string.Empty);
        }
        public CFDIXmlTextWriter(Comprobante comprobante, System.IO.Stream stream, Encoding encoding) {
            this.comprobante = comprobante;
            this.fileName = null;
            this.encoding = encoding;

            this.writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
        }
 public static void GenerateCustomXmlPart3Content(CustomXmlPart customXmlPart3)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart3.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?mso-contentType?><FormTemplates xmlns=\"http://schemas.microsoft.com/sharepoint/v3/contenttype/forms\"><Display>DocumentLibraryForm</Display><Edit>DocumentLibraryForm</Edit><New>DocumentLibraryForm</New></FormTemplates>");
     writer.Flush();
     writer.Close();
 }
예제 #32
0
 protected virtual void WriteConfiguration(System.Xml.XmlTextWriter xmlWriter)
 {
     WriteParameter(xmlWriter, Commands.Configuration.CloseAfterTest, _CloseAfterTest.ToString(CultureInfo.InvariantCulture));
     WriteParameter(xmlWriter, Commands.Configuration.IncludeCurveData, _IncludeCurveData.ToString(CultureInfo.InvariantCulture));
     WriteParameter(xmlWriter, Commands.Configuration.IncludeTrialValues, _IncludeTrialValues.ToString(CultureInfo.InvariantCulture));
     WriteParameter(xmlWriter, Commands.Configuration.FileExchangeFolder, m_FileExchangeFolder.ToString(CultureInfo.InvariantCulture));
 }
예제 #33
0
        private void saveButton_Click(object sender, System.EventArgs e)
        {
            if (System.IO.File.Exists(jmjcmptst))
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(jmjcmptst);
                saveFileDialog1.InitialDirectory = sr.ReadToEnd();
                sr.Close();
            }

            if (saveFileDialog1.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            System.IO.File.Delete(jmjcmptst);
            System.IO.StreamWriter sw = new System.IO.StreamWriter(jmjcmptst);
            sw.Write(System.IO.Path.GetDirectoryName(saveFileDialog1.FileName));
            sw.Flush();
            sw.Close();

            sw = new System.IO.StreamWriter(saveFileDialog1.FileName);
            System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(sw);
            xw.WriteStartDocument();
            xw.WriteStartElement("JMJComponentTestCase");
            xw.WriteElementString("component_wrapper_class", "EncounterPRO.OS.Component." + ddlWrapperClass.Text);
            xw.WriteElementString("component_class", tClass.Text);
            xw.WriteElementString("component_version", tAssembly.Text);
            xw.WriteElementString("component_attributes_xml", tComponentAttributes.Text);
            xw.WriteElementString("credential_attributes_xml", tCredentialAttributes.Text);
            xw.WriteElementString("context_xml", tClinicalContext.Text);
            xw.WriteEndElement();
            xw.WriteEndDocument();
            xw.Flush();
            xw.Close();
        }
        private void WriteModifications(string dataHistoryFile, IIntegrationResult result)
        {
            System.IO.FileStream fs = new System.IO.FileStream(dataHistoryFile, System.IO.FileMode.Append);
            fs.Seek(0, System.IO.SeekOrigin.End);

            System.IO.StreamWriter   sw = new System.IO.StreamWriter(fs);
            System.Xml.XmlTextWriter currentBuildInfoWriter = new System.Xml.XmlTextWriter(sw);
            currentBuildInfoWriter.Formatting = System.Xml.Formatting.Indented;

            currentBuildInfoWriter.WriteStartElement("Build");
            WriteXMLAttributeAndValue(currentBuildInfoWriter, "BuildDate", Util.DateUtil.FormatDate(result.EndTime));
            WriteXMLAttributeAndValue(currentBuildInfoWriter, "Success", result.Succeeded.ToString(CultureInfo.CurrentCulture));
            WriteXMLAttributeAndValue(currentBuildInfoWriter, "Label", result.Label);

            if (result.Modifications.Length > 0)
            {
                currentBuildInfoWriter.WriteStartElement("modifications");

                for (int i = 0; i < result.Modifications.Length; i++)
                {
                    result.Modifications[i].ToXml(currentBuildInfoWriter);
                }

                currentBuildInfoWriter.WriteEndElement();
            }

            currentBuildInfoWriter.WriteEndElement();
            sw.WriteLine();

            sw.Flush();
            fs.Flush();

            sw.Close();
            fs.Close();
        }
        /// <summary>
        /// 保存设置 当p_path 不为空时 相当于设置别存为
        /// </summary>
        /// <param name="pPath">路径</param>
        public void Save(string pPath = null)
        {
            string path = GetPath(pPath);

            FileStream fs = null;

            System.Xml.XmlTextWriter writer = null;
            try
            {
                var xs = new XmlSerializer(typeof(KRNetworkingConfig));

                fs     = new FileStream(path, FileMode.Create);
                writer = new System.Xml.XmlTextWriter(fs, System.Text.Encoding.UTF8);
                xs.Serialize(writer, this);
            }
            catch (IOException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("序列化失败!原因:" + ex.Message));
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
예제 #36
0
        public void ToXml(System.Xml.XmlTextWriter writer)
        {
            // FIXME: if (this.IsOr) rc_package_dep_or_slist_to_xml_node ()

            writer.WriteStartElement("dep");

            using (RC.PackageSpec spec = Spec) {
                writer.WriteAttributeString("name", spec.Name);

                if (this.Relation != PackageRelation.Any)
                {
                    writer.WriteAttributeString("op", Package.RelationToString(this.Relation, 0));

                    if (spec.HasEpoch)
                    {
                        writer.WriteAttributeString("epoch", System.Xml.XmlConvert.ToString(spec.Epoch));
                    }

                    if (spec.Version != null)
                    {
                        writer.WriteAttributeString("version", spec.Version);
                    }

                    if (spec.Release != null)
                    {
                        writer.WriteAttributeString("release", spec.Release);
                    }
                }
            }

            writer.WriteEndElement();
        }
예제 #37
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int    callstack_uid;
            string author  = Request.QueryString["author"];
            string comment = Request.QueryString["comment"];

            if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
            {
                return;
            }

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Outputs");

                bool res = DB.InsertCallstackComment(callstack_uid, author, comment);
                writer.WriteAttributeString("result", res.ToString());

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
예제 #38
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int callstack_uid;

            if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
                callstack_uid = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Callstack");

                DB.LoadCallstack(callstack_uid,
                    delegate(int depth, string funcname, string fileline)
                    {
                        writer.WriteStartElement("Singlestep");
                        writer.WriteAttributeString("depth", depth.ToString());
                        this.WriteCData(writer, "Funcname", funcname);
                        this.WriteCData(writer, "Fileline", fileline);
                        writer.WriteEndElement();
                    }
                );

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
예제 #39
0
        static void WriteKeePassFile(string filePath)
        {
            XDocument xDoc         = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
            XElement  xKeyPassFile = new XElement("KeePassFile");
            XElement  xRoot        = new XElement("Root");
            XElement  xGroup       = new XElement("Group",
                                                  new XElement("UUID", "Pysc/OPNvEOBrCYOGuQJ8g=="),
                                                  new XElement("Name", "Passwords"),
                                                  new XElement("Notes"));

            xDoc.Add(xKeyPassFile);
            xKeyPassFile.Add(xRoot);
            xRoot.Add(xGroup);

            List <IEntry> entries = _root.Entries;

            AddEntriesToXml(entries, xGroup);

            MemoryStream ms           = new MemoryStream();
            var          docXmlWriter = new System.Xml.XmlTextWriter(ms, System.Text.Encoding.UTF8);

            docXmlWriter.Formatting = System.Xml.Formatting.Indented;
            xDoc.WriteTo(docXmlWriter);
            docXmlWriter.Flush();
            ms.Flush();

            ms.Seek(0, SeekOrigin.Begin);

            StreamReader sr        = new StreamReader(ms);
            string       xmlResult = sr.ReadToEnd();

            File.WriteAllText(filePath, xmlResult);
        }
예제 #40
0
        // -----------------
        private bool SaveToPlayerPrefs()
        {
            TextWriter textWriter = new StringWriter();

            System.Xml.XmlTextWriter stream = new System.Xml.XmlTextWriter(textWriter);

            if (!this.SaveToStream(stream))
            {
                return(false);
            }


            string str = textWriter.ToString();

//#if UNITY_EDITOR
//		Debug.Log(str);
//		Debug.Log("String len:" + str.Length);
//#endif

            try {
                PlayerPrefs.SetString(GAMEPAD_PROFILE_LIST_KEY, str);
            }
            catch (System.Exception e)
            {
#if UNITY_EDITOR
                Debug.LogError("Error while saving to plater prefs!\n" + e.Message);
#endif
                return(false);
            }

            return(true);
        }
예제 #41
0
        /// <summary>
        /// 保存配置到配置文件
        /// </summary>
        /// <param name="fileName">配置文件名</param>
        public virtual void SaveConfig(String fileName)
        {
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(fileName, Encoding.UTF8);

            try
            {
                writer.Formatting = System.Xml.Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("Jeelu.WordSegmentor");


                foreach (CfgItem item in GetCfgItems())
                {
                    writer.WriteComment(item.Comment);
                    writer.WriteStartElement("Item");
                    writer.WriteAttributeString("Name", item.Pi.Name);
                    writer.WriteAttributeString("Value", item.Pi.GetValue(this, null).ToString());
                    writer.WriteEndElement(); //Item
                }

                writer.WriteEndElement(); //Jeelu.WordSegmentor
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
            catch (Exception e)
            {
                WriteLog(String.Format("Save config fail, errmsg:{0}", e.Message));
            }
        }
예제 #42
0
        public static void IsolatedStorage_Read_and_Write_Sample()
        {
            string fileName = @"SelfWindow.xml";

            IsolatedStorageFile storFile = IsolatedStorageFile.GetUserStoreForDomain();
            IsolatedStorageFileStream storStream = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write);
            System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(storStream, Encoding.UTF8);
            writer.WriteStartDocument();

            writer.WriteStartElement("Settings");

            writer.WriteStartElement("UserID");
            writer.WriteValue(42);
            writer.WriteEndElement();
            writer.WriteStartElement("UserName");
            writer.WriteValue("kingwl");
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
            storStream.Close();

            string[] userFiles = storFile.GetFileNames();

            foreach(var userFile in userFiles)
            {
                if(userFile == fileName)
                {
                    var storFileStreamnew =  new IsolatedStorageFileStream(fileName,FileMode.Open,FileAccess.Read);
                    StreamReader storReader = new StreamReader(storFileStreamnew);
                    System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(storReader);

                    int UserID = 0;
                    string UserName = null;

                    while(reader.Read())
                    {
                        switch(reader.Name)
                        {
                            case "UserID":
                                UserID = int.Parse(reader.ReadString());
                                break;
                            case "UserName":
                                UserName = reader.ReadString();
                                break;
                            default:
                                break;
                        }
                    }

                    Console.WriteLine("{0} {1}", UserID, UserName);

                    storFileStreamnew.Close();
                }
            }
            storFile.Close();
        }
예제 #43
0
        public SimpleSVGWriter(System.Xml.XmlTextWriter xw)
        {
            if (xw == null)
            {
                throw new System.ArgumentNullException();
            }
            this.xw = xw;

        }
예제 #44
0
		public override void Initialize()
		{
			base.Initialize ();

			System.IO.StreamWriter oStream = new System.IO.StreamWriter(_FilePath, false, System.Text.Encoding.UTF8);
			_StreamWriter = new System.Xml.XmlTextWriter(oStream);
			_StreamWriter.Formatting = System.Xml.Formatting.Indented;

			_StreamWriter.WriteStartDocument();
			_StreamWriter.WriteStartElement("ListItems");
		}
예제 #45
0
 // Lecture de la configuration
 public static void WriteConfig()
 {
     string config_file = "config.xml";
     var newconf = new System.Xml.XmlTextWriter(config_file, null);
     newconf.WriteStartDocument();
     newconf.WriteStartElement("config");
     newconf.WriteElementString("last_update", LastUpdate.ToShortDateString());
     newconf.WriteElementString("auth_token", AuthToken);
     newconf.WriteEndElement();
     newconf.WriteEndDocument();
     newconf.Close();
 }
예제 #46
0
		protected virtual void SaveToFile(DataSet pDataSet)
		{
			if (m_FileName == null)
				throw new ApplicationException("FileName is null");
			
			byte[] completeByteArray;
			using (System.IO.MemoryStream fileMemStream = new System.IO.MemoryStream())
			{
				System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(fileMemStream, System.Text.Encoding.UTF8);

				xmlWriter.WriteStartDocument();
				xmlWriter.WriteStartElement("filedataset", c_DataNamespace);

				xmlWriter.WriteStartElement("header", c_DataNamespace);
				//File Version
				xmlWriter.WriteAttributeString(c_FileVersion, c_FileVersionNumber.ToString());
				//Data Version
				xmlWriter.WriteAttributeString(c_DataVersion, GetDataVersion().ToString());
				//Data Format
				xmlWriter.WriteAttributeString(c_DataFormat, ((int)mSaveDataFormat).ToString());
				xmlWriter.WriteEndElement();

				xmlWriter.WriteStartElement("data", c_DataNamespace);

				byte[] xmlByteArray;
				using (System.IO.MemoryStream xmlMemStream = new System.IO.MemoryStream())
				{
					StreamDataSet.Write(xmlMemStream, pDataSet, mSaveDataFormat);
					//pDataSet.WriteXml(xmlMemStream);

					xmlByteArray = xmlMemStream.ToArray();
					xmlMemStream.Close();
				}

				xmlWriter.WriteBase64(xmlByteArray, 0, xmlByteArray.Length);
				xmlWriter.WriteEndElement();

				xmlWriter.WriteEndElement();
				xmlWriter.WriteEndDocument();

				xmlWriter.Flush();
				
				completeByteArray = fileMemStream.ToArray();
				fileMemStream.Close();
			}

			//se tutto è andato a buon fine scrivo effettivamente il file
			using (System.IO.FileStream fileStream = new System.IO.FileStream(m_FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write))
			{
				fileStream.Write(completeByteArray, 0, completeByteArray.Length);
				fileStream.Close();
			}
		}
예제 #47
0
		public override void Terminate()
		{
			base.Terminate ();

			if (_StreamWriter != null)
			{
				_StreamWriter.WriteEndElement();
				_StreamWriter.WriteEndDocument();

				_StreamWriter.Close();
				_StreamWriter = null;
			}
		}
예제 #48
0
 public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
 {
     if (entity == null || !(entity is SparqlEndpoint)) return;
     var sparqlEndpoint = entity as SparqlEndpoint;
     var client = BrightstarService.GetClient();
     using (var resultStream = client.ExecuteQuery(sparqlEndpoint.Store, sparqlEndpoint.SparqlQuery))
     {
         var resultsDoc = XDocument.Load(resultStream);
         var resultsWriter = new System.Xml.XmlTextWriter(response.Stream, Encoding.Unicode);
         resultsDoc.WriteTo(resultsWriter);
         resultsWriter.Flush();
     }
 }
예제 #49
0
 // This is apapted from http://stackoverflow.com/questions/6442123/in-c-how-do-i-convert-a-xmlnode-to-string-with-indentation-without-looping
 // Note that it currently outputs the string as UTF-16 rather than the roar default of UTF-8
 // But since its only for debugging that shouldn't matter too much.
 public static string DebugAsString(this System.Xml.XmlNode node)
 {
     using (var sw = new System.IO.StringWriter())
     {
         using (var xw = new System.Xml.XmlTextWriter(sw))
         {
             xw.Formatting = System.Xml.Formatting.Indented;
             xw.Indentation = 4;
             node.WriteTo(xw);
         }
         return sw.ToString();
     }
 }
예제 #50
0
        // Lecture de la configuration
        static void ReadConfig()
        {
            string config_file = "config.xml";
            if (!System.IO.File.Exists(config_file))
            {
                var newconf = new System.Xml.XmlTextWriter(config_file, null);
                newconf.WriteStartDocument();
                newconf.WriteStartElement("config");
                newconf.WriteElementString("last_update", "0");
                newconf.WriteElementString("auth_token", "");
                newconf.WriteEndElement();
                newconf.WriteEndDocument();
                newconf.Close();
            }

            var conf = new System.Xml.XmlTextReader(config_file);
            string CurrentElement = "";
            while (conf.Read())
            {
                switch(conf.NodeType) {
                    case System.Xml.XmlNodeType.Element:
                        CurrentElement = conf.Name;
                        break;
                    case System.Xml.XmlNodeType.Text:
                    if (CurrentElement == "last_update")
                        LastUpdate = DateTime.Parse(conf.Value);
                    if (CurrentElement == "auth_token")
                        AuthToken = conf.Value;
                        break;
                }
            }
            conf.Close();

            // On vérifie que le token est encore valide
            if (AuthToken.Length > 0)
            {
                var flickr = new Flickr(Program.ApiKey, Program.SharedSecret);
                try
                {
                    Auth auth = flickr.AuthCheckToken(AuthToken);
                    Username = auth.User.UserName;
                }
                catch (FlickrApiException ex)
                {
                    //MessageBox.Show(ex.Message, "Authentification requise",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    AuthToken = "";
                }
            }
        }
예제 #51
0
 public void serialize( Stream stream, object obj ) {
     if ( m_serialize_static_mode ) {
         m_static_serializer.Serialize( stream );
     } else {
         System.Xml.XmlTextWriter xw = null;
         try {
             xw = new System.Xml.XmlTextWriter( stream, null );
             xw.Formatting = System.Xml.Formatting.None;
             m_serializer.Serialize( xw, obj );
         } catch ( Exception ex ) {
             serr.println( "XmlSerializer#serialize; ex=" + ex );
         }
     }
 }
예제 #52
0
 public static string ToString(this System.Xml.XmlDocument doc, int indentation)
 {
     using (var sw = new System.IO.StringWriter())
     {
         using (var xw = new System.Xml.XmlTextWriter(sw))
         {
             xw.Formatting = System.Xml.Formatting.Indented;
             xw.Indentation = indentation;
             doc.Save(xw);
             // node.WriteTo(xw);
         }
         return sw.ToString();
     }
 }
예제 #53
0
 public static void Save(this XDocument doc, string filename, int indentation)
 {
     using (var fs = File.Create(filename))
     {
         using (var sw = new System.IO.StreamWriter(fs))
         {
             using (var xw = new System.Xml.XmlTextWriter(sw))
             {
                 xw.Formatting = System.Xml.Formatting.Indented;
                 xw.Indentation = indentation;
                 doc.Save(xw);
             }
         }
     }
 }
예제 #54
0
        internal void FormatXml()
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(Editor.Text);

            System.IO.StringWriter sw = new System.IO.StringWriter();
            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(sw))
            {
                writer.Indentation = 2;  // the Indentation
                writer.Formatting = System.Xml.Formatting.Indented;
                doc.WriteContentTo(writer);
                writer.Close();
            }
            Editor.Text = sw.ToString();
        }
예제 #55
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DichMusicHelperPathSettings.xml";

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(settingsFile, System.Text.Encoding.Unicode))
            {
                writer.WriteStartElement("PathSettings");
                writer.WriteAttributeString("Path", pathTextBox.Text);
                writer.WriteAttributeString("CreateFolder", createFolderBox.Checked.ToString());
                writer.WriteEndElement();
                writer.Close();
            }

            this.Close();
        }
예제 #56
0
파일: XmlCOM.cs 프로젝트: WZDotCMS/WZDotCMS
 /// <summary>
 /// 保存Config参数
 /// </summary>
 public static void UpdateConfig(string name, string nKey, string nValue)
 {
     if (ReadConfig(name, nKey) != "")
     {
         System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
         XmlDoc.Load(HttpContext.Current.Server.MapPath(name + ".config"));
         System.Xml.XmlNodeList elemList = XmlDoc.GetElementsByTagName(nKey);
         System.Xml.XmlNode mNode = elemList[0];
         mNode.InnerText = nValue;
         System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(new System.IO.StreamWriter(HttpContext.Current.Server.MapPath(name + ".config")));
         xw.Formatting = System.Xml.Formatting.Indented;
         XmlDoc.WriteTo(xw);
         xw.Close();
     }
 }
예제 #57
0
        public static string KToString(SyncKnowledge knowlege)
        {
            String retVal = "";

            System.IO.MemoryStream memStream = new System.IO.MemoryStream();
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(memStream, Encoding.UTF8);
            writer.Formatting = System.Xml.Formatting.Indented;
            knowlege.WriteXml(writer);
            writer.Flush();
            memStream.Seek(0, System.IO.SeekOrigin.Begin);
            System.IO.StreamReader reader = new System.IO.StreamReader(memStream);
            retVal = reader.ReadToEnd();

            return retVal;
        }
예제 #58
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            int project_uid;

            if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
                project_uid = 1;

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();

                writer.WriteStartElement("Report");
                writer.WriteAttributeString("project", project_uid.ToString());

                writer.WriteStartElement("Items");

                DB.LoadReportDeleted(project_uid,
                    delegate(int report_uid, string login_id, string ipaddr, DateTime reported_time, string relative_time, int callstack_uid, string funcname, string version, string filename, string assigned, string uservoice, int num_comments)
                    {
                        writer.WriteStartElement("Item");

                        writer.WriteAttributeString("report_uid", report_uid.ToString());
                        writer.WriteAttributeString("login_id", login_id);
                        writer.WriteAttributeString("ipaddr", ipaddr);
                        writer.WriteAttributeString("reported_time", reported_time.ToString());
                        writer.WriteAttributeString("relative_time", relative_time);
                        writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
                        writer.WriteAttributeString("assigned", assigned);
                        writer.WriteAttributeString("num_comments", num_comments.ToString());
                        this.WriteCData(writer, "Funcname", funcname);
                        this.WriteCData(writer, "Version", version);
                        this.WriteCData(writer, "Filename", filename);
                        this.WriteCData(writer, "Uservoice", uservoice);

                        writer.WriteEndElement();
                    }
                );
                writer.WriteEndElement(); // Items
                writer.WriteEndElement(); // Report
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
예제 #59
0
 public static void saveDataTable(DataTable data, string filePath)
 {
     // Create the FileStream to write with.
     System.IO.FileStream myFileStream = new System.IO.FileStream
        (filePath, System.IO.FileMode.Create);
     // Create an XmlTextWriter with the fileStream.
     System.Xml.XmlTextWriter myXmlWriter =
        new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
     // Write to the file with the WriteXml method.
     try
     {
         data.WriteXml(myXmlWriter);
     }
     finally
     {
         myXmlWriter.Close();
     }
 }
예제 #60
0
 /// <summary>
 /// 序列化成xml字符串
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>序列化后的字符串</returns>
 public static string Serialize(object obj)
 {
     XmlSerializer xs = new XmlSerializer(obj.GetType());
     using (MemoryStream ms = new MemoryStream())
     {
         System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(ms, System.Text.Encoding.UTF8);
         xtw.Formatting = System.Xml.Formatting.Indented;
         xs.Serialize(xtw, obj);
         ms.Seek(0, SeekOrigin.Begin);
         using (StreamReader sr = new StreamReader(ms))
         {
             string str = sr.ReadToEnd();
             xtw.Close();
             ms.Close();
             return str;
         }
     }
 }