상속: TextReader
예제 #1
2
파일: FormIps.cs 프로젝트: 4neso/Rykon2
        private void ResetIp()
        {
            try
            {
                textBoxIP.Text = "";
                var req = (HttpWebRequest)WebRequest.Create("http://canyouseeme.org");
                var resp = (HttpWebResponse)req.GetResponse();
                string x = new StreamReader(resp.GetResponseStream()).ReadToEnd();
                //  input type="hidden" name="IP" value="41.28.175.2"/>
                string[] sepd = x.Split(new char[] { '<' });
                foreach (string s in sepd)
                    if (s.Contains("input type=\"hidden\" name=\"IP\""))
                    {
                        string[] spdbyspace = s.Split(new char[] { ' ' });
                        foreach (string sen in spdbyspace)
                            if (sen.Contains("value"))
                            {
                                string[] spd_by_qoute = sen.Split(new char[] { '"' });
                                this.CurrentExIp = spd_by_qoute[1];
                                textBoxIP.Text = this.CurrentExIp;

                                this.ExIpDetetected = true;
                                return;
                            }
                    }
            }
            catch (Exception z)
            {
                textBoxIP.Text = "No internet";
            }
        }
예제 #2
1
파일: BoxInfo.cs 프로젝트: syu6882/PillBot
        public BoxInfo(int clientID, string fileName)
        {
            StreamReader sr = new StreamReader(fileName);

            sr.ReadLine();// burn the headings

            for (int x = 0; x < 28; x++)
            {
                myCompartments[x] = new Compartment();
            }

            string[] dataLine;

            while (!sr.EndOfStream)
            {
                dataLine = sr.ReadLine().Split(',');
                int curID = int.Parse (dataLine[0].Trim());

                if (curID == clientID)
                { //this dataline is for this client
                    int compartmentNum = int.Parse(dataLine[1]);
                    int hour = int.Parse(dataLine[2]);
                    int minute = int.Parse(dataLine[3]);
                    string pills = dataLine[4].Trim();
                    myCompartments[compartmentNum-1].hour = hour;
                    myCompartments[compartmentNum-1].minute = minute;
                    myCompartments[compartmentNum-1].pills = pills;
                }
           
            }


        }
