本文整理汇总了C#中Parse.ParseUser类的典型用法代码示例。如果您正苦于以下问题:C# ParseUser类的具体用法?C# ParseUser怎么用?C# ParseUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseUser类属于Parse命名空间,在下文中一共展示了ParseUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createNewUser
public static void createNewUser(string username, string password, System.Action<bool> complete)
{
ParseUser user = new ParseUser (){
Username = username,
Password = password,
Email = username + "@fakeEmailabc123.com"
};
user.SignUpAsync().ContinueWith(t => {
if (t.IsFaulted) {
// Errors from Parse Cloud and network interactions
using (IEnumerator<System.Exception> enumerator = t.Exception.InnerExceptions.GetEnumerator()) {
if (enumerator.MoveNext()) {
ParseException error = (ParseException) enumerator.Current;
// error.Message will contain an error message
// error.Code will return "OtherCause"
Debug.Log(error.Code + " : " + error.Message);
complete(false);
}
}
}
else {
complete(true);
}
});
}
示例2: RegUser
//Sample Parse Function
public async Task RegUser (string un, string ps, string em)
{
ParseUser user = new ParseUser ();
user.Username = un;
user.Password = ps;
user.Email = em;
// other fields can be set just like with ParseObject
//user ["phone"] = "415-392-0202";
try
{
await user.SignUpAsync ();
Console.WriteLine ("Account Creation Success");
// Login was successful.
//TODO: Open up a new page
//await Navigation.PushModalAsync (new NEWPAGENAME () );
}
catch (Exception e)
{
// The login failed. Check the error to see why.
Console.WriteLine("Signup error: " + e.Message);
DisplayAlert ("Error", e.Message, "OK", "Cancel");
}
}
示例3: CreateUser
public async Task<User> CreateUser(string username, string pass, string email)
{
try
{
var user = new ParseUser()
{
Username = username,
Password = pass,
Email = email
};
User createdUser = new User()
{
Username = user.Username
};
await user.SignUpAsync();
await ParseUser.LogInAsync(username, pass);
((App)App.Current).AuthenticatedUser = ParseUser.CurrentUser;
return createdUser;
}
catch (Exception e)
{
new MessageDialog(e.Message).ShowAsync();
return null;
}
}
示例4: CreateUser
public async Task<ActionResult> CreateUser(FormCollection form)
{
try
{
var user = new ParseUser()
{
Username = form["username"],
Password = form["password"],
Email = form["email"]
};
user["firstName"] = form["firstName"].ToString();
user["lastName"] = form["lastName"].ToString();
user["phoneNumber"] = form["phoneNumber"].ToString();
user["address"] = form["address"].ToString();
user["birthday"] = DateTime.Parse(form["birthday"].ToString());
user["gender"] = bool.Parse(form["gender"]);
user["role"] = form["role"].ToString();
await user.SaveAsync();
return RedirectToAction("UserList");
}
catch (ParseException pe)
{
ViewBag.Error = "Error input form " + pe.Message + " ! Please retry";
return View();
}
}
示例5: CreateUser
void CreateUser()
{
ParseUser.LogOut();
var user = new ParseUser(){
Username = usuario,
Password = pwd,
Email = email
};
// other fields can be set just like with ParseObject
user["pontuacao"] = (int) scoreInicial;
user.SignUpAsync().ContinueWith( t => {
if (t.IsFaulted || t.IsCanceled)
{
foreach (var e in t.Exception.InnerExceptions)
{
ParseException parseException = (ParseException)e;
Debug.Log("Error message " + parseException.Message);
Debug.Log("Error code: " + parseException.Code);
}
}
else
{
//SignUpAsync(); //DONE
Debug.Log("Usuário criado com sucesso");
}
});
ParseUser.LogOut();
}
示例6: SignUp
public async Task<IHttpActionResult> SignUp([FromBody]Usuario user)
{
try
{
ParseUser usuario = new ParseUser()
{
Username = user.usuario,
Password = user.psw,
Email = user.correo
};
usuario["nombre"] = user.nombre;
Byte[] bytes = Convert.FromBase64String(user.foto);
ParseFile foto = new ParseFile("foto.png", bytes);
await foto.SaveAsync();
usuario["foto"] = foto;
usuario["sexo"] = user.sexo;
usuario["tipo"] = user.tipo;
await usuario.SignUpAsync();
Usuario resp = new Usuario();
resp.usuario = user.usuario;
resp.psw = user.psw;
resp.correo = usuario.Get<string>("email");
resp.foto = usuario.Get<ParseFile>("foto").Url.AbsoluteUri;
resp.sexo = usuario.Get<string>("sexo");
resp.tipo = usuario.Get<string>("tipo");
resp.nombre = usuario.Get<string>("nombre");
resp.ObjectId = usuario.ObjectId;
return Ok(resp);
}
catch (ParseException e) {
return InternalServerError(e);
}
}
示例7: SignUp
private void SignUp(string username, string password, string email, Dictionary<string, string> signUpParams)
{
var user = new ParseUser()
{
Username = username,
Password = password,
Email = email
};
foreach(var kvp in signUpParams) {
user[kvp.Key] = kvp.Value;
}
user.SignUpAsync();
/* Task signUpTask = user.SignUpAsync();
signUpTask.ContinueWith(
task => {
Debug.Log("Calling cloud function");
ParseCloud.CallFunctionAsync<Dictionary<string,object>>("GetSuggestions", new Dictionary<string, object>()).ContinueWith(
t => {
var suggestions = t.Result;
if(suggestions != null) {
foreach(var kvp in suggestions) {
Debug.Log(kvp.Key + " " + kvp.Value);
}
}
});
});*/
}
示例8: Registration
void Registration()
{
Debug.LogError("Registration has been called");
if (usernameRegister.text == "Your full name" || emailRegister.text == "Your email" || repassRegister.text == "Enter password again" || usernameRegister.text == "" || emailRegister.text == "" || passwordRegister.text == "" || repassRegister.text == "")
{
message = "Please enter all the fields";
Debug.LogError ("" +message);
}
else
{
if (passwordRegister.text == repassRegister.text)
{
Debug.LogError("Passwords Matched");
var userCurrent = new ParseUser(){
Username = usernameRegister.text,
Email = emailRegister.text,
Password = passwordRegister.text
};
// Debug.LogError ("" +userCurrent);
Task signUpTask = userCurrent.SignUpAsync();
message = "Sign up successful. Check your email for verification!";
}
else
{
message = "Your Password does not match";
}
}
}
示例9: TestGetSetAsync
public Task TestGetSetAsync() {
var storageController = new Mock<IStorageController>(MockBehavior.Strict);
var mockedStorage = new Mock<IStorageDictionary<string, object>>();
var controller = new ParseCurrentUserController(storageController.Object);
var user = new ParseUser();
storageController.Setup(s => s.LoadAsync()).Returns(Task.FromResult(mockedStorage.Object));
return controller.SetAsync(user, CancellationToken.None).OnSuccess(_ => {
Assert.AreEqual(user, controller.CurrentUser);
object jsonObject = null;
Predicate<object> predicate = o => {
jsonObject = o;
return true;
};
mockedStorage.Verify(s => s.AddAsync("CurrentUser", Match.Create<object>(predicate)));
mockedStorage.Setup(s => s.TryGetValue("CurrentUser", out jsonObject)).Returns(true);
return controller.GetAsync(CancellationToken.None);
}).Unwrap()
.OnSuccess(t => {
Assert.AreEqual(user, controller.CurrentUser);
controller.ClearFromMemory();
Assert.AreNotEqual(user, controller.CurrentUser);
return controller.GetAsync(CancellationToken.None);
}).Unwrap()
.OnSuccess(t => {
Assert.AreNotSame(user, controller.CurrentUser);
Assert.IsNotNull(controller.CurrentUser);
});
}
示例10: AddUser
public virtual void AddUser(ParseDatastoreMaster pdm ){
pdm.Dismiss ();
var user = new ParseUser()
{
Username = username.text,
Password = password.text,
Email = email.text
};
user.SignUpAsync().ContinueWith (t =>
{
if (t.IsFaulted || t.IsCanceled)
{
// The login failed. Check the error to see why.
print ("signup failed!");
print (t.Exception.Message);
pdm.updateLoginStateFlag = true;
}
else
{
// Login was successful.
print ("signup success");
pdm.updateLoginStateFlag = true;
}
});
}
示例11: TestExistsAsync
public Task TestExistsAsync() {
var controller = new ParseCurrentUserController();
var user = new ParseUser();
return controller.SetAsync(user, CancellationToken.None).OnSuccess(_ => {
Assert.AreEqual(user, controller.CurrentUser);
return controller.ExistsAsync(CancellationToken.None);
}).Unwrap()
.OnSuccess(t => {
Assert.IsTrue(t.Result);
controller.ClearFromMemory();
return controller.ExistsAsync(CancellationToken.None);
}).Unwrap()
.OnSuccess(t => {
Assert.IsTrue(t.Result);
controller.ClearFromDisk();
return controller.ExistsAsync(CancellationToken.None);
}).Unwrap()
.OnSuccess(t => {
Assert.IsFalse(t.Result);
});
}
示例12: Login
private static async Task Login(string username, string password)
{
await Task.Delay(1000);
await ParseUser.LogInAsync(username, password);
await Task.Delay(1000);
currentUser = ParseUser.CurrentUser;
}
示例13: signup
public async void signup(string email, string password, Action signupSuccess, Action signupError) {
var user = new ParseUser ()
{
Username = email,
Email = email,
Password = password
};
try
{
await user.SignUpAsync();
Console.WriteLine("signup done");
if (ParseUser.CurrentUser != null)
{
Console.WriteLine("Connected as : {0}", ParseUser.CurrentUser.Get<string>("username"));
signupSuccess();
}
else
{
throw new Exception ("Parse Current User null");
}
}
catch (Exception e)
{
Console.WriteLine("Signup did not work : "+e.Message);
signupError();
}
}
示例14: Map
public static User Map(ParseUser puser)
{
User user = new User();
user.UserName = puser.Username;
user.ObjectId = puser.ObjectId;
user.Email = puser.Email;
return user;
}
示例15: SignUp
private void SignUp()
{
ParseUser userToSignUp = new ParseUser() {
Username = CurrentUser.Username,
Password = CurrentUser.Password
};
userToSignUp.SignUpAsync();
}