/// <summary>
        ///   Try to accept dependency as a public property
        /// </summary>
        /// <param name="model">Current component model</param>
        /// <param name="dependency">Dependency</param>
        /// <returns>True if success, else false</returns>
        /// <exception cref="ConfigurationProcessingException">If the config property referenced is not found</exception>
        protected bool TryAcceptAsProperty(ComponentModel model, ResolvableDependency dependency)
        {
            PropertySet propKey = model.Properties.FirstOrDefault(f => f.Property.Name.Equals(dependency.Name, StringComparison.OrdinalIgnoreCase));

            if (propKey == null)
            {
                return(false);
            }

            if (propKey.Property.GetSetMethod() == null)
            {
                return(false);
            }

            ParameterModelCollection collection = new ParameterModelCollection();

            if (dependency.Value != null)
            {
                collection.Add(propKey.Property.Name, dependency.Value);
            }
            else if (dependency.IsComponent)
            {
                collection.Add(propKey.Property.Name, "${" + dependency.ConfigName + "}");
            }
            else if (!m_resolver.CanResolve(dependency.ConfigName))
            {
                throw new ConfigurationProcessingException("No config property with name '" + dependency.ConfigName + "' found");
            }
            else
            {
                //collection.Add(propKey.Property.Name, m_resolver.GetConfig(dependency.ConfigName));
                model.CustomDependencies[propKey.Property.Name] = m_resolver.GetValue(dependency.Name, propKey.Property.PropertyType);
            }

            propKey.Dependency.Init(collection);
            m_resolvableProperties.Add(propKey.Property.Name);
            return(true);
        }
예제 #2
0
        /// <summary>
        ///		Carga los parámetros de un tipo
        /// </summary>
        private ParameterModelCollection LoadParameterList(MLNode nodeML, string tag)
        {
            ParameterModelCollection parameters = new ParameterModelCollection();

            // Carga los parámetros
            foreach (MLNode parameterML in nodeML.Nodes)
            {
                if (parameterML.Name == tag)
                {
                    parameters.Add(parameterML.Nodes[TagParameterName].Value,
                                   parameterML.Nodes[TagParameterValue].Value);
                }
            }
            // Devuelve la colección de parámetros
            return(parameters);
        }