Close() 공개 메소드

public Close ( ) : void
리턴 void
예제 #1
0
    public static T LoadFromTextAsset <T>(TextAsset textAsset, System.Type[] extraTypes = null)
    {
        if (textAsset == null)
        {
            throw new ArgumentNullException("textAsset");
        }

        System.IO.TextReader textStream = null;

        try
        {
            textStream = new System.IO.StringReader(textAsset.text);

            XmlSerializer serializer = new XmlSerializer(typeof(T), extraTypes);
            T             data       = (T)serializer.Deserialize(textStream); //T data = (T)serializer...

            textStream.Close();

            return(data);
        }
        catch (System.Exception exception)
        {
            Debug.LogError("The database of type '" + typeof(T) + "' failed to load the asset. The following exception was raised:\n " + exception.Message);
        }
        finally
        {
            if (textStream != null)
            {
                textStream.Close();
            }
        }

        return(default(T));//return default(T);
    }
예제 #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="notationData"></param>
 /// <returns></returns>
 public static LLSD DeserializeNotation(string notationData)
 {
     StringReader reader = new StringReader(notationData);
     LLSD llsd = DeserializeNotation(reader);
     reader.Close();
     return llsd;
 }
예제 #3
0
		public static TriviaMessage Deserialize(string dataReceived)
		{
            /*
bool correctEnding = (dataReceived.EndsWith("</TriviaMessage>"));
if (!correctEnding)
{
	throw new InvalidOperationException("Deserialization will fail...");
}
             */
			XmlSerializer serializer = new XmlSerializer(typeof(TriviaMessage));
			StringReader reader = new StringReader(dataReceived);

			TriviaMessage message = null;

            try
            {
                message = (TriviaMessage)(serializer.Deserialize(reader));
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException(string.Format("Failed to deserialize this data received '{0}'", dataReceived), ex);
            }

			reader.Close();
			
			return message;
		}
        /// <summary>
        /// Deserializes a string containing an Xml representation of a TokenRestrictionTemplate
        /// back into a TokenRestrictionTemplate class instance.
        /// </summary>
        /// <param name="templateXml">A string containing the Xml representation of a TokenRestrictionTemplate</param>
        /// <returns>TokenRestrictionTemplate instance</returns>
        public static TokenRestrictionTemplate Deserialize(string templateXml)
        {
            TokenRestrictionTemplate templateToReturn = null;
            DataContractSerializer serializer = GetSerializer();

            StringReader stringReader = null;
            XmlReader reader = null;
            try
            {
                stringReader = new StringReader(templateXml);

                reader = XmlReader.Create(stringReader);

                templateToReturn = (TokenRestrictionTemplate)serializer.ReadObject(reader);
            }
            finally
            {
                if (reader != null)
                {
                    // This will close the underlying StringReader instance
                    reader.Close();
                }
                else if (stringReader != null)
                {
                    stringReader.Close();
                }
            }

            return templateToReturn;
        }
예제 #5
0
파일: ItemCache.cs 프로젝트: tsebalj1/rawr
        public void Load()
        {
            _items = new SortedDictionary <int, Item>();
            List <Item> listItems = new List <Item>();

            if (File.Exists(ItemCache.SavedFilePath))
            {
                try {
                    string xml = System.IO.File.ReadAllText(ItemCache.SavedFilePath).Replace("/images/icons/", "");
                    xml = xml.Replace("<Slot>Weapon</Slot", "<Slot>TwoHand</Slot>").Replace("<Slot>Idol</Slot", "<Slot>Ranged</Slot>").Replace("<Slot>Robe</Slot", "<Slot>Chest</Slot>");
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ItemList));
                    System.IO.StringReader reader = new System.IO.StringReader(xml);
                    listItems = (List <Item>)serializer.Deserialize(reader);
                    reader.Close();
                } catch (Exception) {
                    Log.Show("Rawr was unable to load the Item Cache. It appears to have been made with a previous incompatible version of Rawr. Please use the ItemCache included with this version of Rawr to start from.");
                }
            }
            foreach (Item item in listItems)
            {
                //item.Stats.ConvertStatsToWotLKEquivalents();
                //item.Sockets.Stats.ConvertStatsToWotLKEquivalents();
                //if (item.Type == ItemType.Leather) UpdateArmorFromWowhead(item);
                AddItem(item, false);
            }

            LocationFactory.Load(Path.Combine("Data", "ItemSource.xml"));
            ItemFilter.Load(Path.Combine("Data", "ItemFilter.xml"));
            Calculations.ModelChanged += new EventHandler(Calculations_ModelChanged);
        }
예제 #6
0
 public static OSD DeserializeLLSDNotation(string notationData)
 {
     StringReader reader = new StringReader(notationData);
     OSD osd = DeserializeLLSDNotation(reader);
     reader.Close();
     return osd;
 }
예제 #7
0
        public void TestMethod1()
        {
            Lucene.Net.Analysis.Standard.StandardAnalyzer a = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
            string s = "我日中华人民共和国";

            System.IO.StringReader          reader = new System.IO.StringReader(s);
            Lucene.Net.Analysis.TokenStream ts     = a.TokenStream(s, reader);
            bool hasnext = ts.IncrementToken();

            Lucene.Net.Analysis.Tokenattributes.ITermAttribute ita;

            while (hasnext)
            {
                ita = ts.GetAttribute <Lucene.Net.Analysis.Tokenattributes.ITermAttribute>();
                Console.WriteLine(ita.Term);
                hasnext = ts.IncrementToken();
            }

            Console.WriteLine("over");


            ts.CloneAttributes();
            reader.Close();
            a.Close();
        }
