コード例 #1
0
    /// <summary>
    /// Adds support for creating contents of type <see cref="ConfigurationInstance{T}"/> with any of the given types first generic type argument.
    /// </summary>
    /// <param name="assembler">The <see cref="Assembler"/> to add composites to.</param>
    /// <param name="configTypes">
    /// The types that may be used as generic argument for <see cref="ConfigurationInstance{T}"/>.
    /// If the array is <c>null</c> or empty, this method will have no effect.
    /// </param>
    /// <returns>
    /// The <see cref="PlainCompositeAssemblyDeclaration"/>s of the configuration instance composites.
    /// Notice that the resulting array may be of different size if <paramref name="configTypes"/> was <c>null</c> or contained <c>null</c>s.
    /// </returns>
    /// <exception cref="NullReferenceException">If <paramref name="assembler"/> is <c>null</c>.</exception>
    /// <remarks>
    /// Usually this method is not invoked directly but the method <see cref="AddSupportForSpecificConfigurationInstancesAndManager(Assembler, Type[])"/> is used.
    /// </remarks>
    public static PlainCompositeAssemblyDeclaration[] AddSupportForSpecificConfigurationInstances(this Assembler assembler, params Type[] configTypes)
    {
        PlainCompositeAssemblyDeclaration decl;

        configTypes = configTypes.FilterNulls();
        var result = new PlainCompositeAssemblyDeclaration[configTypes.Length];

        for (var i = 0; i < configTypes.Length; ++i)
        {
            var cType = configTypes[i];
            if (assembler.ForNewOrExistingPlainComposite(new Type[] { typeof(ConfigurationInstance <>).MakeGenericType(cType) }, out decl))
            {
                decl.WithMixins(typeof(ConfigurationInstanceMixin <>).MakeGenericType(cType));
            }
            result[i] = decl;
        }
        return(result);
    }
コード例 #2
0
ファイル: Assembler.cs プロジェクト: CometaSolutions/Qi4CS
 /// <summary>
 /// Helper method to invoke <see cref="Assembler.ForNewOrExistingComposite{T}(CompositeModelType,IEnumerable{System.Type},out T)"/> method with <see cref="CompositeModelType.PLAIN"/> as parameter.
 /// </summary>
 /// <param name="assembler">The <see cref="Assembler"/>.</param>
 /// <param name="types">The composite types.</param>
 /// <param name="result">This parameter will hold the resulting composite declaration.</param>
 /// <returns>The return value of <see cref="Assembler.ForNewOrExistingComposite{T}(CompositeModelType,IEnumerable{System.Type},out T)"/>.</returns>
 public static Boolean ForNewOrExistingPlainComposite(this Assembler assembler, IEnumerable <Type> types, out PlainCompositeAssemblyDeclaration result)
 {
     return(assembler.ForNewOrExistingComposite <PlainCompositeAssemblyDeclaration>(CompositeModelType.PLAIN, types, out result));
 }