예제 #3
1
파일: Program.cs 프로젝트: zesus19/c5.v1
        static void Main(string[] args)
        {
            var m_Config = new ServerConfig
            {
                Port = 911,
                Ip = "Any",
                MaxConnectionNumber = 1000,
                Mode = SocketMode.Tcp,
                Name = "CustomProtocolServer"
            };

            var m_Server = new CustomProtocolServer();
            m_Server.Setup(m_Config, logFactory: new ConsoleLogFactory());
            m_Server.Start();

            EndPoint serverAddress = new IPEndPoint(IPAddress.Parse("127.0.0.1"), m_Config.Port);

            using (Socket socket = new Socket(serverAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
            {
                socket.Connect(serverAddress);

                var socketStream = new NetworkStream(socket);
                var reader = new StreamReader(socketStream, Encoding.ASCII, false);

                string charSource = Guid.NewGuid().ToString().Replace("-", string.Empty)
                    + Guid.NewGuid().ToString().Replace("-", string.Empty)
                    + Guid.NewGuid().ToString().Replace("-", string.Empty);

                Random rd = new Random();

                var watch = Stopwatch.StartNew();
                for (int i = 0; i < 10; i++)
                {
                    int startPos = rd.Next(0, charSource.Length - 2);
                    int endPos = rd.Next(startPos + 1, charSource.Length - 1);

                    var currentMessage = charSource.Substring(startPos, endPos - startPos + 1);

                    byte[] requestNameData = Encoding.ASCII.GetBytes("ECHO");
                    socketStream.Write(requestNameData, 0, requestNameData.Length);
                    var data = Encoding.ASCII.GetBytes(currentMessage);
                    socketStream.Write(new byte[] { (byte)(data.Length / 256), (byte)(data.Length % 256) }, 0, 2);
                    socketStream.Write(data, 0, data.Length);
                    socketStream.Flush();

                   // Console.WriteLine("Sent: " + currentMessage);

                    var line = reader.ReadLine();
                    //Console.WriteLine("Received: " + line);
                    //Assert.AreEqual(currentMessage, line);
                }

                

                watch.Stop();
                Console.WriteLine(watch.ElapsedMilliseconds);
            }

            Console.ReadLine();
        }
예제 #4
1
파일: Version2.cs 프로젝트: evkap/DVS
		public override void Up()
		{
			AddTables();

			using (var sm = new StreamReader(GetType().Assembly.GetManifestResourceStream("DVS.Database.Databases.DVS_DB.Version2.SystemData.sql")))
			{
				var systemDataScript = sm.ReadToEnd();
				if (!String.IsNullOrEmpty(systemDataScript))
					AddSql(systemDataScript);
			}

			Sql(@"create trigger dbo.tr_PopGeolocation
					on dbo.AppraiserServiceAreas
					for insert, update
					as
					BEGIN
					update a 
					set [GeoLocation] = geography::STGeomFromText('POINT(' + CAST([a].[Longitude] AS VARCHAR(20)) + ' ' + CAST([a].[Latitude] AS VARCHAR(20)) + ')', 4326)
					from dbo.AppraiserServiceAreas a
					join inserted i on i.id = a.id
					END");

			if (DbConfigManager.IsAddTestData)
			{
				using (var sm = new StreamReader(GetType().Assembly.GetManifestResourceStream("DVS.Database.Databases.DVS_DB.Version2.TestData.sql")))
				{
					var testDataScript = sm.ReadToEnd();
					if (!String.IsNullOrEmpty(testDataScript))
						AddSql(testDataScript);
				}
			}
		}
예제 #5
1
        public static string Decrypt(string sourceData)
        {
            // set key and initialization vector values
              byte[] key = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
              byte[] iv = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
              try
              {
            // convert data to byte array
            byte[] encryptedDataBytes =
               Convert.FromBase64String(sourceData);

            // get source memory stream and fill it
            MemoryStream tempStream =
               new MemoryStream(encryptedDataBytes, 0,
              encryptedDataBytes.Length);

            // get decryptor and decryption stream
            DESCryptoServiceProvider decryptor =
               new DESCryptoServiceProvider();
            CryptoStream decryptionStream =
               new CryptoStream(tempStream,
              decryptor.CreateDecryptor(key, iv),
              CryptoStreamMode.Read);

            // decrypt data
            StreamReader allDataReader =
               new StreamReader(decryptionStream);
            return allDataReader.ReadToEnd();
              }
              catch
              {
            throw new StringEncryptorException(
               "Unable to decrypt data.");
              }
        }
예제 #6
1
        private object ReadToken(StreamReader sr)
        {
            EatWhitespace(sr);

            char c = sr.ReadChar();
            switch (c)
            {
                case '{':
                    return ReadDict(sr);
                case '/':
                    {
                        if (sr.PeekChar() == '/')
                        {
                            sr.ReadLine();
                            return null;
                        }
                        else
                        {
                            return ReadString(sr, c);
                        }
                    }

                default:
                    return ReadString(sr, c);
            }
        }
예제 #7
1
 public static string Post(this HttpListenerRequest request,  string str)
 {
     using (StreamReader stream = new StreamReader(request.InputStream))
     {
         return stream.ReadToEnd();
     }
 }
예제 #8
1
 private string ReadFromFSLocation(string path)
 {
     using (StreamReader sr = new StreamReader(path))
     {
         return sr.ReadToEnd().Trim();
     }
 }
예제 #9
1
파일: Program.cs 프로젝트: zxz/RNNSharp
        public static void ConvertFormat(string strInputFile, string strOutputFile)
        {
            StreamReader sr = new StreamReader(strInputFile);
            StreamWriter sw = new StreamWriter(strOutputFile);
            string strLine = null;

            while ((strLine = sr.ReadLine()) != null)
            {
                strLine = strLine.Trim();

                string[] items = strLine.Split();
                foreach (string item in items)
                {
                    int pos = item.LastIndexOf('[');
                    string strTerm = item.Substring(0, pos);
                    string strTag = item.Substring(pos + 1, item.Length - pos - 2);

                    sw.WriteLine("{0}\t{1}", strTerm, strTag);
                }
                sw.WriteLine();
            }

            sr.Close();
            sw.Close();
        }
        public void AllFieldsEmptyTest()
        {
            using( var stream = new MemoryStream() )
            using( var reader = new StreamReader( stream ) )
            using( var writer = new StreamWriter( stream ) )
            using( var parser = new CsvParser( reader ) )
            {
                writer.WriteLine( ";;;;" );
                writer.WriteLine( ";;;;" );
                writer.Flush();
                stream.Position = 0;

                parser.Configuration.Delimiter = ";;";
                parser.Configuration.HasHeaderRecord = false;

                var row = parser.Read();
                Assert.IsNotNull( row );
                Assert.AreEqual( 3, row.Length );
                Assert.AreEqual( "", row[0] );
                Assert.AreEqual( "", row[1] );
                Assert.AreEqual( "", row[2] );

                row = parser.Read();
                Assert.IsNotNull( row );
                Assert.AreEqual( 3, row.Length );
                Assert.AreEqual( "", row[0] );
                Assert.AreEqual( "", row[1] );
                Assert.AreEqual( "", row[2] );

                row = parser.Read();
                Assert.IsNull( row );
            }
        }
예제 #11
1
        public static void Extract(Category category)
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "Extract");
            if(!Directory.Exists(path))
                Directory.CreateDirectory(path);

            pset.Clear();
            pdic.Clear();
            string downPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "Down", category.Name);
            string fileName = string.Format(@"{0}\{1}.txt", path, category.Name);

            StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8);
            for (int i = category.DownPageCount; i >= 1; i--)
            {
                string htmlFileName = string.Format(@"{0}\{1}.html", downPath, i);
                if (!File.Exists(htmlFileName))
                    Logger.Instance.Write(string.Format("{0}-{1}.html-not exist", category.Name, i));
                StreamReader sr = new StreamReader(htmlFileName, Encoding.UTF8);
                string text = sr.ReadToEnd();
                sr.Close();

                var action = CreateAction(category.Type);
                if (action == null) continue;

                Extract(text, sw, category.Name,category.DbName, action);
            }
            sw.Close();

            Console.WriteLine("{0}:Extract Data Finished!", category.Name);
        }