예제 #8
0
        /// <summary>
        /// Opens a specified chart and reads in all the valid BPM changes 
        /// (i.e. 23232 = B 162224) and returns a populated list.
        /// </summary>
        /// <param name="inputFile">
        /// The whole *.chart file stored in one massive string.
        /// </param>
        /// <returns>
        /// A list containing every valid BPM change from the chart.  Due to the nature
        /// of the *.chart specification, these BPM changes will be in proper order.
        /// </returns>
        public static List<BPMChange> AddBPMChangesFromChart(string inputFile)
        {
            List<BPMChange> BPMChangeListToReturn = new List<BPMChange>();

            // Single out the BPM section via regular expressions
            string pattern = Regex.Escape("[") + "SyncTrack]\\s*" + Regex.Escape("{") + "[^}]*";
            Match matched_section = Regex.Match(inputFile, pattern);

            // Create the stream from the singled out section of the input string
            StringReader pattern_stream = new StringReader(matched_section.ToString());
            string current_line = "";
            string[] parsed_line;

            while ((current_line = pattern_stream.ReadLine()) != null)
            {
                // Trim and split the line to retrieve information
                current_line = current_line.Trim();
                parsed_line = current_line.Split(' ');

                // If a valid change is found, add it to the list
                if (parsed_line.Length == 4)
                {
                    if (parsed_line[2] == "B")
                        BPMChangeListToReturn.Add(new BPMChange(Convert.ToUInt32(parsed_line[0]), Convert.ToUInt32(parsed_line[3])));
                }
            }

            // Close the string stream
            pattern_stream.Close();

            return BPMChangeListToReturn;
        }
예제 #9
0
 public void FailsIfThereAreReferenceOrTypeErrors()
 {
     string program = "class Factorial {\n" +
                      "   public static void main () {\n" +
                      "     System.out.println (new Factor ().ComputeFac (10));\n" +
                      "} \n\n" +
                      "} \n" +
                      "class Fac { \n" +
                      "   public int ComputeFac (int num) {\n" +
                      "     assert (num > true || num == 0);\n" +
                      "     int num_aux;\n" +
                      "     if (num == 0)\n" +
                      "       num_aux = 1;\n" +
                      "     else \n" +
                      "       aux = num * this.ComputeFac (num-1);\n" +
                      "     return aux;\n" +
                      "   }\n" +
                      "}\n";
     var reader = new StringReader(program);
     var frontend = new FrontEnd(reader);
     Program syntaxTree;
     Assert.False(frontend.TryProgramAnalysis(out syntaxTree));
     Assert.NotNull(syntaxTree); // syntax analysis was ok
     Assert.That(frontend.GetErrors(), Is.Not.Empty);
     reader.Close();
 }
예제 #10
0
    // Method for getting all config fields at once, once when game starts.
    public bool ParseInputConfig(string configName)
    {
        Debug.Log("Parse of config: " + configName + "started.");
        TextAsset textFile = (TextAsset)Resources.Load(configName, typeof(TextAsset));

        System.IO.StringReader textStream = new System.IO.StringReader(textFile.text);
        string line;

        while ((line = textStream.ReadLine()) != null)
        {
            if (line.StartsWith(LEFT_BRACKET))
            {
                string key = FindStringInBetween(line, LEFT_BRACKET, RIGHT_BRACKET);

                if ((line = textStream.ReadLine()) != null)
                {
                    string value = line;
                    keyCodes.Add(key, value);
                    Debug.Log("Line ID: " + LEFT_BRACKET + key + RIGHT_BRACKET + "was successfully parsed with value: " + value);
                }
            }
        }
        textStream.Close();

        int count = keyCodes.Count;

        if (count > 0)
        {
            return(true);
        }

        Debug.LogWarning("Config file was not found or has zero fields.");
        return(false);
    }
예제 #11
0
        public static DatatxtDesc ParseDatatxt(string st)
        {
            DatatxtDesc result = new DatatxtDesc();
            StringReader sr = new StringReader(st);
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                if (line.Trim().Length == 0) continue;
                if (line.Trim() == "<object>")
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.Trim() == "<object_end>") break;
                        ObjectInfo of = new ObjectInfo(GetTagAndIntValue(line, "id:"),
                                                         GetTagAndIntValue(line, "type:"),
                                                         GetTagAndStrValue(line, "file:"));
                        result.lObject.Add(of);

                    }
                if (line.Trim() == "<background>")
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.Trim() == "<background_end>") break;
                        BackgroundInfo bf = new BackgroundInfo(GetTagAndIntValue(line, "id:"), GetTagAndStrValue(line, "file:"));
                        result.lBackground.Add(bf);
                    }

            }
            sr.Close();
            return result;
        }
예제 #12
0
파일: Server.cs 프로젝트: KNCT-KPC/Bungo
        private async System.Threading.Tasks.Task acceptClient(TcpClient client)
        {
            try
            {
            var ns = client.GetStream();
            var ms = new System.IO.MemoryStream();
            byte[] result_bytes = new byte[4096];

            do
            {
                int result_size = await ns.ReadAsync(result_bytes, 0, result_bytes.Length);
                if (result_size == 0)
                {
                    onDisconnect(client);
                    client.Close();
                    return;
                }
                ms.Write(result_bytes, 0, result_size);
            } while (ns.DataAvailable);

            string message = Encoding.UTF8.GetString(ms.ToArray());
            ms.Close();

            StringReader sr = new StringReader(message);
            string str;
            while ((str = sr.ReadLine()) != null) {
                onReceive(client, str);
            }
            sr.Close();
            await acceptClient(client);
            } catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #13
0
파일: EasyDB.cs 프로젝트: mfz888/xcore
 public static Object LoadFromString( String targetString, Type targetType ) {
     XmlSerializer serializer = new XmlSerializer( targetType );
     TextReader textReader = new StringReader( targetString );
     Object result = serializer.Deserialize( textReader );
     textReader.Close();
     return result;
 }
예제 #14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="HeaderText">Text for the header</param>
 public MIMEHeader(string HeaderText)
 {
     Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(HeaderText), "HeaderText");
     this.Fields = new List<Field>();
     StringReader Reader=new StringReader(HeaderText);
     try
     {
         string LineRead=Reader.ReadLine();
         string Field=LineRead+"\r\n";
         while(!string.IsNullOrEmpty(LineRead))
         {
             LineRead=Reader.ReadLine();
             if (!string.IsNullOrEmpty(LineRead) && (LineRead[0].Equals(' ') || LineRead[0].Equals('\t')))
             {
                 Field += LineRead + "\r\n";
             }
             else
             {
                 Fields.Add(new Field(Field));
                 Field = LineRead + "\r\n";
             }
         }
     }
     finally
     {
         Reader.Close();
         Reader=null;
     }
 }
