private static bool DeserializeDependencyValueElement(
            XmlReader reader,
            string genericParameterName,
            string name,
            out InjectionParameterValueElement valueElement)
        {
            DependencyValueElement element = new DependencyValueElement();

            element.DeserializeElement(reader);

            if (!string.IsNullOrEmpty(genericParameterName) &&
                !string.IsNullOrEmpty(element.TypeName))
            {
                throw new ConfigurationErrorsException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              Resources.MustNotProvideATypeForDependencyIfBelongsToGeneric,
                              name,
                              element.Name),
                          reader);
            }

            valueElement = element;
            return(true);
        }
        private bool DeserializeDependencyValueElement(XmlReader reader)
        {
            DependencyValueElement element = new DependencyValueElement();

            element.DeserializeElement(reader);
            valueElement = element;
            return(true);
        }
        public static InjectionParameterValue CreateParameterValue(
            string typeName,
            string genericParameterName,
            InjectionParameterValueElement valueElement,
            UnityTypeResolver typeResolver)
        {
            string genericParameter;
            bool   isGenericParameterArray;

            ExtractGenericParameter(genericParameterName, out genericParameter, out isGenericParameterArray);

            if (!string.IsNullOrEmpty(genericParameter))
            {
                if (!isGenericParameterArray)
                {
                    if (valueElement == null)
                    {
                        return(new GenericParameter(genericParameter));
                    }
                    else
                    {
                        DependencyValueElement dependencyElement = valueElement as DependencyValueElement;
                        if (dependencyElement != null)
                        {
                            if (!string.IsNullOrEmpty(dependencyElement.Name))
                            {
                                return(new GenericParameter(genericParameter, dependencyElement.Name));
                            }
                            else
                            {
                                return(new GenericParameter(genericParameter));
                            }
                        }
                        else
                        {
                            // should not happen - checked during config deserialization
                            throw new InvalidOperationException(Resources.InvalidConfiguration);
                        }
                    }
                }
                else
                {
                    if (valueElement == null)
                    {
                        return(new GenericResolvedArrayParameter(genericParameter));
                    }
                    else
                    {
                        ArrayValueElement arrayElement = valueElement as ArrayValueElement;
                        if (arrayElement != null)
                        {
                            return(arrayElement.CreateParameterValue(genericParameter));
                        }
                        else
                        {
                            // should not happen - checked during config deserialization
                            throw new InvalidOperationException(Resources.InvalidConfiguration);
                        }
                    }
                }
            }
            else
            {
                if (valueElement == null)
                {
                    valueElement = new DependencyValueElement();
                }
                valueElement.TypeResolver = typeResolver;
                return(valueElement.CreateParameterValue(typeResolver.ResolveType(typeName)));
            }
        }