Example #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());
 }
Example #3
0
 private void HandleUserAdded(IServiceList <IUser> sender, IUser user)
 {
     if (user.Connection != default && !this.Connections.Contains(user.Connection))
     {
         this.Connections.Add(user.Connection);
     }
 }
Example #4
0
 private void HandleUserRemoved(IServiceList <IUser> sender, IUser user)
 {
     if (user.Connection != default && this.Connections.Contains(user.Connection))
     {
         this.Connections.Remove(user.Connection);
     }
 }
Example #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);
 }
Example #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());
     }
 }
Example #7
0
        public IEnumerable <IService> FindGenericServices(IServiceList list, Type type)
        {
            if (IsClassValidator.Validate(type))
            {
                return(ClassFinder.FindClasses(list, type));
            }

            return(InterfaceFinder.FindInterfaces(list, type));
        }
Example #8
0
 public ServiceUpdateDatabase(
     IServiceList <Logger> serviceList,
     ILogger <ServiceUpdateDatabase> logger,
     IMediator mediator)
 {
     _serviceList = serviceList;
     _logger      = logger;
     _mediator    = mediator;
 }
Example #9
0
 public CreateManyLoggerCommandHandler(
     IRepositoryCommand <Logger> repository,
     ILogger <CreateManyLoggerCommandHandler> logger,
     IServiceList <Logger> serviceList)
 {
     _repository  = repository;
     _logger      = logger;
     _serviceList = serviceList;
 }
Example #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));
        }
Example #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)));
        }
Example #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();
        }
Example #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));
        }
        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);
            }
        }
Example #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);
                }
            }
        }
Example #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);
        }
Example #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);
        }
Example #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);
                }
            }
        }
Example #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));
 }
Example #21
0
 private void HandleChannelRemoved(IServiceList <IChannel> sender, IChannel args)
 {
     _channels.Remove(args.Id);
 }
Example #22
0
 public QueueController(IServiceList <Logger> serviceList)
 {
     _serviceList = serviceList;
 }
 public bool Check(IServiceList list, Type type)
 {
     return(Finder.Find(list, type) != null);
 }
 public IEnumerable <IService> FindManyByClass(IServiceList list, Type @class)
 {
     return(list
            .GetServices()
            .Where(x => x.Registration.TargetType.IsAssignableFrom(@class)));
 }
Example #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>()));
 }
Example #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);
 }
Example #27
0
 private void HandleUserConnected(IServiceList <IUser> sender, IUser args)
 {
     this.Channel.Users.TryAdd(args);
     this.Channel.Pipes.GetOrCreateById(Guid.Empty).Users.TryAdd(args);
 }
Example #28
0
 private void HandleUserJoined(IServiceList <IUser> sender, IUser args)
 {
     // throw new NotImplementedException();
 }