예제 #15
0
    private List <string> readData(string fileLoc)
    {
        string        data = "";
        string        nextLine;
        List <string> list     = new List <string>();
        TextAsset     textFile = (TextAsset)Resources.Load(fileLoc, typeof(TextAsset));

        System.IO.StringReader textStream = new System.IO.StringReader(textFile.text);
        while ((nextLine = textStream.ReadLine()) != null)
        {
            if (nextLine.Equals("}"))
            {
                data += nextLine;
                list.Add(data);
                data = "";
            }
            else
            {
                data += nextLine;
            }
        }
        textStream.Close();

        return(list);
    }
예제 #16
0
        public bool CreatePDF(string text, string outPutPath)
        {
            var returnValue = false;
            try
            {
                StringReader sr = new StringReader(text);

              //  Document pdfDoc = new Document(PageSize.LETTER, 30, 30, 40, 30);
                Document pdfDoc = new Document(PageSize.A4, 30, 30, 40, 30);

                HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                //PdfWriter.GetInstance(pdfDoc, new FileStream(@"d:\Temp\Test.pdf", FileMode.Create));

                PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, new FileStream(outPutPath, FileMode.Create));
                //pdfWriter.PageEvent = new ITextEvents();

                pdfDoc.Open();

                htmlparser.Parse(sr);
                pdfDoc.Close();
                sr.Close();
                returnValue = true;
            }
            catch { }

            return returnValue;
        }
예제 #17
0
파일: Node.cs 프로젝트: JerryXia/Yaml.Net
 /// <summary> Parse a Yaml string and return a Yaml tree </summary>
 public static Node Parse(string lines)
 {
     StringReader reader = new StringReader(lines);
     Node node = Parse(new ParseStream(reader));
     reader.Close();
     return node;
 }
예제 #18
0
        public void v()
        {
            //Analyzer analyzer = new CJKAnalyzer();
            //TokenStream tokenStream = analyzer.TokenStream("", new StringReader("我爱你中国China中华人名共和国"));
            //Lucene.Net.Analysis.Token token = null;
            //while ((token = tokenStream.Next()) != null)
            //{
            //    Response.Write(token.TermText() + "<br/>");
            //}

            Lucene.Net.Analysis.Standard.StandardAnalyzer a = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
            string s = "我日中华人民共和国";

            System.IO.StringReader          reader = new System.IO.StringReader(s);
            Lucene.Net.Analysis.TokenStream ts     = a.TokenStream(s, reader);
            bool hasnext = ts.IncrementToken();

            Lucene.Net.Analysis.Tokenattributes.ITermAttribute ita;
            while (hasnext)
            {
                ita = ts.GetAttribute <Lucene.Net.Analysis.Tokenattributes.ITermAttribute>();
                Console.WriteLine(ita.Term);
                hasnext = ts.IncrementToken();
            }
            ts.CloneAttributes();
            reader.Close();
            a.Close();
            Console.ReadKey();
        }
예제 #19
0
    private static void UpdateBuildNumber()
    {
        string    currentDate = "" + System.DateTime.Now.Year + "." + System.DateTime.Now.Month.ToString("00") + "." + System.DateTime.Now.Day.ToString("00");
        TextAsset txt         = (TextAsset)Resources.LoadAssetAtPath("Assets/StreamingAssets/build_number.txt", typeof(TextAsset));

        string val = "";

        if (txt == null)
        {
            val = currentDate + ".1";
        }
        else
        {
            System.IO.StringReader reader = new System.IO.StringReader(txt.text);
            val = reader.ReadLine();
            reader.Close();


            if (val.Contains(currentDate))
            {
                int buildNumber = int.Parse(val.Replace(currentDate + ".", ""));
                val = currentDate + "." + (buildNumber + 1);
            }
            else
            {
                val = currentDate + ".1";
            }
        }

        //write the val
        System.IO.TextWriter writer = System.IO.File.CreateText("Assets/StreamingAssets/build_number.txt");
        writer.Write(val);
        writer.Close();
        AssetDatabase.ImportAsset("Assets/StreamingAssets/build_number.txt", ImportAssetOptions.ForceUpdate);
    }
예제 #20
0
        public void TestPublic()
        {
            TextReader reader = new StringReader(OpenIdTestBase.LoadEmbeddedFile("dhpriv.txt"));

            try {
                string line;
                while ((line = reader.ReadLine()) != null) {
                    string[] parts = line.Trim().Split(' ');
                    byte[] x = Convert.FromBase64String(parts[0]);
                    DiffieHellmanManaged dh = new DiffieHellmanManaged(AssociateDiffieHellmanRequest.DefaultMod, AssociateDiffieHellmanRequest.DefaultGen, x);
                    byte[] pub = dh.CreateKeyExchange();
                    byte[] y = Convert.FromBase64String(parts[1]);

                    if (y[0] == 0 && y[1] <= 127) {
                        y.CopyTo(y, 1);
                    }

                    Assert.AreEqual(
                        Convert.ToBase64String(y),
                        Convert.ToBase64String(DiffieHellmanUtilities.EnsurePositive(pub)),
                        line);
                }
            } finally {
                reader.Close();
            }
        }
