public override InjectionParameterValue CreateParameterValue(Type targetType) { Guard.ArgumentNotNull(targetType, "targetType"); if (!targetType.IsArray) { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.ParameterTypeIsNotArray, targetType.Name, this.ElementInformation.Source, this.ElementInformation.LineNumber)); } Type elementType = targetType.GetElementType(); string elementTypeName = elementType.AssemblyQualifiedName; object[] elementValues = new object[elements.Count]; for (int i = 0; i < elements.Count; i++) { elementValues[i] = InjectionParameterValueHelper.CreateParameterValue( elementTypeName, null, elements[i], TypeResolver); } return(new ResolvedArrayParameter(elementType, elementValues)); }
/// <summary> /// Get the <see cref="InjectionParameterValue"/> object for this parameter /// to feed to the container configuration API. /// </summary> /// <returns>The created <see cref="InjectionParameterValue"/> object.</returns> public InjectionParameterValue CreateInjectionParameterValue() { return(InjectionParameterValueHelper.CreateParameterValue( ParameterTypeName, GenericParameterName, valueElement, TypeResolver)); }
///<summary> ///Gets a value indicating whether an unknown element is encountered during deserialization. ///</summary> /// ///<returns> ///true when an unknown element is encountered while deserializing; otherwise, false. ///</returns> /// ///<param name="reader">The <see cref="T:System.Xml.XmlReader"></see> being used for deserialization.</param> ///<param name="elementName">The name of the unknown subelement.</param> ///<exception cref="T:System.Configuration.ConfigurationErrorsException">The element identified by elementName is locked.- or -One or more of the element's attributes is locked.- or -elementName is unrecognized, or the element has an unrecognized attribute.- or -The element has a Boolean attribute with an invalid value.- or -An attempt was made to deserialize a property more than once.- or -An attempt was made to deserialize a property that is not a valid member of the element.- or -The element cannot contain a CDATA or text element.</exception> protected override bool OnDeserializeUnrecognizedElement( string elementName, XmlReader reader) { return(InjectionParameterValueHelper.DeserializeSingleUnrecognizedElement( elementName, reader, Name, GenericParameterName, ref valueElement)); }
/// <summary> /// Return the InjectionMember object represented by this configuration /// element. /// </summary> /// <returns>The injection member object.</returns> public override InjectionMember CreateInjectionMember() { InjectionParameterValue param = InjectionParameterValueHelper.CreateParameterValue( PropertyTypeName, GenericParameterName, valueElement, TypeResolver); return(new InjectionProperty(Name, param)); }
internal InjectionParameterValue CreateParameterValue(string genericParameterName) { object[] elementValues = new object[elements.Count]; for (int i = 0; i < elements.Count; i++) { elementValues[i] = InjectionParameterValueHelper.CreateParameterValue( null, genericParameterName, elements[i], TypeResolver); } return(new GenericResolvedArrayParameter(genericParameterName, elementValues)); }
///<summary> ///Gets a value indicating whether an unknown element is encountered during deserialization. ///</summary> /// ///<returns> ///true when an unknown element is encountered while deserializing; otherwise, false. ///</returns> /// ///<param name="reader">The <see cref="T:System.Xml.XmlReader"></see> being used for deserialization.</param> ///<param name="elementName">The name of the unknown subelement.</param> ///<exception cref="T:System.Configuration.ConfigurationErrorsException">The element identified by elementName is locked.- or -One or more of the element's attributes is locked.- or -elementName is unrecognized, or the element has an unrecognized attribute.- or -The element has a Boolean attribute with an invalid value.- or -An attempt was made to deserialize a property more than once.- or -An attempt was made to deserialize a property that is not a valid member of the element.- or -The element cannot contain a CDATA or text element.</exception> protected override bool OnDeserializeUnrecognizedElement(string elementName, XmlReader reader) { InjectionParameterValueElement element; if (InjectionParameterValueHelper.DeserializeUnrecognizedElement( elementName, reader, "array", null, out element)) { this.elements.Add(element); return(true); } return(false); }
/// <summary> /// Reads XML from the configuration file. /// </summary> /// <param name="reader">The <see cref="XmlReader"/> that reads from the configuration file.</param> /// <param name="serializeCollectionKey"><see langword="true"/> to serialize only the collectionkey properties; /// otherwise, <see langword="false"/>.</param> protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey) { InjectionParameterValueHelper.GuardAttributeOccurrences(reader, "parameterType"); base.DeserializeElement(reader, serializeCollectionKey); }