コード例 #1
0
ファイル: ArrayValueElement.cs プロジェクト: formist/LinkMe
        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));
        }
コード例 #2
0
 /// <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));
 }
コード例 #3
0
        /// <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));
        }
コード例 #4
0
ファイル: ArrayValueElement.cs プロジェクト: formist/LinkMe
 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));
 }