// Use this for initialization void Start() { mConfig = new AFConfig(); mConfig.Load(); mConfig.GetSelectServer(ref strTargetIP, ref nPort); String strConfigPath = mConfig.GetConfigPath(); AFCElementManager.Instance.Load(strConfigPath); AFCRenderInterface.Instance.Init(); }
/// <summary> /// Initialize components and plugins in the af environment. /// </summary> /// <param name="config">Config</param> public void Initialize(AFConfig config) { //register dependencies RegisterDependencies(config); //startup tasks if (!config.IgnoreStartupTasks) { RunStartupTasks(); } }
/// <summary> /// Creates a factory instance and adds a http application injecting facility. /// </summary> /// <param name="config">Config</param> /// <returns>New engine instance</returns> protected static IEngine CreateEngineInstance(AFConfig config) { if (config != null && !string.IsNullOrEmpty(config.EngineType)) { var engineType = Type.GetType(config.EngineType); if (engineType == null) { throw new ConfigurationErrorsException("The type '" + config.EngineType + "' could not be found. Please check the configuration at /configuration/af/engine[@engineType] or check for missing assemblies."); } if (!typeof(IEngine).IsAssignableFrom(engineType)) { throw new ConfigurationErrorsException("The type '" + engineType + "' doesn't implement 'Af.Core.Infrastructure.IEngine' and cannot be configured in /configuration/af/engine[@engineType] for that purpose."); } return(Activator.CreateInstance(engineType) as IEngine); } return(new AFEngine()); }
/// <summary> /// Register dependencies /// </summary> /// <param name="config">Config</param> protected virtual void RegisterDependencies(AFConfig config) { var builder = new ContainerBuilder(); var container = builder.Build(); //we create new instance of ContainerBuilder //because Build() or Update() method can only be called once on a ContainerBuilder. //dependencies var typeFinder = new WebAppTypeFinder(config); builder = new ContainerBuilder(); builder.RegisterInstance(config).As <AFConfig>().SingleInstance(); builder.RegisterInstance(this).As <IEngine>().SingleInstance(); builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance(); builder.Update(container); //register dependencies provided by other assemblies builder = new ContainerBuilder(); 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(builder, typeFinder); } builder.Update(container); this._containerManager = new ContainerManager(container); //set dependency resolver DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); }
public WebAppTypeFinder(AFConfig config) { }