/// <summary> /// Loads the specified loaders. /// </summary> /// <param name="loaders">The list of configuration loaders to load into the context.</param> public void Load(params IConfigurationLoader[] loaders) { if (loaders.Any()) { var typeConfigurations = loaders .Select(loader => loader.Load()).Aggregate((x, y) => x.Union(y)); //first we have to add each type config to the collection foreach (var typeConfig in typeConfigurations) { if (TypeConfigurations.ContainsKey(typeConfig.Type)) { Log.Warn("Tried to add type {0} to TypeConfigurationDictioary twice".Formatted(typeConfig.Type)); continue; } typeConfig.PerformAutoMap(); if (!TypeConfigurations.TryAdd(typeConfig.Type, typeConfig)) { Log.Warn("Failed to add type {0} to TypeConfigurationDictionary".Formatted(typeConfig.Type)); } } //then process the properties. //this stops the problem of types not existing for certain data handlers foreach (var typeConfig in typeConfigurations) { ProcessProperties(typeConfig.Properties); } } }
/// <summary> /// Loads the specified loaders. /// </summary> /// <param name="loaders">The list of configuration loaders to load into the context.</param> public void Load(params IConfigurationLoader[] loaders) { if (loaders.Any()) { var typeConfigurations = loaders .Select(loader => loader.Load()).Aggregate((x, y) => x.Union(y)); //first we have to add each type config to the collection foreach (var typeConfig in typeConfigurations) { //don't load generic types or specifically the object type //see https://github.com/mikeedwards83/Glass.Mapper/issues/85 if (typeConfig.Type.IsGenericTypeDefinition || typeConfig.Type == typeof(System.Object)) { continue; } if (TypeConfigurations.ContainsKey(typeConfig.Type)) { Log.Warn("Tried to add type {0} to TypeConfigurationDictioary twice".Formatted(typeConfig.Type)); continue; } typeConfig.PerformAutoMap(); ProcessProperties(typeConfig.Properties); if (!TypeConfigurations.TryAdd(typeConfig.Type, typeConfig)) { Log.Warn("Failed to add type {0} to TypeConfigurationDictionary".Formatted(typeConfig.Type)); } } } }
/// <summary> /// Loads the specified loaders. /// </summary> /// <param name="loaders">The list of configuration loaders to load into the context.</param> public void Load(params IConfigurationLoader[] loaders) { if (loaders.Any()) { var typeConfigurations = loaders .Select(loader => loader.Load()).Aggregate((x, y) => x.Union(y)); //first we have to add each type config to the collection foreach (var typeConfig in typeConfigurations) { //don't load generic types //see https://github.com/mikeedwards83/Glass.Mapper/issues/85 if (typeConfig.Type.IsGenericTypeDefinition) { continue; } if (TypeConfigurations.ContainsKey(typeConfig.Type)) { Log.Warn("Tried to add type {0} to TypeConfigurationDictioary twice".Formatted(typeConfig.Type)); continue; } typeConfig.PerformAutoMap(); if (!TypeConfigurations.TryAdd(typeConfig.Type, typeConfig)) { Log.Warn("Failed to add type {0} to TypeConfigurationDictionary".Formatted(typeConfig.Type)); } } //then process the properties. //this stops the problem of types not existing for certain data handlers foreach (var typeConfig in typeConfigurations) { ProcessProperties(typeConfig.Properties); } } }
/// <summary> /// Loads the specified loaders. /// </summary> /// <param name="loaders">The list of configuration loaders to load into the context.</param> public void Load(params IConfigurationLoader[] loaders) { if (!loaders.Any()) { return; } var typeConfigurations = loaders .Select(loader => loader.Load()).Aggregate((x, y) => x.Union(y)); //first we have to add each type config to the collection foreach (var typeConfig in typeConfigurations) { //don't load generic types or specifically the object type //see https://github.com/mikeedwards83/Glass.Mapper/issues/85 if (typeConfig.Type.IsGenericTypeDefinition || typeConfig.Type == typeof(System.Object)) { continue; } if (TypeConfigurations.ContainsKey(typeConfig.Type)) { Log.Warn("Tried to add type {0} to TypeConfigurationDictioary twice".Formatted(typeConfig.Type)); continue; } typeConfig.PerformAutoMap(); if (!Config.AutoImportBaseClasses) //if we have to import baseclasses... wait for it { ProcessProperties(typeConfig.Properties); } if (!TypeConfigurations.TryAdd(typeConfig.Type, typeConfig)) { Log.Warn("Failed to add type {0} to TypeConfigurationDictionary".Formatted(typeConfig.Type)); } } if (Config.AutoImportBaseClasses) { foreach (var typeconfig in TypeConfigurations) //go through all typeconfigs, one can be changed now { var type = typeconfig.Key; var baseTypes = type.GetBaseClassesAndInterfaces(); foreach (var baseType in baseTypes) { AbstractTypeConfiguration config; if (TypeConfigurations.TryGetValue(baseType, out config)) { typeconfig.Value.Import(config); } } } foreach (var typeConfig in TypeConfigurations.Values) { ProcessProperties(typeConfig.Properties); } } }