本文整理汇总了C#中Parameters.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Parameters.ToString方法的具体用法?C# Parameters.ToString怎么用?C# Parameters.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameters
的用法示例。
在下文中一共展示了Parameters.ToString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <summary>
/// Runs the specified parameters.
/// </summary>
/// <param name="commandType">Type of the command.</param>
/// <param name="parameters">The parameters.</param>
/// <returns></returns>
public int Run(Type commandType, Parameters parameters)
{
// Assign current parameters
Parameters.SetCurrent(parameters.ToString());
var command = (ICommand)Activator.CreateInstance(commandType);
command.BindParameters(parameters);
return command.Execute();
}
示例2: SetParameter
public void SetParameter(string name, object value)
{
var target = new Parameters();
var property = typeof (Parameters).GetProperties()
.First(p => string.Equals(p.Name, name, StringComparison.InvariantCultureIgnoreCase));
property.SetValue(target, value, null);
var expected = string.Format(" /{0}:{1}", name, value);
target.ToString().Should().Be(expected);
}
示例3: Login
/// <summary>
/// 登录操作
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="captcha"></param>
/// <param name="captchaID"></param>
/// <param name="remember"></param>
public Models.LoginResult Login(string userName, string password, string captcha, string captchaID, bool remember)
{
Parameters parameters = new Parameters();
parameters["source"] = "radio";
parameters["alias"] = userName;
parameters["form_password"] = password;
parameters["captcha_solution"] = captcha;
parameters["captcha_id"] = captchaID;
parameters["remember"] = "on";
string json = new ConnectionBase().Post("http://douban.fm/j/login", Encoding.UTF8.GetBytes(parameters.ToString()));
var result = Framework.Common.Helpers.JsonHelper.Deserialize<Models.LoginResult>(json);
return result;
}
示例4: loginButton_MouseLeftButtonDown
/// <summary>
/// 用户登陆
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void loginButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (string.IsNullOrEmpty(userName.Text.Trim()))
errorMessage.Content = "用户名不能为空";
else if (string.IsNullOrEmpty(userPassword.Password.Trim()))
errorMessage.Content = "密码不能为空";
else if (string.IsNullOrEmpty(userCaptcha.Text.Trim()))
errorMessage.Content = "验证码不能为空";
else
{
Parameters parameters = new Parameters();
parameters.Add("source", "radio");
parameters.Add("alias", userName.Text.Trim());
parameters.Add("form_password", userPassword.Password.Trim());
parameters.Add("captcha_solution", userCaptcha.Text.Trim());
parameters.Add("captcha_id", CaptchaID);
parameters.Add("from", "mainsite");
parameters.Add("remember", "on");
string LogOnJson = "";
await Task.Run(() =>
{
LogOnJson = new ConnectionBase().Post("http://douban.fm/j/login", Encoding.UTF8.GetBytes(parameters.ToString()));
});
if (LogOnJson == string.Empty)
{
errorMessage.Content = "网络连接错误";
return;
}
else
{
LogOnResult logonresult = LogOnResult.FromJson(LogOnJson);
if (logonresult.r == 1)
{
errorMessage.Content = logonresult.err_msg;
return;
}
else if (logonresult.r == 0)
{
loginCanvas.Visibility = Visibility.Collapsed;
loginedCanvas.Visibility = Visibility.Visible;
loginedName.Content = logonresult.user_info.name;
loginedPlayed.Content = logonresult.user_info.play_record.played + "首";
loginedLiked.Content = logonresult.user_info.play_record.liked + "首";
loginedBanned.Content = logonresult.user_info.play_record.banned + "首";
loginTitle.Content = "用户";
LoginState = 1;
loginUserName = logonresult.user_info.name;
}
}
}
}
示例5: UpdateUserInfo
/// <summary>
/// 更新用户信息
/// </summary>
/// <returns>是否成功</returns>
private bool UpdateUserInfo()
{
Debug.Assert(!string.IsNullOrEmpty(Settings.User.Token), "!string.IsNullOrEmpty(Settings.User.Token)");
Parameters parameters = new Parameters();
parameters["app_name"] = "radio_desktop_win";
parameters["version"] = "100";
parameters["user_id"] = Settings.User.UserID;
parameters["token"] = Settings.User.Token;
parameters["expire"] = Settings.User.Expire;
string file = new ConnectionBase().Post("http://www.douban.com/j/app/radio/user_info",
Encoding.UTF8.GetBytes(parameters.ToString()));
var userInfo = JsonHelper.FromJson<UserInfo>(file);
if (userInfo == null || userInfo.r)
{
return false;
}
Settings.User.Played = userInfo.played_num;
Settings.User.Liked = userInfo.liked_num;
Settings.User.Banned = userInfo.banned_num;
if (userInfo.pro_status == "S")
{
if (!Settings.User.IsPro)
{
Settings.User.IsPro = true;
Settings.User.ProRate = ProRate.Kbps64;
}
}
else
{
Settings.User.IsPro = false;
Settings.User.ProRate = ProRate.Kbps64;
}
return true;
}
示例6: LogOnWithEmail
/// <summary>
/// 使用邮箱登录
/// </summary>
/// <param name="email">邮箱</param>
/// <param name="password">密码</param>
/// <returns>登录结果</returns>
private LogOnResult LogOnWithEmail(string email, string password)
{
Parameters parameters = new Parameters();
parameters["app_name"] = "radio_desktop_win";
parameters["version"] = "100";
parameters["email"] = email;
parameters["password"] = password;
string file = new ConnectionBase().Post("http://www.douban.com/j/app/login",
Encoding.UTF8.GetBytes(parameters.ToString()));
return JsonHelper.FromJson<LogOnResult>(file);
}
示例7: SendReport
public static string SendReport(string exceptionMessage, string userMessage, string systemInformation)
{
Assembly assembly = Assembly.GetEntryAssembly();
string productName = ((AssemblyProductAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyProductAttribute))).Product;
string versionNumber = App.AppVersion.ToString();
Parameters parameters = new Parameters();
parameters["ProductName"] = productName;
parameters["VersionNumber"] = versionNumber;
parameters["SystemInformation"] = systemInformation;
parameters["Exception"] = exceptionMessage;
parameters["UserMessage"] = userMessage;
string result = new ConnectionBase().Post("http://doubanfmcloud.sinaapp.com/products/errorfeedback.php", Encoding.UTF8.GetBytes(parameters.ToString()));
return result;
}
示例8: SettingSystrayTo
public void SettingSystrayTo(bool value)
{
var target = new Parameters {Systray = value};
var expected = value ? " /systray:true" : "";
target.ToString().Should().Be(expected);
}
示例9: SettingTraceLevelTo
public void SettingTraceLevelTo(TraceLevel level)
{
var target = new Parameters {Trace = level};
var expected = " /trace:" + level.ToString().ToLower();
target.ToString().Should().Be(expected);
}
示例10: SettingTraceLevelToNone_ReturnsEmpty
public void SettingTraceLevelToNone_ReturnsEmpty()
{
var target = new Parameters();
target.Trace.Should().Be(TraceLevel.None);
target.ToString().Should().Be.Empty();
}
示例11: Parameters_DefaultToString_ShouldBeEmpty
public void Parameters_DefaultToString_ShouldBeEmpty()
{
var target = new Parameters();
target.ToString().Should().Be.Empty();
}
示例12: RunExperiment
/// <summary>
/// <c>RunExperiment</c> is the main method of the <c>ConductivityExperiment</c>, it manages
/// all instruments to reach the required functionality.
/// </summary>
/// <param name="expParms">Experiment parameters passed by the user interface and set by the user.</param>
/// <param name="pidParms">PID parameters that can be changed by the user.</param>
/// <returns>If the experiment terminates normally, <c>true</c> is returned.</returns>
public bool RunExperiment(Parameters expParms, PID.Controller.Parameters pidParms)
{
this.runningExperiment = true;
/* experiment always starts in the phase 1 */
Contract.Requires(phase == Phases.PHASE1);
//float T; /* temperature measured in the data acquisition */
float lastT = 0; /* temperature before current one */
//float rate; /* rate at which the temperature varies each time interval */
float desiredRate = expParms.desiredRate;
float envT = expParms.envTemperature;
Limits Tlims = expParms.temperatureLims;
float V_PowerSupply = 0; /* voltage value to be sent to the power supply */
int time = 0, dt = 100; /* miliseconds */
//float R = 0, i, V; /* resistance, current and voltage in the sample */
float err = 0; /* error from desired rate */
Measurement measure;
System.Console.Write("Start Experiment\n");
pid = new PID.Controller(pidParms);
ExportToFile(fullpath, expParms.ToString()); //fileacq.Write(expParms);
ExportToFile(fullpath, "\n" + Measurement.header); //fileacq.Write("\n" + Measurement.header);
if (Init(expParms.amperimeterVoltage0))
{
do
{
/*i = ampere.Read();
V = ampere.readVoltage();
T = data.Read();
rate = (T - lastT) / (dt * 60); /* Celsius degree / sec */
/*
Contract.Invariant(i > 0);
R = V / i;*/
measure = this.Read(lastT, time);
// list changes the status here, listeners are
// interested in this event
list.Add(measure);
fileacq.Write(measure);
System.Console.Write(measure);
/*
* In the freezing phase temperature is not controlled
* by PID because the rate of decreasing is very high
* and the power supply will change the voltage every
* time
*/
if (phase != Phases.PHASE2 || phase != Phases.PHASE4)
{
err = desiredRate - measure.getRate();
lastT = measure.getT();
V_PowerSupply = V_PowerSupply * ((desiredRate - pid.output(err, dt * 60)) / desiredRate);
heater.Send(V_PowerSupply);
}
if ((measure.getT() > Tlims.max && (phase == Phases.PHASE1 || phase == Phases.PHASE3))
|| (measure.getT() < Tlims.min && phase == Phases.PHASE2))
phase++;
System.Threading.Thread.Sleep(dt);
time += dt;
} while (phase != Phases.PHASE4 && measure.getT() < envT && this.runningExperiment);
fileacq.Close();
Halt();
this.runningExperiment = false;
return true;
}
else return false;
}