Should class NopObjectContext use GetExecutingAssembly to make the code more elegant?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
In class NopObjectContext  

System.Type configType = typeof(LanguageMap);   //any of your configuration classes here
            var typesToRegister = Assembly.GetAssembly(configType).GetTypes()
            .Where(type => !String.IsNullOrEmpty(type.Namespace))
            .Where(type => type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition()


This makes NopObjectContext  dependent on namespace Nop.Data.Mapping.Localization, which kind of break the design rules.

If we change it as

            var typesToRegister = Assembly.GetExecutingAssembly ().GetTypes()
            .Where(type => !String.IsNullOrEmpty(type.Namespace))
            .Where(type => type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition()

Which will take the dependency off.

Will that make the code look better?

Thanks
11 years ago
Thanks a lot for suggestion
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.