public string GetImageIdFor(UserFlags flags, UserStats us) { foreach (UserFlags flag in m_flagsToImages.Keys) { if (TestFlag(flag, flags)) { return flag.ToString(); } } string clientBasedImage = us.Product.ProductCode; Warcraft3Stats w3 = us as Warcraft3Stats; if (!object.ReferenceEquals(w3, null)) { if (w3.IconTier == 1) { clientBasedImage = "W3O1"; } else { clientBasedImage = string.Format("{0}{1}{2}", w3.Product == Product.Warcraft3Retail ? "W3" : "FT", w3.IconRace.ToString(), w3.IconTier); } } return clientBasedImage; }
/// <summary> /// Creates a new <see>ChatUser</see>. /// </summary> /// <param name="userName">Specifies the user's fully-qualified username, including possibly the character name, /// name separator (for Diablo 2 characters), and realm namespace qualifier.</param> /// <param name="ping">The user's latency.</param> /// <param name="flags">The user's flags.</param> /// <param name="stats">The user's stats.</param> /// <remarks> /// <para>The user's stats can be determined by passing the username and binary statsring value to /// <see cref="UserStats.Parse">UserStats.Parse</see>.</para> /// </remarks> public ChatUser(string userName, int ping, UserFlags flags, UserStats stats) { m_un = userName; m_ping = ping; m_flags = flags; m_stats = stats; }
public Employee(string _name, UserFlags _flag) { id = new Random().Next(-1, int.MaxValue); name = _name; flag = _flag; shifts = new PeriodShifts(id); }
public Boolean AddUser(DirectoryEntry container, String login, String password) { if (ObjectExists(login, "user", false)) { throw new Exception("Login already exists"); } DirectoryEntry _user = container.Children.Add(login, "user"); //A primeira senha é gerada randomicamente para cumprir com todos os sequisitos de complexidade //Para evitar erro ao inserir o usuário String tPwd = IAM.Password.RandomPassword.Generate(16); _user.Invoke("SetPassword", (Object)tPwd); _user.CommitChanges(); UserFlags flags = UserFlags.NORMAL_ACCOUNT | UserFlags.DONT_EXPIRE_PASSWD | UserFlags.PASSWD_CANT_CHANGE; _user.Invoke("Put", new object[] { "UserFlags", (Int32)flags }); //Define a senha correta do usuário _user.Invoke("SetPassword", (Object)password); _user.CommitChanges(); _user.Close(); return(true); }
private void BindData() { RankID.DataSource = YAF.Classes.Data.DB.rank_list(PageContext.PageBoardID, null); RankID.DataValueField = "RankID"; RankID.DataTextField = "Name"; RankID.DataBind(); using (DataTable dt = YAF.Classes.Data.DB.user_list(PageContext.PageBoardID, CurrentUserID, null)) { DataRow row = dt.Rows[0]; UserFlags userFlags = new UserFlags(row["Flags"]); Name.Text = (string)row["Name"]; Email.Text = row["Email"].ToString(); IsHostAdminX.Checked = userFlags.IsHostAdmin; IsApproved.Checked = userFlags.IsApproved; IsGuestX.Checked = userFlags.IsGuest; IsCaptchaExcluded.Checked = userFlags.IsCaptchaExcluded; IsExcludedFromActiveUsers.Checked = userFlags.IsActiveExcluded; Joined.Text = row["Joined"].ToString(); LastVisit.Text = row["LastVisit"].ToString(); ListItem item = RankID.Items.FindByValue(row["RankID"].ToString()); if (item != null) { item.Selected = true; } } }
protected void Save_Click(object sender, System.EventArgs e) { // update the membership too... if (!IsGuestX.Checked) { MembershipUser user = Membership.GetUser(Name.Text); if (Email.Text.Trim() != user.Email) { user.IsApproved = IsApproved.Checked; // update the e-mail here too... user.Email = Email.Text.Trim(); System.Web.Security.Membership.UpdateUser(user); } } UserFlags userFlags = new UserFlags(); userFlags.IsHostAdmin = IsHostAdminX.Checked; userFlags.IsGuest = IsGuestX.Checked; userFlags.IsCaptchaExcluded = IsCaptchaExcluded.Checked; userFlags.IsActiveExcluded = IsExcludedFromActiveUsers.Checked; userFlags.IsApproved = IsApproved.Checked; YAF.Classes.Data.DB.user_adminsave(PageContext.PageBoardID, CurrentUserID, Name.Text, Email.Text, userFlags.BitValue, RankID.SelectedValue); BindData(); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { this.RankID.DataSource = this.GetRepository <Rank>().GetByBoardId(); this.RankID.DataValueField = "ID"; this.RankID.DataTextField = "Name"; this.RankID.DataBind(); using (var dt = this.GetRepository <User>().ListAsDataTable(this.PageContext.PageBoardID, this.CurrentUserID, null)) { var row = dt.GetFirstRow(); var userFlags = new UserFlags(row["Flags"]); this.Name.Text = row.Field <string>("Name"); this.DisplayName.Text = row.Field <string>("DisplayName"); this.Email.Text = row.Field <string>("Email"); this.IsHostAdminX.Checked = userFlags.IsHostAdmin; this.IsApproved.Checked = userFlags.IsApproved; this.IsGuestX.Checked = userFlags.IsGuest; this.IsCaptchaExcluded.Checked = userFlags.IsCaptchaExcluded; this.IsExcludedFromActiveUsers.Checked = userFlags.IsActiveExcluded; this.Moderated.Checked = userFlags.Moderated; this.Joined.Text = row["Joined"].ToString(); this.IsFacebookUser.Checked = row.Field <bool>("IsFacebookUser"); this.IsTwitterUser.Checked = row.Field <bool>("IsTwitterUser"); this.IsGoogleUser.Checked = row.Field <bool>("IsGoogleUser"); this.LastVisit.Text = row["LastVisit"].ToString(); var item = this.RankID.Items.FindByValue(row["RankID"].ToString()); if (item != null) { item.Selected = true; } } }
private void WriteContent(PexWriteMeta write) { if (DebugInfo == null) { write.Writer.Write((byte)0); } else { write.Writer.Write((byte)1); DebugInfo.Write(write); } write.Writer.Write((ushort)UserFlags.NotNull().Count()); for (byte i = 0; i < 32; i++) { var str = UserFlags[i]; if (str == null) { continue; } write.WriteString(str); write.Writer.Write(i); } write.Writer.Write((ushort)Objects.Count); foreach (var pexObject in Objects) { pexObject.Write(write); } }
/// <summary> /// Adds the User as Host user if not already /// </summary> /// <param name="yafUserId">The YAF user id.</param> /// <param name="boardId">The board id.</param> public static void CreateYafHostUser(int yafUserId, int boardId) { // get this user information... var userInfoTable = LegacyDb.user_list(boardId, yafUserId, null, null, null); if (userInfoTable.Rows.Count <= 0) { return; } DataRow row = userInfoTable.Rows[0]; if (row["IsHostAdmin"].ToType <bool>()) { return; } // fix the IsHostAdmin flag... var userFlags = new UserFlags(row["Flags"]) { IsHostAdmin = true }; // update... LegacyDb.user_adminsave( boardId, yafUserId, row["Name"], row["DisplayName"], row["Email"], userFlags.BitValue, row["RankID"]); }
/// <summary> /// Set the User as Host user if not already /// </summary> /// <param name="yafUserId">The YAF user id.</param> /// <param name="boardId">The board id.</param> public static void SetYafHostUser([NotNull] int yafUserId, [NotNull] int boardId) { // get this user information... var userInfo = BoardContext.Current.GetRepository <User>().GetById(yafUserId); if (userInfo == null) { return; } if (userInfo.UserFlags.IsHostAdmin) { return; } // fix the IsHostAdmin flag... var userFlags = new UserFlags(userInfo.Flags) { IsHostAdmin = true }; // update... BoardContext.Current.GetRepository <User>().AdminSave( boardId, yafUserId, userInfo.Name, userInfo.DisplayName, userInfo.Email, userFlags.BitValue, userInfo.RankID); }
/// <summary> /// Creates a new instance of <see>ChatMessageEventArgs</see> with the given parameters. /// </summary> /// <param name="eventType">The type of event.</param> /// <param name="flags">The other user's flags.</param> /// <param name="username">The primarily involved user.</param> /// <param name="text">The message.</param> public ChatMessageEventArgs(ChatEventType eventType, UserFlags flags, string username, string text) : base(eventType) { m_flags = flags; m_un = username; m_txt = text; }
/// <summary> /// Binds the data. /// </summary> private void BindData() { this.RankID.DataSource = LegacyDb.rank_list(this.PageContext.PageBoardID, null); this.RankID.DataValueField = "RankID"; this.RankID.DataTextField = "Name"; this.RankID.DataBind(); using (DataTable dt = LegacyDb.user_list(this.PageContext.PageBoardID, this.CurrentUserID, null)) { DataRow row = dt.Rows[0]; var userFlags = new UserFlags(row["Flags"]); this.Name.Text = (string)row["Name"]; this.DisplayName.Text = row.Field <string>("DisplayName"); this.Email.Text = row["Email"].ToString(); this.IsHostAdminX.Checked = userFlags.IsHostAdmin; this.IsApproved.Checked = userFlags.IsApproved; this.IsGuestX.Checked = userFlags.IsGuest; this.IsCaptchaExcluded.Checked = userFlags.IsCaptchaExcluded; this.IsExcludedFromActiveUsers.Checked = userFlags.IsActiveExcluded; this.Joined.Text = row["Joined"].ToString(); this.IsFacebookUser.Checked = row["IsFacebookUser"].ToType <bool>(); this.IsTwitterUser.Checked = row["IsTwitterUser"].ToType <bool>(); this.IsGoogleUser.Checked = row["IsGoogleUser"].ToType <bool>(); this.LastVisit.Text = row["LastVisit"].ToString(); ListItem item = this.RankID.Items.FindByValue(row["RankID"].ToString()); if (item != null) { item.Selected = true; } } }
public Employee(int _id, string _name, UserFlags _flag) { id = _id; name = _name; flag = _flag; shifts = new PeriodShifts(id); }
public bool CheckOut(long _time, UserFlags _flag, int _id) { Employee _employee = null; if (TryGetEmployee(_flag, out _employee, _id)) { DateTime Time = DateTime.FromBinary(_time); if (_employee.Shifts == null) { _employee.SetShifts(new PeriodShifts(_employee.ID, Time.Month, Time.Year, DateTime.DaysInMonth(Time.Year, Time.Month))); } if (_employee.Shifts.DaysCount == 0 || _employee.Shifts.Month != Time.Month || _employee.Shifts.Year != Time.Year) { _employee.Shifts.SetData(Time.Month, Time.Year, DateTime.DaysInMonth(Time.Year, Time.Month)); } if (!_employee.Shifts.CheckOut(Time.Hour, Time.Minute)) { _employee.Shifts.CheckOut(Time.Day, Time.Hour, Time.Minute); } return(true); } else { return(false); } }
public Image GetImageFor(UserFlags flags, UserStats stats) { UserFlags[] allFlags = new UserFlags[] { UserFlags.BlizzardRepresentative, UserFlags.BattleNetAdministrator, UserFlags.ChannelOperator, UserFlags.Speaker, UserFlags.SpecialGuest, UserFlags.Squelched, UserFlags.GFOfficial, UserFlags.GFPlayer }; foreach (UserFlags flag in allFlags) { if (TestFlag(flags, flag)) { BniIcon ico = (from icon in m_bni.AllIcons where (icon.UserFlags & flag) == flag select icon).FirstOrDefault(); if (!object.ReferenceEquals(null, ico)) { return(ico.Image); } } } BniIcon img = (from icon in m_bni.AllIcons where icon.SoftwareProductCodes.Contains(stats.Product.ProductCode) select icon).FirstOrDefault(); if (!object.ReferenceEquals(null, img)) { return(img.Image); } return(m_fail); }
public AfpResultCode Process(IAfpSession session, DsiHeader dsiHeader, AfpStream requestStream, AfpStream responseStream) { UserFlags flags = requestStream.ReadEnum <UserFlags>(); int? userId = null; //if (flags != UserFlags.ThisUser) { userId = requestStream.ReadInt32(); // } UserBitmap bitmap = requestStream.ReadEnum <UserBitmap>(); responseStream.WriteEnum(bitmap); foreach (UserBitmap value in bitmap.EnumerateFlags()) { switch (value) { case UserBitmap.UserId: responseStream.WriteInt32(0); break; case UserBitmap.Uuid: responseStream.WriteBytes(new byte[16]); break; case UserBitmap.PrimaryGroupId: responseStream.WriteInt32(0); break; } } return(AfpResultCode.FPNoErr); }
private void LoadFlagsIcons(WebIconList iconsList, string localPath) { var flagsIcons = from icon in iconsList.Icons where !string.IsNullOrEmpty(icon.UserFlags) select icon; foreach (var flagsIconEntry in flagsIcons) { string[] appropriateFlags = flagsIconEntry.UserFlags.Contains(",") ? flagsIconEntry.UserFlags.Split(',') : new string[] { flagsIconEntry.UserFlags }; Image currentImage = null; try { currentImage = LoadImageFromFile(Path.Combine(localPath, flagsIconEntry.LocalName)); } catch { // TODO: Log the error or report it. continue; } foreach (string flagName in appropriateFlags) { try { UserFlags actualFlag = (UserFlags)Enum.Parse(typeof(UserFlags), flagName); m_flagsToImages.Add(actualFlag, currentImage); } catch { // TODO: Log the error or report it. continue; } } } }
/// <summary> /// Set the User as Host user if not already /// </summary> /// <param name="yafUserId">The YAF user id.</param> /// <param name="boardId">The board id.</param> public static void SetYafHostUser(int yafUserId, int boardId) { // get this user information... var userInfoTable = BoardContext.Current.GetRepository <User>().ListAsDataTable(boardId, yafUserId, null); if (userInfoTable.Rows.Count <= 0) { return; } var row = userInfoTable.Rows[0]; if (row["IsHostAdmin"].ToType <bool>()) { return; } // fix the IsHostAdmin flag... var userFlags = new UserFlags(row["Flags"]) { IsHostAdmin = true }; // update... BoardContext.Current.GetRepository <User>().AdminSave( boardId, yafUserId, row["Name"].ToString(), row["DisplayName"].ToString(), row["Email"].ToString(), userFlags.BitValue, row["RankID"].ToType <int>()); }
/// <summary> /// Updates the User Info /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { // Update the Membership if (!this.IsGuestX.Checked) { var aspNetUser = this.Get <IAspNetUsersHelper>().GetUserByName(this.Name.Text.Trim()); var userName = this.Get <IAspNetUsersHelper>().GetUserByEmail(this.Email.Text.Trim()).UserName; if (userName.IsSet() && userName != aspNetUser.UserName) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"), MessageTypes.warning); return; } if (this.Email.Text.Trim() != aspNetUser.Email) { // update the e-mail here too... aspNetUser.Email = this.Email.Text.Trim(); } // Update IsApproved aspNetUser.IsApproved = this.IsApproved.Checked; this.Get <IAspNetUsersHelper>().Update(aspNetUser); } else { if (!this.IsApproved.Checked) { this.PageContext.AddLoadMessage( this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "MSG_GUEST_APPROVED"), MessageTypes.success); return; } } var userFlags = new UserFlags { IsHostAdmin = this.IsHostAdminX.Checked, IsGuest = this.IsGuestX.Checked, IsCaptchaExcluded = this.IsCaptchaExcluded.Checked, IsActiveExcluded = this.IsExcludedFromActiveUsers.Checked, IsApproved = this.IsApproved.Checked, Moderated = this.Moderated.Checked }; this.GetRepository <User>().AdminSave( this.PageContext.PageBoardID, this.CurrentUserID, this.Name.Text.Trim(), this.DisplayName.Text.Trim(), this.Email.Text.Trim(), userFlags.BitValue, this.RankID.SelectedValue.ToType <int>()); this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.CurrentUserID)); this.BindData(); }
public Employee(string _name, UserFlags _flag, HealthCertificate _healthcertificate) { id = new Random().Next(-1, int.MaxValue); name = _name; flag = _flag; healthcertificate = _healthcertificate; shifts = new PeriodShifts(id); }
public Employee(int _id, string _name, UserFlags _flag, HealthCertificate _healthcertificate) { id = _id; name = _name; flag = _flag; healthcertificate = _healthcertificate; shifts = new PeriodShifts(id); }
/// <summary> /// sets flags for a user /// </summary> /// <param name="service">service name</param> /// <param name="username">username</param> /// <param name="flag">flag to be reset</param> public void ResetFlags(string service, string username, UserFlags flag) { User user = GetExistingUser(service, username); user.Flags &= ~flag; context.Database.Update <User>().Set(u => u.Flags == user.Flags).Where(u => u.ID == user.ID).Execute(); NightlyCode.Core.Logs.Logger.Info(this, $"{service}/{username} is not flagged as {flag} anymore."); }
/// <summary> /// The get is user disabled label. /// </summary> /// <param name="userFlag"> /// The user Flag. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> protected string GetIsUserDisabledLabel(object userFlag) { var flag = new UserFlags((int)userFlag); return(flag.IsApproved ? string.Empty : $@"<span class=""badge badge-warning"">{this.GetText("DISABLED")}</span>"); }
public bool TryGetEmployee(UserFlags _flag, out Employee _employee, int _id = -255, string _name = null, long _validcertificationdate = -255) { _employee = null; lock (this.syncRoot) { Dictionary <int, Employee> Values = null; List <Employee> employees = null; if (this.items.TryGetValue(_flag, out Values)) { employees = Values.Select(x => x.Value).ToList(); if (_id != -255 && _name == null && _validcertificationdate == -255) { _employee = employees.Find(p => p.ID == _id); return(true); } else if (_id != -255 && _name != null && _validcertificationdate == -255) { _employee = employees.Find(p => p.ID == _id && p.Name == _name); return(true); } else if (_name != null && _id == -255 && _validcertificationdate == -255) { _employee = employees.Find(p => p.Name == _name); return(true); } else if (_name != null && _id == -255 && _validcertificationdate != -255) { _employee = employees.Find(p => p.Name == _name && p.CheckDate(_validcertificationdate)); return(true); } else if (_validcertificationdate != -255 && _id == -255 && _name != null) { _employee = employees.Find(p => p.CheckDate(_validcertificationdate)); return(true); } else if (_validcertificationdate != -255 && _id != -255 && _name == null) { _employee = employees.Find(p => p.CheckDate(_validcertificationdate) && p.ID == _id); return(true); } else { if (_id != -255 && _validcertificationdate != -255 && _name != null) { _employee = employees.Find(p => p.CheckDate(_validcertificationdate) && p.ID == _id && p.Name == _name); return(_employee != null); } } _employee = employees.FirstOrDefault(); return(true); } else { return(false); } } }
/// <summary> /// Updates the User Info /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { // Update the Membership if (!this.IsGuestX.Checked) { MembershipUser user = UserMembershipHelper.GetUser(this.Name.Text.Trim()); string userName = this.Get <MembershipProvider>().GetUserNameByEmail(this.Email.Text.Trim()); if (userName.IsSet() && userName != user.UserName) { this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"), MessageTypes.Warning); return; } if (this.Email.Text.Trim() != user.Email) { // update the e-mail here too... user.Email = this.Email.Text.Trim(); } // Update IsApproved user.IsApproved = this.IsApproved.Checked; this.Get <MembershipProvider>().UpdateUser(user); } else { if (!this.IsApproved.Checked) { this.PageContext.AddLoadMessage( this.Get <ILocalization>().GetText("ADMIN_EDITUSER", "MSG_GUEST_APPROVED"), MessageTypes.Success); return; } } var userFlags = new UserFlags { IsHostAdmin = this.IsHostAdminX.Checked, IsGuest = this.IsGuestX.Checked, IsCaptchaExcluded = this.IsCaptchaExcluded.Checked, IsActiveExcluded = this.IsExcludedFromActiveUsers.Checked, IsApproved = this.IsApproved.Checked }; LegacyDb.user_adminsave( this.PageContext.PageBoardID, this.CurrentUserID, this.Name.Text.Trim(), this.DisplayName.Text.Trim(), this.Email.Text.Trim(), userFlags.BitValue, this.RankID.SelectedValue); this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.CurrentUserID)); this.BindData(); }
/// <summary> /// Returns true if the user flag is set /// </summary> /// <param name="flag"></param> /// <exception cref="NullReferenceException">If the user doesnt exist</exception> /// <returns></returns> protected bool UserFlagSet(UserFlags flag) { if (User == null) { throw new NullReferenceException(); } int value = (int)(User?.Properties["UserFlags"]?.Value ?? 0); return((value & (int)flag) == 1); }
protected void AddFlag(String username, ChatBadges flag) { if (UserFlags.ContainsKey(username)) { UserFlags[username] |= flag; } else { UserFlags.Add(username, flag); } }
private static bool TestBanInfoFlags(IUser user, UserFlags userFlags) { if (userFlags.HasFlag(UserFlags.NotBanned) == true && user.BanInfo.IsBanned == true) { return(false); } if (userFlags.HasFlag(UserFlags.Banned) == true && user.BanInfo.IsNotBanned == true) { return(false); } return(true); }
private static bool TestUserStateFlags(IUser user, UserFlags userFlags) { if (userFlags.HasFlag(UserFlags.Offline) == true && user.UserState != UserState.None) { return(false); } if (userFlags.HasFlag(UserFlags.Online) == true && user.UserState != UserState.Online) { return(false); } return(true); }
public UserAccount(UserAccount src) { Principal = new UGUIWithName(src.Principal); Email = src.Email; Created = src.Created; UserLevel = src.UserLevel; UserFlags = src.UserFlags; UserTitle = src.UserTitle; ServiceURLs = new Dictionary <string, string>(src.ServiceURLs); IsEverLoggedIn = src.IsEverLoggedIn; LastLogout = new Date(src.LastLogout); LastRegion = src.LastRegion?.Clone(); HomeRegion = src.HomeRegion?.Clone(); }
public void Add(string[] _Name, CommandType _CommandType, UserFlags _FlagsRequired, string _Description, CommandTable _SubCommandTable, Delegate _ProcMethod) { System.Reflection.MethodInfo mi = _ProcMethod.Method; System.Reflection.ParameterInfo[] pars = mi.GetParameters(); CommandData data = new CommandData { CommandName = _Name, CommandType = _CommandType, FlagsRequired = _FlagsRequired, Description = _Description, SubCommandTable = _SubCommandTable, ProcMethod = mi, ParameterInfo = pars, ParameterCount = pars.Length - 2 }; _dict.Add(_Name, data); }
protected bool IsUserHostAdmin( DataRow userRow ) { UserFlags userFlags = new UserFlags( userRow ["Flags"] ); return userFlags.IsHostAdmin; }
/// <summary> /// Removes flags from a user /// </summary> /// <param name="user">The user to remove flags from</param> /// <param name="flags">The flags to remove</param> protected void RemoveFlagsFromUser(User user, UserFlags flags) { if (UserHasFlags(user, flags)) user.Flags ^= flags; }
/// <summary> /// Returns true if the user has the specified flags. /// </summary> /// <param name="user">The user to check</param> /// <param name="flags">The flags to check for</param> protected bool UserHasFlags(User user, UserFlags flags) { return (user.Flags & flags) == flags; }
/// <summary> /// Returns true if the user has the specified rank or higher /// </summary> /// <param name="user">The user to check</param> /// <param name="flags">The minimum flags the user must have</param> protected bool UserHasRankOrHigher(User user, UserFlags flags) { if (flags == UserFlags.Admin) return UserHasFlags(user, UserFlags.Admin); if (flags == UserFlags.Moderator) return (UserHasFlags(user, UserFlags.Admin) || UserHasFlags(user, UserFlags.Moderator)); if (flags == UserFlags.Operator) return (UserHasFlags(user, UserFlags.Admin) || UserHasFlags(user, UserFlags.Moderator) || UserHasFlags(user, UserFlags.Operator)); return true; //everyone else is normal }
public Image GetImageFor(UserFlags flags, UserStats stats) { foreach (UserFlags flag in m_flagsToImages.Keys) { if (TestFlag(flag, flags)) { return m_flagsToImages[flag]; } } Image clientBasedImage = null; if (m_nonTieredClientImages.ContainsKey(stats.Product.ProductCode)) clientBasedImage = m_nonTieredClientImages[stats.Product.ProductCode]; Warcraft3Stats w3 = stats as Warcraft3Stats; if (!object.ReferenceEquals(w3, null)) { if (w3.IconTier == 1) { clientBasedImage = m_defaultTierIcon; } else { if (m_tieredClientImages.ContainsKey(stats.Product.ProductCode)) { Dictionary<int, Dictionary<char, Image>> tiers = m_tieredClientImages[stats.Product.ProductCode]; if (tiers.ContainsKey(w3.IconTier)) { Dictionary<char, Image> races = tiers[w3.IconTier]; if (WARCRAFT_3_RACES_TO_IDS.ContainsKey(w3.IconRace)) { char race = WARCRAFT_3_RACES_TO_IDS[w3.IconRace]; if (races.ContainsKey(race)) { clientBasedImage = races[race]; } } } } } } if (object.ReferenceEquals(clientBasedImage, null)) clientBasedImage = m_defaultImage; return clientBasedImage; }
private bool TestFlag(UserFlags flags, UserFlags userFlags) { return ((flags & userFlags) != UserFlags.None); }
public void Add(string _Name, string _Alias1, string _Alias2, string _Alias3, string _Alias4, CommandType _CommandType, UserFlags _FlagsRequired, string _Description, CommandTable _SubCommandTable, Delegate _ProcMethod) { Add(new string[] { _Name, _Alias1, _Alias2, _Alias3, _Alias4 }, _CommandType, _FlagsRequired, _Description, _SubCommandTable, _ProcMethod); }
public string GetImageIdFor(UserFlags flags, UserStats us) { UserFlags[] allFlags = new UserFlags[] { UserFlags.BlizzardRepresentative, UserFlags.BattleNetAdministrator, UserFlags.ChannelOperator, UserFlags.Speaker, UserFlags.SpecialGuest, UserFlags.Squelched, UserFlags.GFOfficial, UserFlags.GFPlayer }; foreach (UserFlags flag in allFlags) { if (TestFlag(flags, flag)) { BniIcon ico = (from icon in m_bni.AllIcons where (icon.UserFlags & flag) == flag select icon).FirstOrDefault(); if (!object.ReferenceEquals(null, ico)) return flag.ToString(); } } return us.Product.ProductCode; }
private static bool TestFlag(UserFlags flags, UserFlags flag) { return ((flags & flag) == flag); }
public Image GetImageFor(UserFlags flags, UserStats stats) { UserFlags[] allFlags = new UserFlags[] { UserFlags.BlizzardRepresentative, UserFlags.BattleNetAdministrator, UserFlags.ChannelOperator, UserFlags.Speaker, UserFlags.SpecialGuest, UserFlags.Squelched, UserFlags.GFOfficial, UserFlags.GFPlayer }; foreach (UserFlags flag in allFlags) { if (TestFlag(flags, flag)) { BniIcon ico = (from icon in m_bni.AllIcons where (icon.UserFlags & flag) == flag select icon).FirstOrDefault(); if (!object.ReferenceEquals(null, ico)) return ico.Image; } } BniIcon img = (from icon in m_bni.AllIcons where icon.SoftwareProductCodes.Contains(stats.Product.ProductCode) select icon).FirstOrDefault(); if (!object.ReferenceEquals(null, img)) return img.Image; return m_fail; }