Witam, czy jest możliwość, by przekonwertować projekt VS 2012 na VB 2010? albo jak "przetłumaczyć" ten kod na VB2010?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using System.IO;
using System.Windows.Forms;
namespace AstroCash
{
public class Api
{
public string Login { get; set; }
private CookieContainer _ciastka;
private string _lastSrc;
public Earnings Zarobki { get; set; }
public Api(string login)
{
_ciastka = new CookieContainer();
Zarobki = new Earnings();
Login = login;
Zarobki.Today = -1;
}
public bool Zaloguj(string login, string haslo)
{
try
{
var request = WebRequest.Create("http://astrocash.org/login") as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Referer = "http://astrocash.org/";
request.UserAgent = "AstroCash App by Miszczu";
request.CookieContainer = _ciastka;
using (var sw = request.GetRequestStream())
{
byte[] buffer = Encoding.UTF8.GetBytes(string.Format("login={0}&password={1}", login, haslo));
sw.Write(buffer, 0, buffer.Length);
}
using (var response = request.GetResponse() as HttpWebResponse)
{
_ciastka.Add(response.Cookies);
using (var sr = new StreamReader(response.GetResponseStream()))
{
_lastSrc = sr.ReadToEnd();
return !_lastSrc.Contains("Forgotten password");
}
}
}
catch (Exception)
{
return false;
}
}
public void AktualizujDane()
{
var request = WebRequest.Create("http://astrocash.org/") as HttpWebRequest;
request.Method = "GET";
request.CookieContainer = _ciastka;
using (var response = request.GetResponse() as HttpWebResponse)
{
_ciastka.Add(response.Cookies);
using (var sr = new StreamReader(response.GetResponseStream()))
_lastSrc = sr.ReadToEnd();
}
var cop = _lastSrc;
var match = Regex.Match(cop, "<div id=\"earn1\">(.*?)</div>", RegexOptions.IgnoreCase);
string success = string.Empty;
if (match.Success)
{
double ost = Zarobki.Today;
Zarobki.Today = Convert.ToDouble(match.Groups[1].Value.Replace("$", ""),
System.Globalization.CultureInfo.InvariantCulture);
if (ost != -1)
{
double roz = Zarobki.Today - ost;
if (roz > 0)
new ToolTip("Zwiększenie salda", string.Format("Stan Twojego konta zwiększył się z ${0:0.00} na ${1:0.00} (${2:0.00})",
ost, Zarobki.Today, roz)).ShowDialog();
}
}
match = Regex.Match(cop, "<div id=\"earn2\">(.*?)</div>", RegexOptions.IgnoreCase);
if (match.Success)
Zarobki.Yesterday = Convert.ToDouble(match.Groups[1].Value.Replace("$", ""), System.Globalization.CultureInfo.InvariantCulture);
match = Regex.Match(cop, "<div id=\"earn3\">(.*?)</div>", RegexOptions.IgnoreCase);
if (match.Success)
Zarobki.Month = Convert.ToDouble(match.Groups[1].Value.Replace("$", ""), System.Globalization.CultureInfo.InvariantCulture);
match = Regex.Match(cop, "<div id=\"earn4\">(.*?)</div>", RegexOptions.IgnoreCase);
if (match.Success)
Zarobki.Total = Convert.ToDouble(match.Groups[1].Value.Replace("$", ""), System.Globalization.CultureInfo.InvariantCulture);
match = Regex.Match(cop, "<div id=\"earn5\">(.*?)</div>", RegexOptions.IgnoreCase);
if (match.Success)
Zarobki.Payout = Convert.ToDouble(match.Groups[1].Value.Replace("$", ""), System.Globalization.CultureInfo.InvariantCulture);
}
}
public class Earnings
{
public double Today { get; set; }
public double Yesterday { get; set; }
public double Month { get; set; }
public double Total { get; set; }
public double Payout { get; set; }
}
}