예제 #21
0
        public static SkillData GetData(string data)
        {
            SkillData skillData = new SkillData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/SKILLS]")
                {
                    break;
                }
                else if (line == "[SKILL]")
                {
                    skillData.Skills.Add(ReadSkill(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return skillData;
        }
예제 #22
0
        //◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆
        /// <summary>
        /// テキストを1行区切でリスト化
        /// </summary>
        /// <param name="str_data">対象文字列</param>
        /// <param name="str_separator">センサ区切り文字</param>
        /// <param name="i_data_num">1行内のセンサ数</param>
        /// <returns></returns>
        public List <string> mReadLine_String(string str_data, string str_separator, int i_data_num)
        {
            string        strBuf;
            List <string> lst_strReturn = new List <string>();

            //StreamReader sr = new StreamReader(str_data, Encoding.GetEncoding("SHIFT_JIS"));
            System.IO.StringReader rs = new System.IO.StringReader(str_data);


            //num = Character_Figure(str_data, New_Line);

            while (true)
            {
                strBuf = rs.ReadLine();

                if (strBuf == null)
                {
                    break;
                }

                else if (i_data_num != Character_Figure(strBuf, str_separator))
                {
                    continue;
                }
                else
                {
                    lst_strReturn.Add(strBuf);
                }
            }

            rs.Close();
            return(lst_strReturn);
        }
예제 #23
0
        public static TriggerableData GetData(string data)
        {
            TriggerableData triggerableData = new TriggerableData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/TRIGGERABLES]")
                {
                    break;
                }
                else if (line == "[TRIGGERABLE]")
                {
                    triggerableData.Triggerables.Add(ReadTriggerable(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return triggerableData;
        }
예제 #24
0
        public void Load()
        {
            _items = new SortedDictionary <string, Item[]>();
            List <Item> listItems = new List <Item>();

            if (File.Exists(ItemCache.SavedFilePath))
            {
                try
                {
                    string xml = System.IO.File.ReadAllText(ItemCache.SavedFilePath).Replace("/images/icons/", "");
                    xml = xml.Replace("<Slot>Weapon</Slot", "<Slot>TwoHand</Slot>").Replace("<Slot>Idol</Slot", "<Slot>Ranged</Slot>").Replace("<Slot>Robe</Slot", "<Slot>Chest</Slot>");
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List <Item>));
                    System.IO.StringReader reader = new System.IO.StringReader(xml);
                    listItems = (List <Item>)serializer.Deserialize(reader);
                    reader.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("Rawr was unable to load the Item Cache. It appears to have been made with a previous incompatible version of Rawr. Please use the ItemCache included with this version of Rawr to start from.");
                }
            }
            foreach (Item item in listItems)
            {
                AddItem(item, true, false);
            }

            LocationFactory.Load("ItemSource.xml");
            Calculations.ModelChanged += new EventHandler(Calculations_ModelChanged);
        }
        public static FunctionMetadataRegistry CreateRegistry()
        {
            StringReader br = new StringReader(Resource1.functionMetadata);

            FunctionDataBuilder fdb = new FunctionDataBuilder(400);

            try
            {
                while (true)
                {
                    String line = br.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    if (line.Length < 1 || line[0] == '#')
                    {
                        continue;
                    }
                    String TrimLine = line.Trim();
                    if (TrimLine.Length < 1)
                    {
                        continue;
                    }
                    ProcessLine(fdb, line);
                }
                br.Close();
            }
            catch (IOException)
            {
                throw;
            }

            return fdb.Build();
        }
예제 #26
0
파일: Paste.cs 프로젝트: rfyiamcool/solrex
 public PasteProcessor(ConnectionTag tag, string text)
 {
     _tag = tag;
     StringReader r = new StringReader(text);
     Fill(r);
     r.Close();
 }
예제 #27
0
    static XmlDocument ParseTextAssetToXMLDocument(TextAsset textasset)
    {
        XmlDocument xmlDoc = new XmlDocument();
        //because of annoying feature of Unity, that the way to read UTF-8 XML, we need to skip BOM(byte order mark)
        //but for XML without UTF-8 character, we MUST NOT skip first character.
        //so, we firstly not skip BOM, try to load XML, if it fail, then try skip BOM to parse again.
        bool parseOK = false;

        //1. not SKIP first character
        try
        {
            xmlDoc.LoadXml(textasset.text);
            parseOK = true;
            return(xmlDoc);
        }
        catch (System.Exception exc)
        {
            Debug.Log("It seems we need to skip BOM at XML:" + textasset.name + "\n" + exc.StackTrace);
            parseOK = false;
        }
        //if 1. fail, skip BOM, and parse again.
        if (parseOK == false)
        {
            System.IO.StringReader stringReader = new System.IO.StringReader(textasset.text);
            stringReader.Read(); // skip BOM
            System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stringReader);
            xmlDoc.Load(reader);
            reader.Close();
            stringReader.Close();
        }
        return(xmlDoc);
    }
예제 #28
0
        public void ConvertDialogScriptToRealScript(Dialog dialog, Game game, CompileMessages errors)
        {
            string thisLine;
            _currentlyInsideCodeArea = false;
            _hadFirstEntryPoint = false;
            _game = game;
            _currentDialog = dialog;
            _existingEntryPoints.Clear();
            _currentLineNumber = 0;

            StringReader sr = new StringReader(dialog.Script);
            StringWriter sw = new StringWriter();
            sw.Write(string.Format("function _run_dialog{0}(int entryPoint) {1} ", dialog.ID, "{"));
            while ((thisLine = sr.ReadLine()) != null)
            {
                _currentLineNumber++;
                try
                {
                    ConvertDialogScriptLine(thisLine, sw, errors);
                }
                catch (CompileMessage ex)
                {
                    errors.Add(ex);
                }
            }
            if (_currentlyInsideCodeArea)
            {
                sw.WriteLine("}");
            }
            sw.WriteLine("return RUN_DIALOG_RETURN; }"); // end the function
            dialog.CachedConvertedScript = sw.ToString();
            sw.Close();
            sr.Close();
        }
        private void UsingStringReaderAndStringWriter()
        {
            Console.WriteLine("String Reader and String Writer example");
            Console.WriteLine("Some APIs expects TestWriter and TextReader but they can't work with string or StringBuilder. StringWriter and StringReader adapts to the interface of StringBuilder.");

            StringWriter stringWriter = new StringWriter();
            using (XmlWriter writer = XmlWriter.Create(stringWriter))
            {
                writer.WriteStartElement("book");
                writer.WriteElementString("price", "19.95");
                writer.WriteEndElement();
                writer.Flush();
            }

            string xml = stringWriter.ToString();
            Console.WriteLine("String created using StringWriter and XMLWriter is :");
            Console.WriteLine(xml);

            StringReader stringReader = new StringReader(xml);
            using (XmlReader reader = XmlReader.Create(stringReader))
            {
                reader.ReadToFollowing("price");
                decimal price = decimal.Parse(reader.ReadInnerXml(),new CultureInfo("en-US"));
                Console.WriteLine("Price read using String Reader and XMLReader is :" + price);
            }

            stringWriter.Close();
            stringReader.Close();
        }
예제 #30
0
	private static void UpdateBuildNumber() 
	{
		string currentDate = "" + System.DateTime.Now.Year + "." + System.DateTime.Now.Month.ToString("00") + "." + System.DateTime.Now.Day.ToString("00");
		TextAsset txt = (TextAsset)Resources.LoadAssetAtPath("Assets/StreamingAssets/build_number.txt", typeof(TextAsset));
		
		string val = "";
		if (txt == null) 
		{
			val = currentDate + ".1";
		} 
		else 
		{
			System.IO.StringReader reader = new System.IO.StringReader(txt.text);
			val = reader.ReadLine();
			reader.Close();
			
			
			if (val.Contains(currentDate)) {
				int buildNumber = int.Parse(val.Replace(currentDate + ".", ""));
				val = currentDate + "." + (buildNumber + 1);
			} else {
				val = currentDate + ".1";
			}
		}
		
		//write the val
		System.IO.TextWriter writer = System.IO.File.CreateText("Assets/StreamingAssets/build_number.txt");
		writer.Write(val);
		writer.Close();
		AssetDatabase.ImportAsset("Assets/StreamingAssets/build_number.txt", ImportAssetOptions.ForceUpdate);
	}
        void LoadV1(BinaryReader binread)
        {
            var strread = new StringReader(binread.ReadString());
            var xmlread = XmlReader.Create(strread);
            var xmlserializer = new XmlSerializer(engineStartParams.type);
            engineStartParams.Load(xmlserializer.Deserialize(xmlread));
            strread.Close ();
            xmlread.Close ();

            int count = binread.ReadInt32();
            for(int i=0;i<count;i++)
            {
                var enabled = binread.ReadBoolean();
                var typestr = binread.ReadString();
                var type = Type.GetType (typestr);
                if(type == null)
                {
                    binread.ReadString(); // can't find type, so just read and throw away
                    continue;
                }
                var xmlserializer2 = new XmlSerializer(type);
                strread = new StringReader(binread.ReadString());
                xmlread = XmlReader.Create(strread);
                customGameStartParams[type].Load(xmlserializer2.Deserialize(xmlread));
                strread.Close ();
                xmlread.Close ();
                customGameStartParams[type].enabled = enabled;
            }
            binread.Close();
            xmlread.Close();
        }
예제 #32
0
        public static AffixData GetData(string data)
        {
            AffixData affixData = new AffixData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;


            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/AFFIXES]")
                {
                    break;
                }
                else if (line == "[AFFIX]")
                {
                    affixData.Affixes.Add(ReadAffix(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return affixData;
        }
예제 #33
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="HeaderText">Text for the header</param>
 public MIMEHeader(string HeaderText)
 {
     if(string.IsNullOrEmpty(HeaderText))
         throw new ArgumentNullException("Header text can not be null");
     StringReader Reader=new StringReader(HeaderText);
     try
     {
         string LineRead=Reader.ReadLine();
         string Field=LineRead+"\r\n";
         while(!string.IsNullOrEmpty(LineRead))
         {
             LineRead=Reader.ReadLine();
             if (!string.IsNullOrEmpty(LineRead) && (LineRead[0].Equals(' ') || LineRead[0].Equals('\t')))
             {
                 Field += LineRead + "\r\n";
             }
             else
             {
                 Fields.Add(new Field(Field));
                 Field = LineRead + "\r\n";
             }
         }
     }
     finally
     {
         Reader.Close();
         Reader=null;
     }
 }
        /// <summary>
        /// This method will deserialize a string
        /// </summary>
        /// <param name="filePath"></param>
        public Object deSerialize(Object m_object, String data)
        {
            try
            {
                XmlSerializer serializer;
                StringReader stringReader = new StringReader(data);
                XmlTextReader textReader = new XmlTextReader(stringReader);

                Type objectType = m_object.GetType();
                string name = objectType.Name;

                if (name == "DocumentStorage")
                {
                    serializer = new XmlSerializer(typeof(DocumentStorage));
                    m_object = (DocumentStorage)serializer.Deserialize(textReader);
                }

                if (name == "TemplateStorage")
                {
                    serializer = new XmlSerializer(typeof(TemplateStorage));
                    m_object = (TemplateStorage)serializer.Deserialize(textReader);
                }

                textReader.Close();
                stringReader.Close();
                System.Console.WriteLine(Environment.NewLine + "Object 'readStore' deserialized!");

                return m_object;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
예제 #35
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(Message);
            int i = 1;
            foreach (IValidationResult result in ValidationResults)
            {
                if (!BoolUtil.IsTrue(result.Passed))
                {
                    if (result.Details != null)
                    {
                        foreach (IValidationResultInfo info in result.Details)
                        {
                            sb.Append(Environment.NewLine + i + ": ");
                            StringReader sr = new StringReader(info.ToString());
                            string s = sr.ReadLine();
                            bool isFirstLine = true;
                            while (!string.IsNullOrEmpty(s))
                            {
                                if (!isFirstLine)
                                    sb.Append(Environment.NewLine);
                                sb.Append("\t" + s);
                                isFirstLine = false;
                                s = sr.ReadLine();
                            }
                            sr.Close();

                            i++;
                        }
                    }
                }
            }

            return sb.ToString();
        }
예제 #36
0
        public static MissileData GetData(string data)
        {
            MissileData missileData = new MissileData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/MISSILES]")
                {
                    break;
                }
                else if (line == "[MISSILE]")
                {
                    missileData.Missiles.Add(ReadMissile(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return missileData;
        }
예제 #37
0
        /// <summary>
        /// Deserialize a XML file on disk to an instance of OWOfficeConfiguration.
        /// </summary>
        /// <param name="configurationFilePath">Full file path for the XML file to be read and deserialized.</param>
        /// <returns>A deserialized OWOfficeConfiguration instance.</returns>
        public static OWC DeserializeFromXml(string xmlData)
        {
            OWC owc = null;

            System.IO.StringReader sr = null;
            try
            {
                sr = new System.IO.StringReader(xmlData);

                XmlSerializer serializer = new XmlSerializer(typeof(OWC));
                owc = (OWC)serializer.Deserialize(sr);
            }
            catch (Exception ex)
            {
                ex = ex;
            }
            finally
            {
                // Clean up memory
                if (sr != null)
                {
                    sr.Close();
                }
            }
            return(owc);
        }
예제 #38
0
        /// <summary>
        /// Opens a specified chart and reads in all the valid events 
        /// (i.e 14208 = E "section Verse 1a") and returns a populated list.
        /// </summary>
        /// <param name="input_string">
        /// The whole *.chart file stored in one massive string.
        /// </param>
        /// <returns>
        /// A list containing every valid event from the chart.  Due to the nature
        /// of the *.chart specification, these events will be in proper order.
        /// </returns>
        public static List<Event> AddEventsFromChart(string input_string)
        {
            List<Event> eventListToReturn = new List<Event>();

            // Single out the event section via regular expressions
            string pattern = Regex.Escape("[") + "Events]\\s*" + Regex.Escape("{") + "[^}]*";
            Match matched_section = Regex.Match(input_string, pattern);

            // Create the stream from the singled out section of the input string
            StringReader pattern_stream = new StringReader(matched_section.ToString());
            string current_line = "";
            string[] parsed_line;

            while ((current_line = pattern_stream.ReadLine()) != null)
            {
                // Trim and split the line to retrieve information
                current_line = current_line.Trim();
                parsed_line = current_line.Split(' ');

                // If a valid event is found, add it to the list
                if (parsed_line.Length >= 4)
                {
                    if (parsed_line[2] == "E")
                    {
                        eventListToReturn.Add(new Event(Convert.ToUInt32(parsed_line[0]),
                                              ProperStringCreator.createProperString(parsed_line.SubArray(3, parsed_line.Length))));
                    }
                }
            }

            // Close the string stream
            pattern_stream.Close();

            return eventListToReturn;
        }
예제 #39
0
        public override void Decode(string Input, out byte[] Output)
        {
            if (string.IsNullOrEmpty(Input))
            {
                throw new ArgumentNullException("Input can not be null");
            }

            string CurrentLine="";
            MemoryStream MemoryStream=new MemoryStream();
            StringReader Reader=new StringReader(Input);
            try
            {
                CurrentLine=Reader.ReadLine();
                while (!string.IsNullOrEmpty(CurrentLine))
                {
                    DecodeOneLine(MemoryStream, CurrentLine);
                    CurrentLine=Reader.ReadLine();
                }
                Output = MemoryStream.ToArray();
            }
            finally
            {
                MemoryStream.Close();
                MemoryStream = null;
                Reader.Close();
                Reader = null;
            }
        }
        public static UserInterfaceData GetData(string data)
        {
            UserInterfaceData userInterfaceData = new UserInterfaceData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/USERINTERFACES]")
                {
                    break;
                }
                else if (line == "[USERINTERFACE]")
                {
                    userInterfaceData.UserInterfaces.Add(ReadUserInterface(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return userInterfaceData;
        }
예제 #41
0
 public void CanContinueToTypeCheckIfNonFatalErrorsFound()
 {
     string program = "class Factorial {\n" +
                      "   public static void main () {\n" +
                      "     System.out.println (new Fac ().ComputeFac (10));\n" +
                      "} \n\n" +
                      "} \n" +
                      "class Fac { \n" +
                      "   public int ComputeFac (int num) {\n" +
                      "     assert (num > 0 || num == 0);\n" +
                      "     void num_aux;\n" +
                      "     if (num == 0)\n" +
                      "       num_aux = 1;\n" +
                      "     else \n" +
                      "       num_aux = num * this.ComputeFac (num-1);\n" +
                      "     return num_aux;\n" +
                      "   }\n" +
                      "   public int ComputeFac () { }\n" +
                      "}\n";
     var reader = new StringReader(program);
     var frontend = new FrontEnd(reader);
     Program syntaxTree;
     Assert.False(frontend.TryProgramAnalysis(out syntaxTree));
     Assert.NotNull(syntaxTree); // syntax analysis was ok
     Assert.That(frontend.GetErrors(), Is.Not.Empty);
     Assert.That(frontend.GetErrors().Last().ToString(), Is.StringContaining("Missing return statement in method ComputeFac"));
     reader.Close();
 }
예제 #42
0
        /// <summary>
        /// Writes attachment to a stream
        /// </summary>
        /// <param name="stream">The stream to write the attachmment on</param>
        public void Write(System.IO.TextWriter stream)
        {
            string st = "";

            // writes headers
#if false
            foreach (System.Collections.DictionaryEntry s in m_headers)
            {
                string v = (string)s.Value;

                st = s.Key + ":" + v;
                if (!v.EndsWith("\r\n"))
                {
                    st += endl;
                }

                stream.Write(st);
            }
#else
            foreach (MimeField m in m_headers)
            {
                st = m.Name + ":" + m.Value;
                if (!st.EndsWith("\r\n"))
                {
                    st += endl;
                }

                stream.Write(st);
            }
#endif

            // \r\n to end header
            stream.Write(endl);

            // write body
            System.IO.StringReader r = new System.IO.StringReader(m_body.ToString());
            string tmp;
            while ((tmp = r.ReadLine()) != null)
            {
                stream.Write(tmp + "\r\n");
            }
            r.Close();
            stream.Write(endl);

            // write attachments
            if (m_attachments.Count > 0)
            {
                stream.Write(m_boundary);
                stream.Write(endl);

                foreach (MimeAttachment m in m_attachments)
                {
                    m.Write(stream);
                }
                stream.Write(m_boundary);
                stream.Write(endl);
            }
        }
        public static DynamicGingerExecution LoadDynamicExecutionFromXML(string content)
        {
            System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(DynamicGingerExecution));
            System.IO.StringReader stringReader           = new System.IO.StringReader(content);
            DynamicGingerExecution dynamicRunSet          = (DynamicGingerExecution)reader.Deserialize(stringReader);

            stringReader.Close();
            return(dynamicRunSet);
        }
예제 #44
0
        /// <summary>
        /// 由Xml反序列化(未验证)
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static object FromXml(this string xml, Type type)
        {
            System.IO.StringReader memStream    = new System.IO.StringReader(xml);
            XmlSerializer          deserializer = new XmlSerializer(type);
            object newobj = deserializer.Deserialize(memStream);

            memStream.Close();
            return(newobj);
        }
예제 #45
0
        public static DataSet XmlToDataSet(string theXml)
        {
            DataSet objDataSet = new DataSet();

            System.IO.StringReader reader = new System.IO.StringReader(theXml);
            objDataSet.ReadXml(reader);
            reader.Close();
            return(objDataSet);
        }
예제 #46
0
        private static void LoadEnchants()
        {
            try
            {
                if (File.Exists(_SaveFilePath))
                {
                    string xml = System.IO.File.ReadAllText(_SaveFilePath);
                    xml = xml.Replace("<Slot>Weapon</Slot", "<Slot>MainHand</Slot>");
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List <Enchant>));
                    System.IO.StringReader reader = new System.IO.StringReader(xml);
                    _allEnchants = (List <Enchant>)serializer.Deserialize(reader);
                    reader.Close();
                }
            }
            catch (Exception) { /* should ignore exception if there is a problem with the file */ }
            finally
            {
                if (_allEnchants == null)
                {
                    _allEnchants = new List <Enchant>();
                }
            }

            List <Enchant> defaultEnchants = GetDefaultEnchants();

            for (int defaultEnchantIndex = 0; defaultEnchantIndex < defaultEnchants.Count; defaultEnchantIndex++)
            {
                bool found = false;
                for (int allEnchantIndex = 0; allEnchantIndex < _allEnchants.Count; allEnchantIndex++)
                {
                    if (defaultEnchants[defaultEnchantIndex].Id == _allEnchants[allEnchantIndex].Id &&
                        defaultEnchants[defaultEnchantIndex].Slot == _allEnchants[allEnchantIndex].Slot &&
                        defaultEnchants[defaultEnchantIndex].Name == _allEnchants[allEnchantIndex].Name
                        )
                    {
                        if (defaultEnchants[defaultEnchantIndex].Stats != _allEnchants[allEnchantIndex].Stats)
                        {
                            if (defaultEnchants[defaultEnchantIndex].Stats == null)
                            {
                                _allEnchants.RemoveAt(allEnchantIndex);
                            }
                            else
                            {
                                _allEnchants[allEnchantIndex].Stats = defaultEnchants[defaultEnchantIndex].Stats;
                            }
                        }
                        found = true;
                        break;
                    }
                }
                if (!found && defaultEnchants[defaultEnchantIndex].Stats != null)
                {
                    _allEnchants.Add(defaultEnchants[defaultEnchantIndex]);
                }
            }
        }
예제 #47
0
        /// <summary>
        /// 反序列化xml2T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static T DeSerialize <T>(this string xml)
        {
            System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(T));

            using (System.IO.StringReader sr = new System.IO.StringReader(xml))
            {
                T rtn = (T)ser.Deserialize(sr);
                sr.Close();
                return(rtn);
            }
        }
예제 #48
0
파일: Form1.cs 프로젝트: satoryuta/Csharp
        private void button_Click(object sender, EventArgs e)
        {
            if (sender == button1)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "テキストファイル|*.txt";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    /* StreamReader sr = new StreamReader(ofd.FileName, System.Text.Encoding.Default);
                     * textBox1.Text = sr.ReadToEnd();
                     * sr.Close();*/
                    ReadCsv(ofd);
                }
            }
            else if (sender == button2)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "テキストファイル|*.txt";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    StreamWriter sw = new StreamWriter(sfd.FileName);

                    System.IO.StringReader rs =
                        new System.IO.StringReader(textBox1.Text);

                    int NLcnt = 0;
                    while (rs.Peek() > -1)
                    {
                        var line = rs.ReadLine();

                        if (line.Length == 0)
                        {
                            if (NLcnt == 0)
                            {
                                sw.WriteLine();
                                NLcnt++;
                            }
                        }
                        else
                        {
                            sw.Write(line + ",");
                            NLcnt = 0;
                        }
                    }


                    rs.Close();
                    sw.Close();
                }
            }
        }