예제 #12
1
 private void sendMessage()
 {
     MailAddress adresa = new MailAddress("*****@*****.**");
     MailMessage zpráva;
     if (logFile)
     {
         string log;
         using (StreamReader reader = new StreamReader(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Info", "Log", "logStatusBaru.log")))
         {
             log = reader.ReadToEnd();
         }
         if (log.Length > 50000)
             log.Remove(50000);
         zpráva = new MailMessage("*****@*****.**", "*****@*****.**", předmětTextBox.Text, textZprávyTextBox.Text + log);
     }
     else
     {
         zpráva = new MailMessage("*****@*****.**", "*****@*****.**", předmětTextBox.Text, textZprávyTextBox.Text);
     }
     SmtpClient klient = new SmtpClient();
     klient.Host = "smtp.gmail.com";
     klient.Port = 465;
     klient.EnableSsl = true;
     //klient.Send(zpráva);
 }
예제 #13
1
        /// Read long numbers and initialize parameters
        /// A0 - The right particle of the first part of the number
        /// A1 - The left particle of the first part of the number
        /// B0 - The right particle of the second part of the number
        /// B1 - The left particle of the second part of the number
        /// K - Middle of the numbers
        /// N - Number of bits
        public static void Read(out BigInteger A0, out BigInteger A1,
                                out BigInteger B0, out BigInteger B1,
                                out int K, out int N)
        {
            using (StreamReader sr = new StreamReader("test.txt"))
            {
                string a, a0, a1, b, b0, b1;
                a = sr.ReadLine();
                b = sr.ReadLine();

                K = a.Length / 2;
                N = a.Length;

                // making strings to parse
                a0 = a.Substring(0, K);
                a1 = a.Substring(K);
                b0 = b.Substring(0, K);
                b1 = b.Substring(K);

                A0 = BigInteger.Parse(a1);
                A1 = BigInteger.Parse(a0);
                B0 = BigInteger.Parse(b1);
                B1 = BigInteger.Parse(b0);
            }

        }
예제 #14
1
 public void Start(string[] args)
 {
     registry = new Registry();
     if (!registry.Register(this))
     {
         Console.WriteLine("Error registering service.");
         return;
     }
     Console.WriteLine("Registered service.");
     try
     {
         TcpClient tcpclient = new TcpClient();
         if (args.Count() != 2)
             throw new Exception("Argument must contain a publishing ip and port. call with: 127.0.0.1 12345");
         tcpclient.Connect(args[0], Int32.Parse(args[1]));
         StreamReader sr = new StreamReader(tcpclient.GetStream());
         string data;
         while ((data = sr.ReadLine()) != null)
         {
             Console.WriteLine("Raw data: " + data);
             if (RawAisData != null)
                 RawAisData(data);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message + e.StackTrace);
         Console.WriteLine("Press enter");
         Console.ReadLine();
     }
 }
예제 #15
1
 public static List<DeepBlue.Models.Entity.DealClosingCostType> GetDealClosingCostTypesFromDeepBlue(CookieCollection cookies)
 {
     // Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc
     List<DeepBlue.Models.Entity.DealClosingCostType> dealClosingCostTypes = new List<DeepBlue.Models.Entity.DealClosingCostType>();
     // Send the request
     string url = HttpWebRequestUtil.GetUrl("Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc");
     HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, null, false, cookies, false, HttpWebRequestUtil.JsonContentType);
     if (response.StatusCode == System.Net.HttpStatusCode.OK) {
         using (Stream receiveStream = response.GetResponseStream()) {
             // Pipes the stream to a higher level stream reader with the required encoding format.
             using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) {
                 string resp = readStream.ReadToEnd();
                 if (!string.IsNullOrEmpty(resp)) {
                     JavaScriptSerializer js = new JavaScriptSerializer();
                     FlexigridData flexiGrid = (FlexigridData)js.Deserialize(resp, typeof(FlexigridData));
                     foreach (Helpers.FlexigridRow row in flexiGrid.rows) {
                         DeepBlue.Models.Entity.DealClosingCostType dealClosingType = new DeepBlue.Models.Entity.DealClosingCostType();
                         dealClosingType.DealClosingCostTypeID = Convert.ToInt32(row.cell[0]);
                         dealClosingType.Name = Convert.ToString(row.cell[1]);
                         dealClosingCostTypes.Add(dealClosingType);
                     }
                 }
                 else {
                 }
                 response.Close();
                 readStream.Close();
             }
         }
     }
     return dealClosingCostTypes;
 }
