Пример #1
0
        public void ScanTest(
            IScannerConfig config,
            IHashProvider <string> hashProvider,
            string[] lines,
            ScanResult[] expectedResult)
        {
            AttributeScanner scanner = new AttributeScanner(config, new ScanPreprocessor(), hashProvider);

            foreach (string line in lines)
            {
                scanner.AppendLine(line);
                scanner.Scan();
            }

            IReadOnlyCollection <ScanResult> result = scanner.GetResult();

            result.ShouldAllBeEquivalentTo(expectedResult);
        }
        /// <summary>
        /// Gets the properties by foreign key attribute.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static List <PropertyInfo> GetPropertiesByForeignKeyAttribute(this Type type)
        {
            List <PropertyInfo> result = null;

            using (AttributeScanner <ForeignKeyAttribute> scanner = new AttributeScanner <ForeignKeyAttribute>())
            {
                foreach (var item in scanner.ScanForAttributes(Assembly.GetCallingAssembly(), ClassTypes.Properties, type))
                {
                    if (result == null)
                    {
                        result = new List <PropertyInfo>();
                    }

                    result.Add((PropertyInfo)item.Item2);
                }
            }

            return(result);
        }
        private ISet <Type> FindAllConfigurationTypes()
        {
            var configurationScanner = new AttributeScanner(typeof(ConfigurationAttribute));

            var    assembly       = Assembly.GetEntryAssembly();
            string assemblyFilter = null;

            if (assembly != null)
            {
                assemblyFilter = assembly.GetName().Name;
            }

            Log.Info("Scanning for [Configuration] classes.");
            var configurationTypes = configurationScanner.ScanByAttribute(assemblyFilter);

            // Use component-scan filters to recursilvy scan for more configuration types in the assembly.

            return(configurationTypes);
        }
Пример #4
0
        public static void Run(Type applicationType, dynamic settingObject, string[] args)
        {
            if (!typeof(IApplication).IsAssignableFrom(applicationType))
            {
                throw new NotSupportedException();
            }

            Settings = settingObject;

            var beanManager = new BeanManager();

            var attrScanner = new AttributeScanner(beanManager);

            var beanFactory = new BeanFactory(beanManager);

            beanFactory.CreateAllBeans();

            var application = beanManager.GetBean <IApplication>();

            application.Run(args);

            Console.ReadLine();
        }