static bool CompareUserName(string s1, string s2) { if (s1 == s2) { return(true); } UserNameStruct userName1 = UserNameStruct.Build(s1); UserNameStruct userName2 = UserNameStruct.Build(s2); // 优先比较 UID if (string.IsNullOrEmpty(userName1.LibraryUID) == false && string.IsNullOrEmpty(userName2.LibraryUID) == false) { if (userName1.UserName == userName2.UserName && userName1.LibraryUID == userName2.LibraryUID) { return(true); } } // 然后比较 LibraryName if (string.IsNullOrEmpty(userName1.LibraryUID) == true && string.IsNullOrEmpty(userName2.LibraryUID) == true) { if (userName1.UserName == userName2.UserName && userName1.LibraryName == userName2.LibraryName) { return(true); } } return(false); }
public static UserNameStruct Build(string strText) { UserNameStruct result = new UserNameStruct(); List <string> array1 = StringUtil.ParseTwoPart(strText, "@"); result.UserName = array1[0]; List <string> array2 = StringUtil.ParseTwoPart(array1[1], "|"); result.LibraryName = array2[0]; result.LibraryUID = array2[1]; return(result); }
public static UserNameStruct Build(string strText) { UserNameStruct result = new UserNameStruct(); List<string> array1 = StringUtil.ParseTwoPart(strText, "@"); result.UserName = array1[0]; List<string> array2 = StringUtil.ParseTwoPart(array1[1], "|"); result.LibraryName = array2[0]; result.LibraryUID = array2[1]; return result; }