/// <summary> /// Finds the parameter by looking at the cache, then in the model configuration. /// </summary> /// <param name="model">Model of the component that is requesting the dependency</param> /// <param name="dependency">The dependcy to satisfy</param> /// <returns>True if processing success, else false</returns> private bool ProcessDependency(ComponentModel model, DependencyModel dependency) { string uniqueKey = model.Implementation.FullName + "+" + dependency.DependencyKey; if (VALUES.ContainsKey(uniqueKey)) { return(true); } IConfiguration parameterNodeConfig = model.Configuration.Children[Constants.ParamsConfigKey]; if (parameterNodeConfig == null) { return(false); } IConfiguration paramConfig = parameterNodeConfig.Children.SingleOrDefault(f => f.Name == dependency.DependencyKey); if (paramConfig == null) { return(false); } //throw new ConfigurationProcessingException(string.Format("Missing parameter value for parameter '{0}'", dependency.DependencyKey)); EPathType?pathType = RelativePathUtil.GetPathType(paramConfig); if (!pathType.HasValue) { return(false); } RelativePathUtil.ConvertPaths(paramConfig, null); IConfiguration processedConfig = null; if (paramConfig.Children.Count > 0) { IConfiguration firstChild = paramConfig.Children[0]; string configName = firstChild.Name.ToLowerInvariant(); if (SpecialNodes.Contains(configName)) { processedConfig = new MutableConfiguration(paramConfig.Name, string.Empty); processedConfig.Children.AddRange(firstChild.Children); } } else { processedConfig = paramConfig; } object value = m_converter.PerformConversion(processedConfig, dependency.TargetType); VALUES[uniqueKey] = value; return(true); }
/// <summary> /// Get property configuration /// </summary> /// <param name="propertyName">Property name</param> /// <returns>Property configuration</returns> public IConfiguration GetConfig(string propertyName) { XmlElement property = m_processor.GetProperty(propertyName); IConfiguration config = PropertyDeserializer.Deserialize(property); // get the flag indicating whether we want to resolve relative paths // this flag is set by the RelativePathSubDependencyResolver when it // gets registered as a sub dependency resolver with castle bool resolveRelativePaths = m_converter.Context.Kernel.GetSettingsSubSystem().ResolveRelativePaths; if (resolveRelativePaths) { RelativePathUtil.ConvertPaths(config, null); } return(config); }