示例#1
0
        public GroupChangedEvent HandleEntity(IEntity entity)
        {
            GroupChangedEvent groupEvent = null;

            if (entity.GetUuid() >= entitiesCheck.Length)
            {
                IncreaseCheckArray((int)entity.GetUuid());
            }

            if (matcher.Matches(entity))
            {
                if (!entitiesCheck[entity.GetUuid()])
                {
                    entitiesCheck[entity.GetUuid()] = true;
                    entities.Add(entity);
                    entity.Retain();
                    groupEvent = OnEntityAdded;
                }
            }
            else
            {
                if (entitiesCheck[entity.GetUuid()])
                {
                    entitiesCheck[entity.GetUuid()] = false;
                    entities.Remove(entity);
                    entity.Release();
                    groupEvent = OnEntityRemoved;
                }
            }

            return(groupEvent);
        }
 //AutoMapper?
 private GroupChangedNotification GroupChangedDtoConverter(GroupChangedEvent entity)
 {
     return(new GroupChangedNotification
     {
         Participants = entity.Participants != null?entity.Participants
                        .Select(p => new ClientDto.Entities.GroupChatParticipant {
             Avatar = p.Avatar, Name = p.Name, UserId = p.UserId, Devices = p.Devices
         })
                        .ToList() : null,
                            ChangesAuthorId = entity.ChangesAuthorId,
                            Avatar = entity.Avatar,
                            Name = entity.Name,
                            GroupId = entity.GroupId,
                            Type = (GroupChangedNotification.ChangesType)(int) entity.Type
     });
 }
示例#3
0
 private Collector()
 {
     collectedEntitiesCheck  = new bool[0];
     collectedEntities       = new List <IEntity>(1000);
     onEntityGroupEventCache = OnEntityGroupEvent;
 }