예제 #49
0
    /// <summary>Use a textAsset to load datas.</summary>
    /// <param name="textAsset">The textAsset</param>
    /// <param name="root">The root node in the xml. Default is "Datatable"</param>
    /// <returns>List<typeparam name="T"></typeparam></returns>
    public static List<T> LoadFromTextAsset<T>(TextAsset textAsset, string root = "Datatable")
    {
        if (textAsset == null)
        {
            throw new ArgumentNullException("textAsset");
        }

        System.IO.TextReader textStream = null;

        try
        {
            textStream = new System.IO.StringReader(textAsset.text);

            XmlRootAttribute xRoot = new XmlRootAttribute
            {
                ElementName = root
            };

            XmlSerializer serializer = new XmlSerializer(typeof(List<T>), xRoot);
            List<T> data = serializer.Deserialize(textStream) as List<T>;

            textStream.Close();

            return data;
        }
        catch (System.Exception exception)
        {
            Debug.LogError("The database of type '" + typeof(T) + "' failed to load the asset. The following exception was raised:\n " + exception.Message);
        }
        finally
        {
            if (textStream != null)
            {
                textStream.Close();
            }
        }

        return null;
    }
예제 #50
0
        //翻訳後のテキストをリストに格納
        public List <string> TextToArray(string text)
        {
            List <string> list = new List <string>();

            System.IO.StringReader rs = new System.IO.StringReader(text);
            while (rs.Peek() > -1)
            {
                list.Add(rs.ReadLine());
            }
            rs.Close();

            return(list);
        }
