/// <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>
        /// 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 AFConfig();

            foreach (var prop in typeof (AFConfig).GetProperties())
            {
                // get properties we can read and write to
                if (!prop.CanRead || !prop.CanWrite)
                    continue;

                var nodeKey = section.SelectSingleNode(prop.Name);
                if (nodeKey != null && nodeKey.Attributes != null)
                {
                    var attribute = nodeKey.Attributes["Value"].Value;
                    var protype = TypeDescriptor.GetConverter(prop.PropertyType);
                    object value = protype.ConvertFromInvariantString(attribute);
                    //set property
                    prop.SetValue(config, value, null);
                }
            }

            return config;
        }
Example #3
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 AFConfig();

            var engineNode = section.SelectSingleNode("Engine");

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

            var startupNode = section.SelectSingleNode("Startup");

            if (startupNode != null && startupNode.Attributes != null)
            {
                var attribute = startupNode.Attributes["IgnoreStartupTasks"];
                if (attribute != null)
                {
                    config.IgnoreStartupTasks = Convert.ToBoolean(attribute.Value);
                }
            }



            var defalutConnetcion = section.SelectSingleNode("DefalutConnetcion");

            if (defalutConnetcion != null && defalutConnetcion.Attributes != null)
            {
                var attribute = defalutConnetcion.Attributes["connectionString"];
                if (attribute != null)
                {
                    config.DefalutConnetcion = attribute.Value;
                }
            }

            var afDataConnetcion = section.SelectSingleNode("AFDataConnetcion");

            if (afDataConnetcion != null && afDataConnetcion.Attributes != null)
            {
                var attribute = afDataConnetcion.Attributes["connectionString"];
                if (attribute != null)
                {
                    config.AfDataConnetcion = attribute.Value;
                }
            }


            var mathHost = section.SelectSingleNode("MathHost");

            if (mathHost != null && mathHost.Attributes != null)
            {
                var attribute = mathHost.Attributes["content"];
                if (attribute != null)
                {
                    config.MathHost = attribute.Value;
                }
            }


            return(config);
        }
 public WebAppTypeFinder(AFConfig config)
 {
     this._ensureBinFolderAssembliesLoaded = config.DynamicDiscovery;
 }