Exemplo n.º 1
0
        public virtual void Configure(IEngine engine, ContainerManager containerManager, EventBroker broker, AgileEAPConfigure configuration)
        {
            //other dependencies
            containerManager.AddComponentInstance<AgileEAPConfigure>(configuration, "AgileEAP.configuration");
            containerManager.AddComponentInstance<IEngine>(engine, "AgileEAP.engine");
            containerManager.AddComponentInstance<ContainerConfigurer>(this, "AgileEAP.containerConfigurer");

            //type finder
            containerManager.AddComponent<ITypeFinder, WebAppTypeFinder>("AgileEAP.typeFinder");

            //register dependencies provided by other assemblies
            var typeFinder = containerManager.Resolve<ITypeFinder>();
            containerManager.UpdateContainer(x =>
            {
                var drTypes = typeFinder.FindClassesOfType<IDependencyRegistrar>();
                var drInstances = new List<IDependencyRegistrar>();
                foreach (var drType in drTypes)
                    drInstances.Add((IDependencyRegistrar)Activator.CreateInstance(drType));
                //sort
                drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList();
                foreach (var dependencyRegistrar in drInstances)
                    dependencyRegistrar.Register(x, typeFinder);
            });

            //event broker
            containerManager.AddComponentInstance(broker);

            //service registration
            containerManager.AddComponent<DependencyAttributeRegistrator>("AgileEAP.serviceRegistrator");
            var registrator = containerManager.Resolve<DependencyAttributeRegistrator>();
            var services = registrator.FindServices();
            var configurations = GetComponentConfigurations(configuration);
            services = registrator.FilterServices(services, configurations);
            registrator.RegisterServices(services);
        }
Exemplo n.º 2
0
 protected virtual string[] GetComponentConfigurations(AgileEAPConfigure configuration)
 {
     var configurations = new List<string>();
     string trustConfiguration = (CommonHelper.GetTrustLevel() > System.Web.AspNetHostingPermissionLevel.Medium)
         ? ConfigurationKeys.FullTrust
         : ConfigurationKeys.MediumTrust;
     configurations.Add(trustConfiguration);
     return configurations.ToArray();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a factory instance and adds a http application injecting facility.
        /// </summary>
        /// <returns>A new factory</returns>
        public static IEngine CreateEngineInstance(AgileEAPConfigure config)
        {
            if (config != null && !string.IsNullOrEmpty(config.EngineType))
            {
                var engineType = Type.GetType(config.EngineType);
                if (engineType == null)
                    throw new ConfigurationErrorsException("The type '" + engineType + "' could not be found. Please check the configuration at /configuration/AgileEAP/engine[@engineType] or check for missing assemblies.");
                if (!typeof(IEngine).IsAssignableFrom(engineType))
                    throw new ConfigurationErrorsException("The type '" + engineType + "' doesn't implement 'AgileEAP.Core.Infrastructure.IEngine' and cannot be configured in /configuration/AgileEAP/engine[@engineType] for that purpose.");
                return Activator.CreateInstance(engineType) as IEngine;
            }

            return new AgileEAPEngine();
        }
Exemplo n.º 4
0
 public WebAppTypeFinder(AgileEAPConfigure config)
 {
     this._ensureBinFolderAssembliesLoaded = config.DynamicDiscovery;
 }
Exemplo n.º 5
0
 public ThemeProvider(AgileEAPConfigure configure, IWebHelper webHelper)
 {
     basePath = webHelper.MapPath(configure.ThemeBasePath);
     LoadConfigurations();
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a configuration section handler.
        /// </summary>
        /// <param name="parent">Parent object.</param>
        /// <param name="configContext">Configuration context object.</param>
        /// <param name="section">Section XML node.</param>
        /// <returns>The created section handler object.</returns>
        public object Create(object parent, object configContext, XmlNode section)
        {
            var config = new AgileEAPConfigure();
            var dynamicDiscoveryNode = section.SelectSingleNode("DynamicDiscovery");
            if (dynamicDiscoveryNode != null && dynamicDiscoveryNode.Attributes != null)
            {
                var attribute = dynamicDiscoveryNode.Attributes["Enabled"];
                if (attribute != null)
                    config.DynamicDiscovery = Convert.ToBoolean(attribute.Value);
            }

            var engineNode = section.SelectSingleNode("Engine");
            if (engineNode != null && engineNode.Attributes != null)
            {
                var attribute = engineNode.Attributes["Type"];
                if (attribute != null)
                    config.EngineType = attribute.Value;
            }

            var themeNode = section.SelectSingleNode("Themes");
            if (themeNode != null && themeNode.Attributes != null)
            {
                var attribute = themeNode.Attributes["basePath"];
                if (attribute != null)
                    config.ThemeBasePath = attribute.Value;
            }

            //var database = section.SelectSingleNode("Themes");

            return config;
        }