public override void Process(GetGlassLoadersPipelineArgs args)
        {
            var automappedAssemblies = IgnitionAutomapHelper.GetAutomappedAssembliesInCurrentDomain();
            var automappedLoaders    = automappedAssemblies.Select(a => new SitecoreAttributeConfigurationLoader(GetShortAssemblyName(a.GetName())));

            args.GlassLoaders.AddRange(automappedLoaders);
        }
Example #2
0
        public void Configure(IServiceCollection serviceCollection)
        {
            var automappedAssemblies = IgnitionAutomapHelper.GetAutomappedAssemblies();

            foreach (var automappedAssembly in automappedAssemblies)
            {
                serviceCollection.AddMvcControllers(automappedAssembly);

                var configuratorTypes = GetServicesConfiguratorTypesFromAssembly(automappedAssembly);
                foreach (var configuratorType in configuratorTypes)
                {
                    var configurator = (IServicesConfigurator)Activator.CreateInstance(configuratorType);
                    configurator.Configure(serviceCollection);
                }
            }
        }
        public override void Process(AddMapsPipelineArgs args)
        {
            var factory = new SitecoreSettingsFactory();
            var automappedAssemblies = IgnitionAutomapHelper.GetAutomappedAssemblies();
            var manyTypes            = automappedAssemblies.SelectMany(s => s.GetTypes());
            var filteredTypes        = manyTypes.Where(p => typeof(IGlassMap).IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface).ToList();

            filteredTypes.ForEach(a => args.MapsConfigFactory.Add(() =>
            {
                var mapper  = (IGlassMap)Activator.CreateInstance(a);
                var setting = mapper as IGlassSettingsConsumer;
                if (setting != null)
                {
                    setting.SettingsFactory = factory;
                }
                return((IGlassMap)setting ?? mapper);
            }));
        }