本文整理汇总了C#中User.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# User.Equals方法的具体用法?C# User.Equals怎么用?C# User.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.Equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualsTest
public void EqualsTest()
{
var user1 = new User("Hans", "Hansen", "Hanserik", "[email protected]");
var user2 = new User("Hans", "Hansen", "Hanserik", "[email protected]");
Assert.IsTrue(user1.Equals(user2));
var user3 = new User("Hanss", "Hansen", "Hanserik", "[email protected]");
Assert.IsFalse(user1.Equals(user3));
}
示例2: Equals_should_work
public void Equals_should_work()
{
var user1 = new User("UseRName", "opa");
var user2 = new User("UserName", "op34a");
var user3 = new User("Nick4Name", "op34a");
Assert.IsTrue(user1.Equals(user2));
Assert.IsFalse(user1.Equals(user3));
Assert.IsFalse(user1.Equals(null));
Assert.IsFalse(user1.Equals(4));
}
示例3: DrawProposalActions
private static IWritable DrawProposalActions(Proposal proposal, User user)
{
List<IWritable> components = new List<IWritable>();
if ( proposal.Status == ProposalStatus.Created )
{
if (user.Equals(proposal.User))
{
components.Add(A(ResolveUri.ForEditProposal(proposal), "Edit"));
}
if (user.Role.Equals(Role.Administrator))
{
components.Add(Form("post", ResolveUri.ForAcceptProposal(proposal), InputSubmit("Accept")));
}
components.Add(Form("post", ResolveUri.ForRejectProposal(proposal), InputSubmit("Reject")));
}
var elem = Div( "controls", "actions"
, components.ToArray()
);
return elem;
}
示例4: EqualsTest
public void EqualsTest()
{
var target = new User { Name = "Florian" };
var obj = new User { Name = "Florian" };
var expected = false; // The Key is never the same
var actual = target.Equals(obj);
Assert.AreEqual(expected, actual);
Assert.IsNotNull(actual);
}
示例5: CompareToTest
public void CompareToTest()
{
var userList = new List<User>();
var user1 = new User("1Hans", "Hansen", "Hanserik", "[email protected]");
var user2 = new User("2Hans", "Hansen", "Hanserik", "[email protected]");
var user3 = new User("3Hans", "Hansen", "Hanserik", "[email protected]");
userList.Add(user2);
userList.Add(user1);
userList.Add(user3);
userList.Sort();
Assert.IsTrue(user1.Equals(userList[0]));
Assert.IsTrue(user2.Equals(userList[1]));
Assert.IsTrue(user3.Equals(userList[2]));
}
示例6: RemovePersonFromProject
/// <summary>
/// Removes the individual person in the given Project.
/// There's no check whether the user or project exists or not.
/// So checks should be made prior to executing this method.
/// </summary>
/// <param name="project">The project to remove the user from</param>
/// <param name="user">THe user to be removed from the given project</param>
/// <returns></returns>
private bool RemovePersonFromProject(Project project, User user)
{
var t = from d in dbContext.ProjectUsers
where project.Equals(d.Project) && user.Equals(d.User)
select d;
dbContext.ProjectUsers.DeleteOnSubmit(t.ToList().FirstOrDefault());
try
{
dbContext.SubmitChanges();
return true;
}
catch (Exception e)
{
Console.WriteLine("Something went wrong, when deleting the user id: " + user.Id + ", from the project id: " + project.Id + " Error Message: \n" + e);
return false;
}
}
示例7: lobbyClient_OnUserStatusChanged
void lobbyClient_OnUserStatusChanged(UserStatus eve, User u)
{
Dispatcher.Invoke(new Action(() =>
{
if (u.Equals(Program.lobbyClient.Me))
{
tbUsername.Text = Program.lobbyClient.Me.DisplayName;
tbStatus.Text = Program.lobbyClient.Me.CustomStatus;
Registry.WriteValue("Nickname", Program.lobbyClient.Me.DisplayName);
}
}));
}
示例8: writeReview
public void writeReview(User user, string review_text, int rating)
{
//Can't write a review of yourself, dummy
if (!user.Equals(this))
{
user.addReview(this, review_text, rating);
}
}
示例9: UserEquality
public void UserEquality()
{
var u1 = new User("Nick");
var u2 = new User("Nick");
Assert.IsTrue(u1.Equals(u2));
}
示例10: AddUpdateUser
public void AddUpdateUser(User user)
{
int index = -1;
bool equals = false;
foreach (var user1 in users)
{
if (user1.MyID == user.MyID)
{
if (user.Equals(user1))
{
equals = true;
break;
}
index = users.IndexOf(user1);
}
}
if (index != -1)
{
users.RemoveAt(index);
}
if (equals == false)
{
users.Add(user);
}
}