예제 #51
0
        /// <summary>
        /// 根据Xml文件的节点路径,返回一个DataSet数据集
        /// </summary>
        /// <param name="XmlPathNode">Xml文件的某个节点</param>
        /// <returns></returns>
        public DataSet GetDs(string XmlPathNode)
        {
            DataSet ds = new DataSet();

            try
            {
                System.IO.StringReader read = new System.IO.StringReader(XmlDoc.SelectSingleNode(XmlPathNode).OuterXml);
                ds.ReadXml(read);   //利用DataSet的ReadXml方法读取StringReader文件流
                read.Close();
            }
            catch
            { }
            return(ds);
        }
예제 #52
0
            static void loadAllPresets()
            {
                presets = new Dictionary <string, LensParams> ();

                TextAsset localStringsAsset = (TextAsset)Resources.Load("lensPresets");

                if (localStringsAsset != null && !string.IsNullOrEmpty(localStringsAsset.text))
                {
                    System.IO.StringReader textStream = new System.IO.StringReader(localStringsAsset.text);
                    string line = null;
                    while ((line = textStream.ReadLine()) != null)
                    {
                        int eqIndex = line.IndexOf("=");
                        if (eqIndex > 0)
                        {
                            string     presetName = line.Substring(0, eqIndex);
                            LensParams lp         = new LensParams();
                            string[]   vals       = line.Substring(eqIndex + 1, line.Length - eqIndex - 1).Split(',');
                            if (vals.Length != 11)
                            {
                                Debug.LogWarning("Invalid number of values for preset " + presetName);
                            }
                            else
                            {
                                lp.screenx = float.Parse(vals[0]);
                                lp.screeny = float.Parse(vals[1]);
                                lp.lensx   = float.Parse(vals[2]);
                                lp.lensy   = float.Parse(vals[3]);
                                lp.scalex  = float.Parse(vals[4]);
                                lp.scaley  = float.Parse(vals[5]);
                                lp.warpx   = float.Parse(vals[6]);
                                lp.warpy   = float.Parse(vals[7]);
                                lp.warpz   = float.Parse(vals[8]);
                                lp.warpw   = float.Parse(vals[9]);
                                lp.chroma  = float.Parse(vals[10]);

                                if (presets.ContainsKey(presetName))
                                {
                                    presets.Remove(presetName);
                                }
                                presets.Add(presetName, lp);
                            }
                        }
                    }

                    textStream.Close();
                }

                //selectPreset (currentPreset);
            }