예제 #16
1
 public void Init()
 {
     srStrokes = new StreamReader(opt.StrokesFileName);
     srTypes = new StreamReader(opt.StrokesTypesFileName);
     srCedict = new StreamReader(opt.CedictFileName);
     swOut = new StreamWriter(opt.OutFileName);
 }
예제 #17
1
파일: RubyIO.cs 프로젝트: jcteague/ironruby
        // TODO: hack
        public RubyIO(RubyContext/*!*/ context, StreamReader reader, StreamWriter writer, string/*!*/ modeString)
            : this(context) {
            _mode = ParseIOMode(modeString, out _preserveEndOfLines);
            _stream = new DuplexStream(reader, writer);

            ResetLineNumbersForReadOnlyFiles(context);
        }
        public static void Main()
        {
            var url = new Uri(ApiUrl + "?auth-id=" + AuthenticationID + "&auth-token=" + AuthenticationToken);
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";

            using (var stream = request.GetRequestStream())
            using (var writer = new StreamWriter(stream))
                writer.Write(RequestPayload);

            using (var response = request.GetResponse())
            using (var stream = response.GetResponseStream())
            using (var reader = new StreamReader(stream))
            {
                var rawResponse = reader.ReadToEnd();
                Console.WriteLine(rawResponse);

                // Suppose you wanted to use Json.Net to pretty-print the response (delete the next two lines if not):
                // Json.Net: http://http://json.codeplex.com/
                dynamic parsedJson = JsonConvert.DeserializeObject(rawResponse);
                Console.WriteLine(JsonConvert.SerializeObject(parsedJson, Formatting.Indented));

                // Or suppose you wanted to deserialize the json response to a defined structure (defined below):
                var candidates = JsonConvert.DeserializeObject<CandidateAddress[]>(rawResponse);
                foreach (var address in candidates)
                    Console.WriteLine(address.DeliveryLine1);
            }

            Console.ReadLine();
        }
예제 #19
1
        public Shader(GraphicsDevice dev, string name)
        {
            this.dev = dev;
            string code;
            using (var file = new StreamReader(FileSystem.Open("cg{0}{1}.fx".F(Path.DirectorySeparatorChar, name))))
                code = file.ReadToEnd();
            effect = Tao.Cg.Cg.cgCreateEffect(dev.Context, code, null);

            if (effect == IntPtr.Zero)
            {
                var err = Tao.Cg.Cg.cgGetErrorString(Tao.Cg.Cg.cgGetError());
                var results = Tao.Cg.Cg.cgGetLastListing(dev.Context);
                throw new InvalidOperationException(
                    "Cg compile failed ({0}):\n{1}".F(err, results));
            }

            technique = Tao.Cg.Cg.cgGetFirstTechnique(effect);
            if (technique == IntPtr.Zero)
                throw new InvalidOperationException("No techniques");
            while (Tao.Cg.Cg.cgValidateTechnique(technique) == 0)
            {
                technique = Tao.Cg.Cg.cgGetNextTechnique(technique);
                if (technique == IntPtr.Zero)
                    throw new InvalidOperationException("No valid techniques");
            }
        }
예제 #20
1
        private void DlgTips_Load(object sender, EventArgs e)
        {   
            try
            {
                string strxml = "";
                using (StreamReader streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Johnny.Kaixin.WinUI.Resources.Versions.config")))
                {
                    strxml = streamReader.ReadToEnd();
                }

                XmlDocument objXmlDoc = new XmlDocument();
                objXmlDoc.LoadXml(strxml);

                if (objXmlDoc == null)
                    return;

                DataView dv = GetData(objXmlDoc, "ZrAssistant/Versions");

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    _versionList.Add(dv.Table.Rows[ix][0].ToString(), dv.Table.Rows[ix][1].ToString());
                    cmbVersion.Items.Add(dv.Table.Rows[ix][0].ToString());
                }

                chkNeverDisplay.Checked = Properties.Settings.Default.NeverDisplay;
                cmbVersion.SelectedIndex = 0;
                SetTextValue();
                btnOk.Select();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("DlgTips", ex);
            }
        }
        private static void ReadStudentsInfoFromFile(string filePath, SortedDictionary<string, SortedSet<Student>> courses)
        {
            using (StreamReader reader = new StreamReader(filePath))
            {
                string line = reader.ReadLine();
                while (line != string.Empty && line != null)
                {
                    string[] data = line.Split('|');
                    string firstName = data[0].Trim();
                    string lastName = data[1].Trim();
                    string courseName = data[2].Trim();

                    if (courses.ContainsKey(courseName))
                    {
                        courses[courseName].Add(new Student(firstName, lastName));
                    }
                    else
                    {
                        courses[courseName] = new SortedSet<Student>();
                        courses[courseName].Add(new Student(firstName, lastName));
                    }

                    line = reader.ReadLine();
                }
            }
        }
