public static ReadOnlyConfig GetFullConfig(Type type, IConfig config)
 {
     config = config ?? DefaultConfig.Instance;
     if (type != null)
     {
         var typeAttributes     = type.GetTypeInfo().GetCustomAttributes(true).OfType <IConfigSource>();
         var assemblyAttributes = type.GetTypeInfo().Assembly.GetCustomAttributes().OfType <IConfigSource>();
         var allAttributes      = typeAttributes.Concat(assemblyAttributes);
         foreach (var configSource in allAttributes)
         {
             config = ManualConfig.Union(config, configSource.Config);
         }
     }
     return(config.AsReadOnly());
 }
Exemple #2
0
        public static ReadOnlyConfig GetFullConfig(Type type, IConfig config)
        {
            config = config ?? DefaultConfig.Instance;
            if (type != null)
            {
                var typeAttributes     = type.GetTypeInfo().GetCustomAttributes(true).OfType <IConfigSource>();
                var assemblyAttributes = type.GetTypeInfo().Assembly.GetCustomAttributes().OfType <IConfigSource>();
                var allAttributes      = typeAttributes.Concat(assemblyAttributes);
                var configs            = allAttributes.Select(attribute => attribute.Config)
                                         .OrderBy(c => c.GetJobs().Count(job => job.Meta.IsMutator)); // configs with mutators must be the ones applied at the end

                foreach (var configFromAttribute in configs)
                {
                    config = ManualConfig.Union(config, configFromAttribute);
                }
            }
            return(config.AsReadOnly());
        }