예제 #53
0
        private void LoadVals(string strXml)
        {
            XmlSerializer s;
            StringReader  sr;

            s  = new XmlSerializer(typeof(COScheduleHour));
            sr = new System.IO.StringReader(strXml);

            oVar = new COScheduleHour();
            oVar = (COScheduleHour)s.Deserialize(sr);

            sr.Close();
            sr = null;
            s  = null;
        }
예제 #54
0
        private void LoadVals(string strXml)
        {
            XmlSerializer s;
            StringReader  sr;

            s  = new XmlSerializer(typeof(COActivityCode));
            sr = new System.IO.StringReader(strXml);

            oVar = new COActivityCode();
            oVar = (COActivityCode)s.Deserialize(sr);

            sr.Close();
            sr = null;
            s  = null;
        }
예제 #55
0
        private void LoadVals(string strXml)
        {
            XmlSerializer s;
            StringReader  sr;

            s  = new XmlSerializer(typeof(COProjectSummarySch));
            sr = new System.IO.StringReader(strXml);

            oVar = new COProjectSummarySch();
            oVar = (COProjectSummarySch)s.Deserialize(sr);

            sr.Close();
            sr = null;
            s  = null;
        }
예제 #56
0
        private void LoadVals(string strXml)
        {
            XmlSerializer s;
            StringReader  sr;

            s  = new XmlSerializer(typeof(COBudgetExpenseSheet));
            sr = new System.IO.StringReader(strXml);

            oVar = new COBudgetExpenseSheet();
            oVar = (COBudgetExpenseSheet)s.Deserialize(sr);

            sr.Close();
            sr = null;
            s  = null;
        }
