Exemplo n.º 1
0
        private void HandleChildRemoved(IServiceList <TChildren> sender, TChildren child)
        {
            child.Container         = null;
            child.Bounds.OnChanged -= this.HandleChildBoundsChanged;

            this.TryCleanInline();
        }
 public IService FindByClass(IServiceList list, Type @class)
 {
     return(list
            .GetServices()
            .Where(x => x.Registration.TargetType.IsAssignableFrom(@class))
            .FirstOrDefault());
 }
Exemplo n.º 3
0
 private void HandleUserAdded(IServiceList <IUser> sender, IUser user)
 {
     if (user.Connection != default && !this.Connections.Contains(user.Connection))
     {
         this.Connections.Add(user.Connection);
     }
 }
Exemplo n.º 4
0
 private void HandleUserRemoved(IServiceList <IUser> sender, IUser user)
 {
     if (user.Connection != default && this.Connections.Contains(user.Connection))
     {
         this.Connections.Remove(user.Connection);
     }
 }
Exemplo n.º 5
0
 private void HandleUserLeft(IServiceList <IUser> sender, IUser oldUser)
 {
     // Broadcast the disconnected user id to all connected peers...
     this.Messages[Constants.Messages.Channel.UserLeft].Create(om =>
     {
         om.Write(oldUser.Id);
     }, this.Users.Connections);
 }
Exemplo n.º 6
0
 private void HandleUserAddedToPipe(IServiceList <IUser> sender, IUser args)
 {
     // Broadcast every single networkEntity within the pipe to the new user.
     foreach (INetworkEntity networkEntity in this.Entity.NetworkEntities)
     {
         networkEntity.Messages[Guppy.Network.Constants.Messages.NetworkEntity.Create].Create(args.Connection.Yield());
     }
 }
Exemplo n.º 7
0
        public IEnumerable <IService> FindGenericServices(IServiceList list, Type type)
        {
            if (IsClassValidator.Validate(type))
            {
                return(ClassFinder.FindClasses(list, type));
            }

            return(InterfaceFinder.FindInterfaces(list, type));
        }
Exemplo n.º 8
0
 public ServiceUpdateDatabase(
     IServiceList <Logger> serviceList,
     ILogger <ServiceUpdateDatabase> logger,
     IMediator mediator)
 {
     _serviceList = serviceList;
     _logger      = logger;
     _mediator    = mediator;
 }
Exemplo n.º 9
0
 public CreateManyLoggerCommandHandler(
     IRepositoryCommand <Logger> repository,
     ILogger <CreateManyLoggerCommandHandler> logger,
     IServiceList <Logger> serviceList)
 {
     _repository  = repository;
     _logger      = logger;
     _serviceList = serviceList;
 }
Exemplo n.º 10
0
        public IEnumerable <IService> FindMany(IServiceList list, Type type)
        {
            if (GenericParametersChecker.Check(type))
            {
                return(GenericServiceFinder.FindGenericServices(list, type));
            }

            return(TypeIsClassValidator.Validate(type) ? ByClassFinder.FindManyByClass(list, type) : ByInterfaceFinder.FindManyByInterface(list, type));
        }
Exemplo n.º 11
0
        public IEnumerable <IService> FindClasses(IServiceList list, Type @class)
        {
            IEnumerable <Type> keyParameters = GenericParametersProvider.ProvideGenericTypes(@class);

            return(list
                   .GetServices()
                   .Where(x => x.Registration.RegistrationFlags.Has(RegistrationFlagConstants.HasGenericParameters))
                   .Where(x => x.Registration.RegistrationFlags.SelectValueOrNull <IEnumerable <Type> >(RegistrationFlagConstants.GenericParameters).Count() == keyParameters.Count())
                   .Where(x => x.Registration.RegistrationFlags.SelectValueOrNull <IEnumerable <Type> >(RegistrationFlagConstants.GenericParameters).SequenceEqual(keyParameters)));
        }
Exemplo n.º 12
0
        private void HandleChildAdded(IServiceList <TChildren> sender, TChildren child)
        {
            if (child.Container != null && child.Container != this)
            {
                throw new Exception($"Unable to add child, already resides within another container.");
            }

            child.Container = this;
            child.TryCleanBounds();
            child.Bounds.OnChanged += this.HandleChildBoundsChanged;

            this.TryCleanInline();
        }
Exemplo n.º 13
0
        public IService Find(IServiceList list, Type typeKey)
        {
            if (GenericParametersChecker.Check(typeKey))
            {
                return(GenericServiceFinder
                       .FindGenericServices(list, typeKey)
                       .FirstOrDefault());
            }

            bool isClass = TypeIsClassValidator.Validate(typeKey);

            return(isClass ? ByClassFinder.FindByClass(list, typeKey) : ByInterfaceFinder.FindByInterface(list, typeKey));
        }
Exemplo n.º 14
0
        public void Register(IServiceList list, IEnumerable <IService> services)
        {
            IEnumerable <IService> filteredList = RegistratedServicesFilter.Filter(list, services);

            foreach (IService service in filteredList)
            {
                if (!InstanceChecker.Check(service))
                {
                    InstanceProvider.ProvideInstance(service);
                }

                list.AddService(service);
            }
        }