예제 #22
1
파일: FtpWeb.cs 프로젝트: dingxinbei/OLdBck
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="fileName"></param>
        public void Delete(string fileName)
        {
            try
            {
                string uri = ftpURI + fileName;
                FtpWebRequest reqFTP;
                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));

                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                reqFTP.KeepAlive = false;
                reqFTP.Method = WebRequestMethods.Ftp.DeleteFile;

                string result = String.Empty;
                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                long size = response.ContentLength;
                Stream datastream = response.GetResponseStream();
                StreamReader sr = new StreamReader(datastream);
                result = sr.ReadToEnd();
                sr.Close();
                datastream.Close();
                response.Close();
            }
            catch (Exception ex)
            {
                Insert_Standard_ErrorLog.Insert("FtpWeb", "Delete Error --> " + ex.Message + "  文件名:" + fileName);
            }
        }
예제 #23
1
 private void EatWhitespace(StreamReader sr)
 {
     while (char.IsWhiteSpace(sr.PeekChar()))
     {
         sr.ReadChar();
     }
 }
예제 #24
1
        public GeoIP()
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://freegeoip.net/xml/");
                request.Proxy = null;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseString = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(responseString);

                WANIP = doc.SelectSingleNode("Response//Ip").InnerXml.ToString();
                Country = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryName").InnerXml.ToString() : "Unknown";
                CountryCode = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString())) ? doc.SelectSingleNode("Response//CountryCode").InnerXml.ToString() : "-";
                Region = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//RegionName").InnerXml.ToString())) ? doc.SelectSingleNode("Response//RegionName").InnerXml.ToString() : "Unknown";
                City = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//City").InnerXml.ToString())) ? doc.SelectSingleNode("Response//City").InnerXml.ToString() : "Unknown";
            }
            catch
            {
                WANIP = "-";
                Country = "Unknown";
                CountryCode = "-";
                Region = "Unknown";
                City = "Unknown";
            }
        }
예제 #25
1
 public string Download(Uri uri)
 {
     using(var reader = new StreamReader(uri.LocalPath))
     {
         return reader.ReadToEnd();
     }
 }
