예제 #1
0
        private IInputCommand CreateCommandFromAlias(string alias)
        {
            // Get all of the IInputCommand Types that have been registered.
            IEnumerable <Type> commandTypes = this.container.ComponentRegistry.Registrations
                                              .Where(service => typeof(IInputCommand).IsAssignableFrom(service.Activator.LimitType))
                                              .Select(service => service.Activator.LimitType);

            Type commandToInstance = commandTypes
                                     .FirstOrDefault(type => TypePool.GetAttribute <CommandAliasAttribute>(
                                                         type: type,
                                                         property: null,
                                                         predicate: attribute => attribute.Alias.ToLower().Equals(alias.ToLower())) != null);

            return(commandToInstance == null ? null : this.container.Resolve(commandToInstance) as IInputCommand);
        }