예제 #57
0
        /// <summary>
        /// 根据Xml文件的节点路径,返回一个DataSet数据集
        /// </summary>
        /// <param name="XmlPathNode">Xml文件的某个节点</param>
        /// <returns></returns>
        public DataSet GetDs(string XmlPathNode)
        {
            DataSet ds = new DataSet();

            try
            {
                System.IO.StringReader read = new System.IO.StringReader(_element.SelectSingleNode(XmlPathNode).OuterXml);
                ds.ReadXml(read); //利用DataSet的ReadXml方法读取StringReader文件流
                //ds.ReadXml(xmlSR, XmlReadMode.InferTypedSchema);
                read.Close();
            }
            catch
            { }
            return(ds);
        }
예제 #58
0
        private void LoadVals(string strXml)
        {
            XmlSerializer s;
            StringReader  sr;

            s  = new XmlSerializer(typeof(COEmployeeDepartment));
            sr = new System.IO.StringReader(strXml);

            oVar = new COEmployeeDepartment();
            oVar = (COEmployeeDepartment)s.Deserialize(sr);

            sr.Close();
            sr = null;
            s  = null;
        }
예제 #59
0
        private void LoadVals(string strXml)
        {
            XmlSerializer s;
            StringReader  sr;

            s  = new XmlSerializer(typeof(CODocumentReleaseType));
            sr = new System.IO.StringReader(strXml);

            oVar = new CODocumentReleaseType();
            oVar = (CODocumentReleaseType)s.Deserialize(sr);

            sr.Close();
            sr = null;
            s  = null;
        }
예제 #60
0
        private void LoadVals(string strXml)
        {
            XmlSerializer s;
            StringReader  sr;

            s  = new XmlSerializer(typeof(COTransmittalTypes));
            sr = new System.IO.StringReader(strXml);

            oVar = new COTransmittalTypes();
            oVar = (COTransmittalTypes)s.Deserialize(sr);

            sr.Close();
            sr = null;
            s  = null;
        }