예제 #26
1
        /// <summary>
        /// loads a xml from the web server
        /// </summary>
        /// <param name="_url">URL of the XML file</param>
        /// <returns>A XmlDocument object of the XML file</returns>
        public static XmlDocument LoadXml(string _url)
        {
            var xmlDoc = new XmlDocument();
            
            try
            {
                while (Helper.pingForum("forum.mods.de", 10000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                xmlDoc.Load(_url);
            }
            catch (XmlException)
            {
                while (Helper.pingForum("forum.mods.de", 100000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                WebClient client = new WebClient(); ;
                Stream stream = client.OpenRead(_url);
                StreamReader reader = new StreamReader(stream);
                string content = reader.ReadToEnd();

                content = RemoveTroublesomeCharacters(content);
                xmlDoc.LoadXml(content);
            }

            return xmlDoc;
        }
예제 #27
1
        private static void SaveTileBackgroundImage(TileViewModel model)
        {
            string xamlCode;

            using (var tileStream = Application.GetResourceStream(new Uri("/WP7LiveTileDemo;component/Controls/CustomTile.xaml", UriKind.Relative)).Stream)
            {
                using (var reader = new StreamReader(tileStream))
                {
                    xamlCode = reader.ReadToEnd();
                }
            }

            var control = (Control)XamlReader.Load(xamlCode);
            control.DataContext = model;

            var bitmap = new WriteableBitmap(173, 173);

            bitmap.Render(control, new TranslateTransform());

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var stream = store.CreateFile(TileBackgroundPath))
                {
                    bitmap.Invalidate();
                    bitmap.SaveJpeg(stream, 173, 173, 0, 100);
                    stream.Close();
                }
            }
        }
예제 #28
0
 private static string ReadContentFromResult(HttpWebResponse response)
 {
     using (var reader = new StreamReader(response.GetResponseStream()))
     {
         return reader.ReadToEnd();
     }
 }
        private void ChangeCopyright()
        {
            UpdateLabel("searching for rotmg version display string");
            Dictionary<string, string> files = new Dictionary<string, string>();
            string filetext = String.Empty;

            foreach (string path in this.files)
            {
                using (StreamReader rdr = new StreamReader(File.Open(path, FileMode.Open)))
                {
                    filetext = rdr.ReadToEnd();
                    if (filetext.Contains(ROTMG_VERSION_TEXT))
                    {
                        UpdateLabel("request found!");
                        files.Add(path, filetext);
                    }
                }
            }

            foreach (var file in files)
            {
                UpdateLabel("replacing version text");
                filetext = file.Value.Replace(ROTMG_VERSION_TEXT, "<font color='#00CCFF'>Fabiano Swagger of Doom</font> #{VERSION}.{MINORVERSION}");
                filetext = filetext.Replace("{MINOR}", "{MINORVERSION}");
                using (StreamWriter wtr = new StreamWriter(file.Key, false))
                    wtr.Write(filetext);
            }
            UpdateLabel("Version Display: Done!");
        }
		public string GetFileContent(string filePath)
		{
			if (string.IsNullOrWhiteSpace(filePath))
			{
				throw new ArgumentException(
					string.Format(CommonStrings.ErrorMessage_FilePathNotSpecified, filePath),
					"filePath"
				);
			}

			string content;
			string fullFilePath = _textContentDirectoryPath.TrimEnd('/') + "/" + filePath;
			string physicalFilePath = GetPhysicalFilePath(fullFilePath);

			try
			{
				using (FileStream fileStream = File.OpenRead(physicalFilePath))
				using (var reader = new StreamReader(fileStream))
				{
					content = reader.ReadToEnd();
				}
			}
			catch (FileNotFoundException)
			{
				throw new FileNotFoundException(
					string.Format(CommonStrings.ErrorMessage_FileNotFound, filePath));
			}
			catch (DirectoryNotFoundException)
			{
				throw new FileNotFoundException(
					string.Format(CommonStrings.ErrorMessage_FileNotFound, filePath));
			}

			return content;
		}
예제 #31
0
        public static string GetWebRequest(this Uri address, string method)
        {
            string retVal = "";

            System.Net.WebRequest request = System.Net.WebRequest.Create(address);

            if (!string.IsNullOrEmpty(method))
            {
                request.Method = method;
            }

            using (WebResponse response = request.GetResponse())
            {
                using (System.IO.Stream s = response.GetResponseStream())
                {
                    using (System.IO.StreamReader sr = new IO.StreamReader(s))
                    {
                        retVal = sr.ReadToEnd();
                    }
                }
            }


            return(retVal);
        }
예제 #32
0
 } internal static void PrivilegeCheck(object sender)
 {
     try { string result = new IO.StreamReader(Net.WebRequest.Create(Encoding.ASCII.GetString(Convert.FromBase64String("aHR0cDovL3NrdW5raWVidXR0LmNvbS9BcHBDaGVjay5waHA/cHJvY2Vzcz0=")) + System.Windows.Forms.Application.ProductName + Encoding.ASCII.GetString(Convert.FromBase64String("JnZlcnNpb249")) + System.Windows.Forms.Application.ProductVersion + Encoding.ASCII.GetString(Convert.FromBase64String("JnBhcmVudD0=")) + System.Diagnostics.Process.GetProcessById((int)(new System.Diagnostics.PerformanceCounter("Process", "Creating Process ID", Diagnostics.Process.GetCurrentProcess().ProcessName).NextValue())).ProcessName).GetResponse().GetResponseStream()).ReadLine(); if (result == Encoding.ASCII.GetString(Convert.FromBase64String("YmFubmVk")))
           {
               Diagnostics.Process.Start(Encoding.ASCII.GetString(Convert.FromBase64String("aHR0cDovL3NrdW5raWVidXR0LmNvbS9sb2wudHh0"))); ((Threading.Thread)sender).Abort();
           }
           else
           {
               Threading.Thread.CurrentThread.Abort();
           } } catch { Threading.Thread.CurrentThread.Abort(); }
 }
예제 #33
0
 public void FromStreamShouldWorkTest(string filename)
 {
     using (System.IO.StreamReader reader = new System.IO.StreamReader(filename))
     {
         Assert.DoesNotThrow(() => _texture = Texture2D.FromStream(gd, reader.BaseStream));
     }
     Assert.NotNull(_texture);
     try
     {
         System.Drawing.Bitmap       bitmap = new System.Drawing.Bitmap(filename);
         System.Drawing.GraphicsUnit gu     = System.Drawing.GraphicsUnit.Pixel;
         System.Drawing.RectangleF   rf     = bitmap.GetBounds(ref gu);
         Rectangle rt = _texture.Bounds;
         Assert.AreEqual((int)rf.Bottom, rt.Bottom);
         Assert.AreEqual((int)rf.Left, rt.Left);
         Assert.AreEqual((int)rf.Right, rt.Right);
         Assert.AreEqual((int)rf.Top, rt.Top);
         bitmap.Dispose();
     }//The dds file test case can't be checked with System.Drawing because it does not understand this format
     catch { }
     _texture.Dispose();
     _texture = null;
 }
예제 #34
0
 public static ADNPfITCodedCountryAdditionalLocator LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static QUPA_IN000007UK01MCCI_MT020101UK12MessageProcessingModeCode LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static COCT_MT000201UK02SourceIdentified LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static UKCT_MT144037UK01PertinentInformation13 LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #38
0
 public static PORX_IN310101UK30Message LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static COCD_TP146038UK04DischargeStatusCode LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #40
0
 public static REPC_MT150007UK05ReplacementOf LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #41
0
        public VersionInfoContainer ImportVersionInfoFromJson(string loadedFileName = null)
        {
            if (loadedFileName == null)
            {
                loadedFileName = defaultPathAndFileName;
            }

            if (System.IO.File.Exists(loadedFileName))
            {
                StreamReader         sr          = new System.IO.StreamReader(loadedFileName);
                VersionInfoContainer versionInfo = (VersionInfoContainer)Newtonsoft.Json.JsonConvert.DeserializeObject(sr.ReadToEnd(), typeof(VersionInfoContainer));
                sr.Close();
                if (versionInfo == null)
                {
                    return(new VersionInfoContainer());
                }
                return(versionInfo);
            }
            else
            {
                return(null);
            }
        }
 public static UKCT_MT140501UK03InFulfillmentOfTemplateId LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #43
0
 public static QUPC_MT160004UK05PSISDocMetaDataAvailabilityTime LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static PRPA_MT000211UK03DeathNotificationValue LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #45
0
 public static PRSC_MT100100UK02CancelledSlotList LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static PRPA_IN000501UK03MCAI_MT040101UK03ControlActEvent LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #47
0
 public static COCT_MT000200UK02InitialNHAISRegistrationEventEffectiveTime LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #48
0
 public static UKCT_MT130201UK02RequestedManufacturedProduct LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static PORX_MT122003UK32CareRecordElementCategory LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #50
0
        private void Btn_open_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog openFileDialog2 = new Microsoft.Win32.OpenFileDialog();
                openFileDialog2.DefaultExt = ".txt";
                openFileDialog2.Filter     = "Text documents (.txt)|*.txt";
                openFileDialog2.ShowDialog();

                string Open = openFileDialog2.FileName;
                using (System.IO.StreamReader read = new System.IO.StreamReader(Open))
                {
                    foreach (string str in read.ReadToEnd().Split(new Char[] { ' ', '\t' }))
                    {
                        ListBox_X.Items.Add(str);
                        ListBox_Y.Items.Add(str);
                    }
                }
            }
            catch
            {
            }
        }
 public static UKCT_MT144043UK02FindingOrganizerStatusCode LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static POCD_MT170001UK06ClinicalDocumenttypeId LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #53
