Пример #1
0
        internal void LoadCommands()
        {
            try
            {
                _interfaceType = typeof(IWebCommand);
                var assemblies = AssemblyLocator.GetAssemblies();

                var results = from a in assemblies
                              from t in a.GetTypes()
                              where _interfaceType.IsAssignableFrom(t)
                              select t;

                _commandTypes = results.ToList();
            }
            catch (ReflectionTypeLoadException ex)
            {
                var text = string.Join(", ", ex.LoaderExceptions.Select(e => e.Message));
                throw new ApplicationException(text);
            }

            //if we still cant find any throw exception
            if (_commandTypes == null || !_commandTypes.Any())
            {
                throw new ApplicationException("No commands found");
            }
        }
Пример #2
0
        internal void LoadCommands()
        {
            try
            {
                var assemblies = AssemblyLocator.GetAssemblies();

                _commandTypes = assemblies.SelectMany(x => x.GetTypes().MarkedWith <WebCommandTypeAttribute>()).ToList();

                _commandMethods = _commandTypes.SelectMany(x => x.GetMethods().MarkedWith <WebCommandAttribute>())
                                  .Where(y =>
                                         (y.ReturnType == typeof(CommandResult) || y.ReturnType == typeof(string))
                                         )
                                  .ToList();
            }
            catch (ReflectionTypeLoadException ex)
            {
                var text = string.Join(", ", ex.LoaderExceptions.Select(e => e.Message));
                throw new ApplicationException(text);
            }

            //if we still cant find any throw exception
            if (_commandTypes == null || !_commandTypes.Any())
            {
                throw new ApplicationException("No commands found");
            }
        }
Пример #3
0
        internal void LoadCommands()
        {
            _interfaceType = typeof(IWebCommand);
            var assemblies = AssemblyLocator.GetAssemblies();

            var results = from a in assemblies
                          from t in TryGetTypes(a)
                          where _interfaceType.IsAssignableFrom(t)
                          select t;

            _commandTypes = results.ToList();

            //if we still cant find any throw exception
            if (_commandTypes == null || !_commandTypes.Any())
            {
                throw new ApplicationException("No commands found");
            }
        }