/// <summary> /// 文字列取得 /// </summary> /// <param name="index">前スペース数</param> /// <returns>文字列</returns> public override string ToString(int index = 0) { var result = new StringBuilder(); var indexSpace = string.Concat(Enumerable.Repeat(" ", index)); // キーワード if (Members.Any()) { result.AppendLine(); result.AppendLine($"{indexSpace}{Name}"); result.AppendLine(indexSpace + "{"); foreach (var statement in Members) { result.AppendLine(statement.ToString(index + 1)); } result.AppendLine(indexSpace + "}"); } else { result.Append($"{Name};"); } return(result.ToString()); }
/// <summary> /// Joins a player into the guild. /// </summary> /// <param name="player">The player to join into the guild.</param> /// <param name="rank">Integer index of the rank to give this new member.</param> /// <param name="initiator">The player who initiated this change (null if done by the api or some other method).</param> public void AddMember(Player player, int rank, Player initiator = null) { if (player != null && !Members.Any(m => m.Key == player.Id)) { using (var context = DbInterface.CreatePlayerContext(readOnly: false)) { var dbPlayer = context.Players.FirstOrDefault(p => p.Id == player.Id); if (dbPlayer != null) { dbPlayer.DbGuild = this; dbPlayer.GuildRank = rank; dbPlayer.GuildJoinDate = DateTime.UtcNow; context.ChangeTracker.DetectChanges(); DetachGuildFromDbContext(context, this); context.SaveChanges(); player.Guild = this; player.GuildRank = rank; player.GuildJoinDate = DateTime.UtcNow; var member = new GuildMember(player.Id, player.Name, player.GuildRank, player.Level, player.ClassName, player.MapName); Members.AddOrUpdate(player.Id, member, (key, oldValue) => member); // Send our new guild list to everyone that's online. UpdateMemberList(); // Send our entity data to nearby players. PacketSender.SendEntityDataToProximity(Player.FindOnline(player.Id)); LogActivity(Id, player, initiator, GuildActivityType.Joined); } } } }
public void RemoveMember(Member member) { if (Members.Any(x => x.MemberId == member.Id)) { Members.RemoveAll(x => x.MemberId == member.Id); } }
public void SyncMembers_AlterMember_Test() { //arrange var repoMock = BuildMemberRepository(); var memberService = new MemberService(repoMock.Object, null, null, null, Mock.Of <IManagementDepartmentService>(), Mock.Of <ISecurityService>(), Mock.Of <IAppSettingHelper>()); var member = Members.First(); var role = member.RoleList.First(); var syncMember = member.Map <SyncMember>(); syncMember.RoleList.Remove(role); syncMember.RoleList.Add(new Role() { Id = Guid.NewGuid(), ManagementDepartmentId = "NewDepartment", RoleId = 2 }); var syncMembers = new[] { syncMember }.ToJson(); var activeUserIds = Enumerable.Empty <Guid>(); //act memberService.SyncMembers(syncMembers, activeUserIds); //assert Assert.NotNull(member.RoleList.FirstOrDefault(r => r.RoleId == 2)); Assert.True(member.RoleList.Any(r => r.RoleId == role.RoleId && r.IsDeleted)); Assert.True(Members.Any(r => r.IsDeleted)); }
public async Task CreateCMD(CommandContext ctx, string Name, params DiscordMember[] Members) { Name = Name.Replace(' ', '_'); if (ctx.Guild == null) { await ctx.RespondAsync("Sorry, not here!"); throw new Exception(); } var g = Dependencies.Settings.MainGuild; if (ctx.Guild.Id != g.Id) { await ctx.RespondAsync("Sorry, not here!"); throw new Exception(); } if (!ctx.Member.Roles.Contains(Dependencies.Settings.AliveParticipantRole)) { await ctx.RespondAsync("Sorry, Participants only!"); throw new Exception(); } if (!Members.Any(x => x.Roles.Contains(Dependencies.Settings.AliveParticipantRole))) { await ctx.RespondAsync("Sorry, Participants only!"); throw new Exception(); } var members = Members.ToList(); for (int a = 0; a < members.Count; a++) { for (int b = 0; b < members.Count; b++) { if (a != b) { if (members[a].Id == members[b].Id) { members.Remove(members[b]); } } } } members.Remove(ctx.Member); var newChannel = await g.CreateChannelAsync("S" + Dependencies.Settings.SeasonNumber + "_" + Name, ChannelType.Text, parent : await GetOrCreateCategory(), overwrites : GetOverwrites(members, g, ctx.Member)); var cc = new CC(ctx.Member, members, newChannel); await newChannel.SendMessageAsync("Look, look! Over @here, a new **conspiracy channel** has been created!", embed : GetListEmbed(cc)); Dependencies.Settings.Channels.Add(cc); }
//private HashSet<Pilot> _ClubMembers { get; } //private HashSet<Aircraft> _ClubAircrafts { get; } public void AddMember(Pilot member) { if (!Members.Any(i => i.IdNumber == member.IdNumber)) { Members.Add(member); } return; }
/// <summary> /// Broadcasts the specified message to online members. /// </summary> /// <param name="message">The message.</param> /// <param name="ignoreIndexes"> /// A collection of player indices that specifies which players should not receive the message. /// </param> public void SendMessage(string message, params int[] ignoreIndexes) { foreach (var player in TShock.Players.Where(p => Members.Any(m => m.Equals(p?.User?.Name)) && !ignoreIndexes.Contains(p.Index))) { player.SendMessage(message, ChatColor.GetColor()); } }
private void ProcessXmlFileContents() { if (Members.Any()) { throw new InvalidOperationException( $@"This {nameof(XmlDocumentationReader)} has already been initialized."); } var root = _doc.Element("doc"); if (root == null) { throw Errors.IncompatibleXmlDocument("doc"); } var assembly = root.Element("assembly"); if (assembly == null) { throw Errors.IncompatibleXmlDocument("doc > assembly"); } AssemblyName = assembly.Element("name")?.Value; var membersElement = root.Element("members"); if (membersElement == null) { throw Errors.IncompatibleXmlDocument("doc > members"); } var members = membersElement.Elements("member").ToList(); foreach (var member in members) { var @namespace = member.Attribute("name")?.Value ?? string.Empty; var split = @namespace.Split(':'); var fieldType = split[0].GetFieldType(); if (fieldType == ReferenceType.Method) { continue; } var descendants = member.Descendants().ToList(); var dict = new Dictionary <string, string>(); foreach (var desc in descendants) { // Process the inner elements dict[desc.Name.LocalName] = ResolveXmlBody(desc); } var model = new XmlSummaryDescriptor(split[1], fieldType, dict); Members.Add(model); } Members = Members.OrderBy(x => x.FieldType).ToList(); Initialized = true; }
protected internal async Task <ObservableCollection <ChartM.Record> > ExecutedService() { return(await Task.Run(async() => { try { List <ChartM.Record> collection = new List <ChartM.Record>(); using (me = new MedicalModel(ConfigurationManager.Connect())) { await me.Database.Connection.OpenAsync(); List <object> services = Members.Count == 0 ? me.servicesdata.Select(s => new { s.IdTD, s.NameTD }).ToList <object>() : me.servicesdata.Where(s => Members.Any(m => m == s.IdTD)).Select(s => new { s.IdTD, s.NameTD }).ToList <object>(); DateTime LocalStart = StartTime == null ? Correction(true, me.examinationdata.OrderBy(e => e.DateTimeEX).FirstOrDefault().DateTimeEX.Date) : Correction(true, (DateTime)StartTime).Date; DateTime LocalFinish = FinishTime == null ? (StartTime != null ? Correction(false, (DateTime)StartTime).Date : Correction(false, DateTime.Now).Date) : Correction(false, (DateTime)FinishTime).Date; FinishTime = LocalFinish; while (LocalStart.Date < ((DateTime)FinishTime).Date) { LocalFinish = NextStep(LocalStart); List <int> examinations = me.examinationdata.Where(e => e.DateTimeEX > LocalStart && e.DateTimeEX < LocalFinish).Select(e => e.ServiceIdEX).ToList(); foreach (object service in services) { collection.Add(new ChartM.Record() { Id = services.IndexOf(service), Name = (string)service.GetType().GetProperty("NameTD").GetValue(service), Date = LocalStart, Value1 = examinations.Count(e => e == (int)service.GetType().GetProperty("IdTD").GetValue(service)) }); } LocalStart = NextStep(LocalStart); } } workingConn = true; return new ObservableCollection <ChartM.Record>(collection); } catch (Exception ex) { Log.WriteException(ex); workingConn = false; return null; } }, CancellationToken.None).ContinueWith(task => { if (!workingConn) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => ConnectionMessage())); } return task.Result; })); }
public Validation CanMove(Exit exit) { if (Members.Any(x => x.Encumbrance > x.MaxEncumbrance)) { return(new Validation().Fail("At least one person in your party is too heavy to move!")); } return(new Validation()); }
public bool Has(Aisling aisling, bool includeSelf = false) { if (includeSelf) { return(Members.Any(i => i.Serial == aisling.Serial)); } return(MembersExcludingSelf.Any(i => i.Serial == aisling.Serial)); }
public void AddMember( string name, Type type) { if (Members.Any(member => member.Name == name)) { throw new IllegalStateException("Member by name '" + name + "' already added"); } Members.Add(new CodegenTypedParam(type, name)); }
public override void AddRoutesTo(RouteCollection routeCollection) { _resourceMapper.SetResourceAs(MappedName ?? ResourceName); var routes = new List <Route>(); if (IncludesAction(_names.ShowName)) { routes.Add(_resourceMapper.ShowRoute()); } if (IncludesAction(_names.UpdateName)) { routes.Add(_resourceMapper.UpdateRoute()); } if (IncludesAction(_names.NewName)) { routes.Add(_resourceMapper.NewRoute()); } if (IncludesAction(_names.EditName)) { routes.Add(_resourceMapper.EditRoute()); } if (IncludesAction(_names.DestroyName)) { routes.Add(_resourceMapper.DestroyRoute()); } if (IncludesAction(_names.CreateName)) { routes.Add(_resourceMapper.CreateRoute()); } if (Members != null && Members.Any()) { foreach (var member in Members) { routes.Add(_resourceMapper.MemberRoute(member.Key, member.Value)); } } foreach (var route in routes) { ConfigureRoute(route); routeCollection.Add(route); } foreach (var mapping in Mappings) { mapping.AddRoutesTo(routeCollection); } }
public override bool CanInvite(Character character, out PartyJoinErrorEnum error, Character inviter = null, bool send = true) { if (Members.Any()) { var lower = Members.Min(x => x.Level); var upper = Members.Max(x => x.Level); if (Math.Max(character.Level, upper) - Math.Min(character.Level, lower) > ArenaManager.ArenaMaxLevelDifference) { if (inviter != null && send) { // Impossible d'inviter %1 : l'écart maximal entre le plus haut et le plus bas niveau d'une équipe Kolizéum ne peut dépasser 50 niveaux. inviter.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 359, character.Name); } error = PartyJoinErrorEnum.PARTY_JOIN_ERROR_UNMET_CRITERION; return(false); } } if (character.ArenaPenality > DateTime.Now) { if (inviter != null && send) { // %1 est interdit de Kolizéum pour un certain temps car il a abandonné un match de Kolizéum. inviter.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 328, character.Name); } error = PartyJoinErrorEnum.PARTY_JOIN_ERROR_UNMET_CRITERION; return(false); } if (character.Level >= ArenaManager.ArenaMinLevel) { return(base.CanInvite(character, out error, inviter, send)); } if (send) { if (inviter != null) { // %1 doit être au moins niveau 50 pour faire des combats en Kolizéum. inviter.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 327, character.Name); } else { // Vous devez être au moins niveau 50 pour faire des combats en Kolizéum. character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 326); } } error = PartyJoinErrorEnum.PARTY_JOIN_ERROR_UNMET_CRITERION; return(false); }
public void CreateDefaultConstructor() { if (Members.Any(m => m is ConstructorDeclarationSyntax)) { return; } var metatype = (Metatype)Type.Resolved(); var constructor = new DefaultConstructor((ObjectType)metatype.Instance); ChildSymbols = new SymbolSet(ChildSymbols.Values.SelectMany(s => s).Append(constructor)); }
public void AddMember(Member member) { if (!Members.Any(x => x.MemberId == member.Id)) { Members.Add(new GroupCodeMember { Member = member, GroupCode = this }); } }
public void AddMember(CustomerDTO customer) { if (Members.Any(x => x.Customer.GlobalId == customer.GlobalId)) { BAMessageBox.ShowError("Error_CustomerGroupDetailsViewModel_AddMember_AlreadyInGroup".TranslateInstructor()); return; } var viewModel = new GroupMemberItem(customer); Members.Add(viewModel); ValidateMembers(); ValidateCustomers(); }
/// <summary> /// メンバーの表示名を更新します。 /// </summary> public void UpdateMemberDisplayName() { var id = UserDataModel.Instance.MemberId; if (id == UserDataModel.DefaultMemberId || Members == null || !Members.Any()) { MemberDisplayName = "ー"; } else { MemberDisplayName = Members.Where(x => x.Id == id).Select(x => x.Name).First() ?? "ー"; } }
public void WriteSitemapIndex(string OutputPath) { // Gather all the pages List <APIPage> AllPages = new List <APIPage>(GatherPages()); // Find the shortest link path to each member Dictionary <string, List <APIMember> > MemberIndexLinks = new Dictionary <string, List <APIMember> >(); foreach (APIMember Member in AllPages.OfType <APIMember>()) { // Find or create the list of members for this link path List <APIMember> Members; if (!MemberIndexLinks.TryGetValue(Member.FullName, out Members)) { Members = new List <APIMember>(); MemberIndexLinks.Add(Member.FullName, Members); } // Remove any members Members.RemoveAll(x => x.HasParent(Member)); if (!Members.Any(x => Member.HasParent(x))) { Members.Add(Member); } } // Create all the root pages List <SitemapNode> RootNodes = new List <SitemapNode>(); foreach (APIPage Page in AllPages) { if (!(Page is APIMember) && Page.ShouldOutputPage()) { RootNodes.Add(new SitemapNode(Page.Name, Page.SitemapLinkPath)); } } foreach (KeyValuePair <string, List <APIMember> > MemberIndexLink in MemberIndexLinks) { foreach (APIMember Member in MemberIndexLink.Value) { if (Member.ShouldOutputPage()) { RootNodes.Add(new SitemapNode(MemberIndexLink.Key, Member.SitemapLinkPath)); } } } // Write the index file Sitemap.WriteIndexFile(OutputPath, RootNodes); }
/// <summary> /// Adds a <see cref="member"/> to the Group Members. /// </summary> /// <typeparam name="TCredential"></typeparam> /// <param name="member"></param> protected internal virtual void AddMember <TCredential>(TCredential member) where TCredential : CredentialBase, new() { if (Members.Any( x => ReferenceEquals(x.Member, member) || x.Member.Id == member.Id)) { return; } InternalMembers.Add(new Membership { Member = member }); }
private void AddMember(string name, bool isLong, bool isSelected) { if (string.IsNullOrWhiteSpace(name)) { return; } if (!Members.Any(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) { Members.Add(new MemberViewModel(name, isSelected) { IsLong = isLong }); } }
private async Task AddMember(string name, bool isLong, bool isSelected) { if (string.IsNullOrWhiteSpace(name)) { return; } if (!Members.Any(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) { Members.Add(new MemberViewModel(name, isSelected) { IsLong = isLong }); } await Task.Delay(TimeSpan.FromSeconds(1)); }
public void AddMembers(IList <Guid> userIds) { if (Members == null || Members.Count == 0) { Members = userIds.Select(userId => new Member(Id, userId)).ToList(); } else { foreach (var member in Members) { if (!Members.Any(m => m.Equals(member))) { Members.Add(new Member(Id, member.UserId)); } } } }
/// <summary> /// Add a new player to the party. /// </summary> public sealed override void MemberAdd(Player invitee, bool broadcast) { if (Members.Any(m => m.Id == invitee.Character.Id)) { throw new PartyMemberException($"Can't invite {invitee.Character.Name}, {invitee.Character.Name} is already a member of the party!"); } if (Members.Count > FullPartySize) { throw new PartyMemberException($"Can't invite {invitee.Character.Name}, party is full!"); } // no leader, assign new member as leader if (Leader == null) { leaderIndex = (byte)Members.Count; } Members.Add(new Member(invitee, (byte)Members.Count)); if (broadcast) { invitee.Session.Send(new ServerSocialMessage { Name = invitee.Character.Name, Byte1 = 1, SocialType = Type }); List <Player> onlineMembers = Players; Send(new ServerSocialAction { ObjectParameter1 = Leader.Id, ObjectParameter2 = invitee.Character.Id, PlayerParameter1 = Leader.Name, PlayerParameter2 = invitee.Character.Name, Byte1 = 1, Action = 1, Byte4 = 2 }, onlineMembers); SendUpdate(onlineMembers); } invitee.SetParty(this); }
/// <summary> /// Verifica se l'utente appartiene alla commissione /// </summary> /// <param name="PersonId">Id persona da controllare</param> /// <returns>True se l'utente fa parte della commissione, come Presidente, Segretario o Membro</returns> public virtual bool IsInCommission(int PersonId) { if (President != null && President.Id == PersonId) { return(true); } if (Secretary != null && Secretary.Id == PersonId) { return(true); } if (Members != null && Members.Any(m => m.Member != null && m.Member.Id == PersonId)) { return(true); } return(false); }
public void AddMember(string _clientEmail, string _clientName) { if (Members.Any(c => c.Email == _clientEmail)) { // client is already a member of this room. Not allowed to re-join. throw new DuplicateRoomMemberException("A conta de e-mail escolhida já faz parte desta sala de chat."); } if (MaxUsers > 0 && Members.Count >= MaxUsers) { throw new FullChatRoomException("A sala já está lotada. Você será colocado na fila de espera."); } Members.Add(new ChatMember { Name = _clientName, Email = _clientEmail }); }
/// <summary> /// Update alliance with another alliance object /// </summary> /// <param name="obj"></param> public void Update(IUpdatable obj) { if (obj is Alliance alliance) { if (FounderId != alliance.FounderId) { FounderId = alliance.FounderId; } if (Name != alliance.Name) { Name = alliance.Name; } if (Tag != alliance.Tag) { Tag = alliance.Tag; } //Remove members that have left Members.RemoveAll(e => !alliance.Members.Any(a => a.Id == e.Id)); //Add new members Members.AddRange(alliance.Members.Where(a => !Members.Any(e => e.Id == a.Id))); } }
/// <summary> /// First check that: /// 1. we don't have any members that are unreachable, or /// 2. all unreachable members in the set have status DOWN or EXITING /// Else we can't continue to check for convergence. When that is done /// we check that all members with a convergence status is in the seen /// table and has the latest vector clock version. /// </summary> /// <param name="exitingConfirmed">The set of nodes who have been confirmed to be exiting.</param> /// <returns><c>true</c> if convergence has been achieved. <c>false</c> otherwise.</returns> public bool Convergence(IImmutableSet <UniqueAddress> exitingConfirmed) { // If another member in the data center that is UP or LEAVING // and has not seen this gossip or is exiting // convergence cannot be reached bool MemberHinderingConvergenceExists() { return(Members.Any(x => ConvergenceMemberStatus.Contains(x.Status) && !(LatestGossip.SeenByNode(x.UniqueAddress) || exitingConfirmed.Contains(x.UniqueAddress)))); } // Find cluster members in the data center that are unreachable from other members of the data center // excluding observations from members outside of the data center, that have status DOWN or is passed in as confirmed exiting. var unreachable = DcReachabilityExcludingDownedObservers.AllUnreachableOrTerminated .Where(node => node != SelfUniqueAddress && !exitingConfirmed.Contains(node)) .Select(x => LatestGossip.GetMember(x)); // unreachables outside of the data center or with status DOWN or EXITING does not affect convergence var allUnreachablesCanBeIgnored = unreachable.All(m => ConvergenceSkipUnreachableWithMemberStatus.Contains(m.Status)); return(allUnreachablesCanBeIgnored && !MemberHinderingConvergenceExists()); }
public bool ContainsSurname(string surname, bool ignoreCase) => ignoreCase?Members.Any(x => x.Surname.Equals(surname, StringComparison.OrdinalIgnoreCase)) : Members.Any(x => x.Surname.Equals(surname));
public MainWindowViewModel() { #region Test AddMemberName = new ReactiveProperty <string>(string.Empty); AddMemberIsLong = new ReactiveProperty <bool>(false); AddMemberIsSelected = new ReactiveProperty <bool>(false); RemoveMemberName = new ReactiveProperty <string>(string.Empty); AddMemberCommand = new AsyncReactiveCommand(); AddMemberCommand.Subscribe(_ => AddMember(AddMemberName.Value, AddMemberIsLong.Value, AddMemberIsSelected.Value)); RemoveMemberCommand = new ReactiveCommand(); RemoveMemberCommand.Subscribe(_ => RemoveMember(RemoveMemberName.Value)); ClearMemberCommand = Members.ObserveProperty(x => x.Count).Select(x => 0 < x).ToReactiveCommand(); ClearMemberCommand.Subscribe(_ => ClearMember()); #endregion PopulateMembers(); Members .ObserveElementProperty(x => x.IsLong) .Where(x => x.Value) .Subscribe(x => ShowName(x.Instance)); Members .ObserveElementObservableProperty(x => x.IsSelected) .Where(x => x.Value) .Subscribe(x => ShowName(x.Instance)); // IsAllLong: Original IsAllLong = Members .ObserveElementProperty(x => x.IsLong) .Select(_ => Members.All(x => x.IsLong)) .ToReactiveProperty(); // IsAllLong: Alternative IFilteredReadOnlyObservableCollection <MemberViewModel> membersNotLong = Members .ToFilteredReadOnlyObservableCollection(x => !x.IsLong); IsAllLong = membersNotLong .CollectionChangedAsObservable() .Select(_ => Members.Any() && (0 == membersNotLong.Count)) .ToReactiveProperty(); // IsAnySelected: Original IsAnySelected = Members .ObserveElementObservableProperty(x => x.IsSelected) .Select(_ => Members.Any(x => x.IsSelected.Value)) .ToReactiveProperty(); // IsAnySelected: Alternative 1 List <MemberViewModel> membersSelected = new List <MemberViewModel>(); IObservable <bool> elementPropertyChanged = Members .ObserveElementObservableProperty(x => x.IsSelected) .Do(x => { if (!x.Value) { membersSelected.Remove(x.Instance); } else if (!membersSelected.Contains(x.Instance)) { membersSelected.Add(x.Instance); } }) .Select(_ => 0 < membersSelected.Count); IObservable <bool> collectionChanged = Members .CollectionChangedAsObservable() .Where(x => x.Action != NotifyCollectionChangedAction.Move) .Do(x => { switch (x.Action) { case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Replace: if (x.OldItems != null) { foreach (var instance in x.OldItems.Cast <MemberViewModel>()) { membersSelected.Remove(instance); } } if (x.NewItems != null) { foreach (var instance in x.NewItems.Cast <MemberViewModel>()) { if (membersSelected.Contains(instance)) { continue; } if (instance.IsSelected.Value) { membersSelected.Add(instance); } } } break; case NotifyCollectionChangedAction.Reset: membersSelected.Clear(); break; } }) .Select(_ => 0 < membersSelected.Count); IsAnySelected = Observable.Merge(elementPropertyChanged, collectionChanged) .ToReactiveProperty(); // IsAnySelected: Alternative 2 IsAnySelected = Members .ObserveElementBooleanObservableProperty(x => x.IsSelected) .Select(x => 0 < x.Count) .ToReactiveProperty(); // IsAnySelected: Alternative 3 IsAnySelected = Members .ObserveElementFilteredObservableProperty(x => x.IsSelected, x => x) .Select(x => 0 < x.Count) .ToReactiveProperty(); }