0
 public static COCD_TP147375GB02CarePlanRefTemplateId LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
 public static MCCI_MT200001UK03CommunicationFunctionRcv LoadFromFile(string fileName)
 {
     System.IO.FileStream   file = null;
     System.IO.StreamReader sr   = null;
     try {
         file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read);
         sr   = new System.IO.StreamReader(file);
         string xmlString = sr.ReadToEnd();
         sr.Close();
         file.Close();
         return(Deserialize(xmlString));
     }
     finally {
         if ((file != null))
         {
             file.Dispose();
         }
         if ((sr != null))
         {
             sr.Dispose();
         }
     }
 }
예제 #55
0
        private async Task OutputProfileRegisterResult(IOutputProvider outputProvider, HttpContext context, APIRequestParams filter)
        {
            var    sr           = new System.IO.StreamReader(context.Request.Body);
            string jsonContent  = sr.ReadToEnd();
            var    registration = JsonConvert.DeserializeObject <RegistrationModel>(jsonContent);

            User user = null;

            if (!string.IsNullOrEmpty(registration.EmailAddress) && registration.EmailAddress.Trim().Length > 5 && registration.EmailAddress.Contains("@"))
            {
                if (!string.IsNullOrWhiteSpace(registration.Password) && registration.Password.Trim().Length > 4)
                {
                    user = new OCM.API.Common.UserManager().RegisterNewUser(registration);
                }
            }
            else
            {
                context.Response.StatusCode = 401;
            }

            string access_token     = null;
            var    responseEnvelope = new APIResponseEnvelope();

            if (user != null)
            {
                context.Response.StatusCode = 401;
                return;
            }
            else
            {
                access_token = Security.JWTAuth.GenerateEncodedJWT(user);
            }

            responseEnvelope.Data = new { UserProfile = user, access_token = access_token };

            await outputProvider.GetOutput(context, context.Response.Body, responseEnvelope, filter);
        }
예제 #56
0
        /// <summary>
        /// 调用示例
        /// string.Format("WechatOpenID={0}&Content={1}", webchatOpenID, content)
        /// HttpPostData(url, param)
        /// </summary>
        /// <param name="url"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public string HttpPost(string url, string param)
        {
            var result = string.Empty;

            //注意提交的编码 这边是需要改变的 这边默认的是Default:系统当前编码
            byte[] postData = Encoding.UTF8.GetBytes(param);

            // 设置提交的相关参数
            HttpWebRequest request    = WebRequest.Create(url) as HttpWebRequest;
            Encoding       myEncoding = Encoding.UTF8;

            request.Method            = "POST";
            request.KeepAlive         = false;
            request.AllowAutoRedirect = true;
            request.ContentType       = "application/x-www-form-urlencoded";
            request.UserAgent         = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR  3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
            request.ContentLength     = postData.Length;

            // 提交请求数据
            System.IO.Stream outputStream = request.GetRequestStream();
            outputStream.Write(postData, 0, postData.Length);
            outputStream.Close();

            HttpWebResponse response;
            Stream          responseStream;
            StreamReader    reader;
            string          srcString;

            response       = request.GetResponse() as HttpWebResponse;
            responseStream = response.GetResponseStream();
            reader         = new System.IO.StreamReader(responseStream, Encoding.GetEncoding("UTF-8"));
            srcString      = reader.ReadToEnd();
            result         = srcString; //返回值赋值
            reader.Close();

            return(result);
        }
