Пример #1
0
 public void Bootstrap(IDependencyContainer container)
 {
     container.Resolve<IServiceConfigBuilder>()
         .Register<INoteService>()
         .Register<IUserService>();
 }
Пример #2
0
 public UserDataService(IDependencyContainer container)
 {
     _contextCreator = () => container.Resolve <DataContext>();
 }
Пример #3
0
        /// <inheritdoc />
        public object Get(int index, Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (Length <= index)
            {
                throw new CommandIndexOutOfRangeException(index, Length);
            }

            if (index < 0)
            {
                throw new IndexOutOfRangeException();
            }

            string arg = ToArray()[index];



            bool isUser = typeof(IUser).IsAssignableFrom(type);


            //todo make type converters
            if (isUser)
            {
                /*
                 * The logic for getting IUser and IUserInfo is as follows:
                 * If the name is supplied as usermanager:username, e.g. discord:Trojaner, it will search for valid "discord" user manager and return the "Trojaner" named user of it.
                 * Otherwise (if the user manager does not exist or the format was not supplied), it will use the player manager and return the user for the given input.
                 */
                IUserManager targetUserManager = container.Resolve <IPlayerManager>();

                string userName = arg;
                if (arg.Contains(":"))
                {
                    var    args = arg.Split(':');
                    string userManagerMapping = args.First();

                    foreach (var userMgr in container.ResolveAll <IUserManager>())
                    {
                        if (userMgr.ServiceName.Equals(userManagerMapping, StringComparison.OrdinalIgnoreCase))
                        {
                            userName          = string.Join(":", args.Skip(1).ToArray());
                            targetUserManager = userMgr;
                            break;
                        }
                    }
                }

                return(targetUserManager.GetUser(userName));
            }

            TypeConverter converter = TypeConverterExtensions.GetConverter(type);

            if (converter.CanConvertFrom(typeof(string)))
            {
                return(converter.ConvertFromWithContext(container, arg));
            }

            throw new CommandParameterParseException(arg, type);
        }
Пример #4
0
 public EcsRxPipelineNeedsObjectBuilder DeserializeWith <T>() where T : IDeserializer
 {
     _steps.Add(new DeserializeStep(_container.Resolve <T>()));
     return(new EcsRxPipelineNeedsObjectBuilder(_container, _steps));
 }
Пример #5
0
 public EcsRxPipelineNeedsDataBuilder StartFrom <T>() where T : IReceiveDataEndpoint
 {
     return(new EcsRxPipelineNeedsDataBuilder(_container, new List <IPipelineStep> {
         new ReceiveEndpointStep(_container.Resolve <T>())
     }));
 }