Exemplo n.º 15
0
        public IEnumerable <IService> FindManyByInterface(IServiceList list, Type @interface)
        {
            foreach (IService service in list.GetServices())
            {
                IEnumerable <IInterface> interfaces = InterfacesExtractor.ExtractInterfaces(service.Registration);

                IEnumerable <IInterface> matchingInterfaces = interfaces
                                                              .Where(x => !x.HasGenericArguments)
                                                              .Where(x => Comparer.Compare(@interface, x.Type));

                if (matchingInterfaces.Any())
                {
                    yield return(service);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Throw an exception when a later is added to the
        /// collection.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private bool CanAddLayer(IServiceList <ILayer> list, ILayer item)
        {
            foreach (Layer layer in this)
            {
                if (item.Id == layer.Id)
                {
                    return(false);
                }
                else if (item.Group.Overlap(layer.Group))
                {
                    throw new Exception("Unable to add Layer to collection, Group overlap detected.");
                }
            }

            return(true);
        }
Exemplo n.º 17
0
        private void HandleUserJoined(IServiceList <IUser> sender, IUser newUser)
        {
            // Broadcast a list of all users to the new user...
            foreach (IUser user in this.Users)
            {
                if (user != newUser)
                {
                    this.Messages[Constants.Messages.Channel.UserJoined].Create(om =>
                    {
                        user.TryWrite(om);
                    }, newUser.Connection.Yield());
                }
            }

            // Broadcast the new users to all connected users.
            this.Messages[Constants.Messages.Channel.UserJoined].Create(om =>
            {
                newUser.TryWrite(om);
            }, this.Users.Connections);
        }
Exemplo n.º 18
0
        public IEnumerable <IService> FindInterfaces(IServiceList list, Type @interface)
        {
            // return list.GetServices()
            //     .Where(x => x.Registration.Interfaces.Count > 0)
            //     .Where(x => x.Registration.Interfaces.Where(x => x.HasGenericArguments).Any())
            //     .Where(x => x.Registration.Interfaces.Where(x => Comparer.Compare(@interface, x.Type)).Any());


            // TODO provizory
            foreach (IService service in list.GetServices())
            {
                IEnumerable <IInterface> interfaces = InterfacesExtractor.ExtractInterfaces(service.Registration);

                IEnumerable <IInterface> matchingInterfaces = interfaces
                                                              .Where(x => x.HasGenericArguments)
                                                              .Where(x => Comparer.Compare(@interface, x.Type));

                if (matchingInterfaces.Any())
                {
                    yield return(service);
                }
            }
        }
Exemplo n.º 19
0
 private void HandleChannelAdded(IServiceList <IChannel> sender, IChannel args)
 {
     _channels.Add(args.Id, args);
 }
 public IEnumerable <IService> Filter(IServiceList list, IEnumerable <IService> services)
 {
     return(services.Where(x => list.GetServices().SingleOrDefault(y => y.Registration.TargetType == x.Registration.TargetType) == null));
 }
Exemplo n.º 21
0
 private void HandleChannelRemoved(IServiceList <IChannel> sender, IChannel args)
 {
     _channels.Remove(args.Id);
 }
Exemplo n.º 22
0
 public QueueController(IServiceList <Logger> serviceList)
 {
     _serviceList = serviceList;
 }
Exemplo n.º 23
0
 public bool Check(IServiceList list, Type type)
 {
     return(Finder.Find(list, type) != null);
 }
Exemplo n.º 24
0
 public IEnumerable <IService> FindManyByClass(IServiceList list, Type @class)
 {
     return(list
            .GetServices()
            .Where(x => x.Registration.TargetType.IsAssignableFrom(@class)));
 }
Exemplo n.º 25
0
 private void HandleNetworkEntityRemovedFromPipe(IServiceList <INetworkEntity> sender, INetworkEntity networkEntity)
 {
     // Broadcast the delete message to all users who are not also in the new NE's pipe.
     networkEntity.Messages[Guppy.Network.Constants.Messages.NetworkEntity.Delete].Create(
         this.Entity.Users.Connections.Except(networkEntity.Pipe?.Users.Connections ?? Enumerable.Empty <NetConnection>()));
 }
Exemplo n.º 26
0
 private void HandleNetworkEntityAddedToPipe(IServiceList <INetworkEntity> sender, INetworkEntity networkEntity)
 {
     // Broadcast create message through the pipe...
     networkEntity.Messages[Guppy.Network.Constants.Messages.NetworkEntity.Create].Create(this.Entity);
 }
Exemplo n.º 27
0
 private void HandleUserConnected(IServiceList <IUser> sender, IUser args)
 {
     this.Channel.Users.TryAdd(args);
     this.Channel.Pipes.GetOrCreateById(Guid.Empty).Users.TryAdd(args);
 }
Exemplo n.º 28
0
 private void HandleUserJoined(IServiceList <IUser> sender, IUser args)
 {
     // throw new NotImplementedException();
 }