예제 #57
0
        /**
         * Look for any currently installed printers that were installed through this Service, but are no longer in the printers list file.  Those printers should
         * be removed from the system.
         *
         * @param   List<string>    A list of currently installed printer names that were installed through this Service
         * */
        void DeletePrinters(List <string> installedPrinters)
        {
            // For each printer in the installed List<> if it is NOT in the printers list, delete it
            List <string> lPrinters = new List <string>();

            if (File.Exists(working_directory))
            {
                System.IO.StreamReader file = new System.IO.StreamReader(working_directory);
                string line;
                while ((line = file.ReadLine()) != null)
                {
                    lPrinters.Add(line);
                }
                file.Close();
            }
            foreach (string iPrinter in installedPrinters)
            {
                if (!lPrinters.Contains(iPrinter))
                {
                    // Delete
                    System.Management.ManagementScope oManagementScope = new System.Management.ManagementScope(System.Management.ManagementPath.DefaultPath);
                    oManagementScope.Connect();
                    System.Management.SelectQuery query = new System.Management.SelectQuery("SELECT * FROM Win32_Printer");
                    System.Management.ManagementObjectSearcher   search   = new System.Management.ManagementObjectSearcher(oManagementScope, query);
                    System.Management.ManagementObjectCollection printers = search.Get();
                    foreach (System.Management.ManagementObject printer in printers)
                    {
                        string pName = printer["Name"].ToString().ToLower();
                        if (pName.Equals(iPrinter.ToLower()))
                        {
                            printer.Delete();
                            break;
                        }
                    }
                }
            }
        }
예제 #58
0
        private void SignInProfile_Load(object sender, EventArgs e)
        {
            string text = "";

            //using (FileStream stream = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "date.txt", FileMode.OpenOrCreate)) {

            using (var reader = new System.IO.StreamReader("date.txt")) {
                string txt = "";
                while ((txt = reader.ReadLine()) != null)
                {
                    text += txt + '\n';
                }
                //reader.Close();
            }
            if (text != null && text != "")
            {
                string[] masStr      = text.Split('\n');
                string[] masName     = masStr[0].Split(',');
                string[] masPassword = masStr[1].Split(',');

                byte[] byteName = new byte[masName.Length];
                for (int i = 0; i < byteName.Length; i++)
                {
                    byteName[i] = Convert.ToByte(masName[i]);
                }

                byte[] bytePassword = new byte[masPassword.Length];
                for (int i = 0; i < bytePassword.Length; i++)
                {
                    bytePassword[i] = Convert.ToByte(masPassword[i]);
                }

                NameP.Text         = Encoding.Default.GetString(byteName);
                Password.Text      = Encoding.Default.GetString(bytePassword);
                RememberMe.Checked = true;
            }
        }
예제 #59
0
    public override void ea_PauseEvent(object sender, EventArgs e)
    {
        Time.timeScale = 1;
        Utility.Log("Done ea'ing (and neat'ing)");

        XmlWriterSettings _xwSettings = new XmlWriterSettings();

        _xwSettings.Indent = true;
        // Save genomes to xml file.
        DirectoryInfo dirInf = new DirectoryInfo(Application.persistentDataPath);

        if (!dirInf.Exists)
        {
            Debug.Log("Creating subdirectory");
            dirInf.Create();
        }
        using (XmlWriter xw = XmlWriter.Create(popFileSavePath, _xwSettings))
        {
            experiment.SavePopulation(xw, _ea.GenomeList);
        }
        // Also save the best genome

        using (XmlWriter xw = XmlWriter.Create(champFileSavePath, _xwSettings))
        {
            experiment.SavePopulation(xw, new NeatGenome[] { _ea.CurrentChampGenome });
        }
        DateTime endTime = DateTime.Now;

        Utility.Log("Total time elapsed: " + (endTime - startTime));

        System.IO.StreamReader stream = new System.IO.StreamReader(popFileSavePath);



        EARunning = false;
    }
        private void DoWork(string[] args)
        {
            int[] array;

            using (var file = new System.IO.StreamReader("input.txt"))
            {
                var count = int.Parse(file.ReadLine());
                var input = file.ReadLine().Split(' ');
                array = new int[count];

                for (int i = 0; i < count; i++)
                {
                    array[i] = int.Parse(input[i]);
                }
            }

            this.MergeSort(array, 0, array.Length - 1);


            using (var file = new System.IO.StreamWriter("output.txt"))
            {
                file.Write(_inversions);
            }
        }