Exemplo n.º 1
0
        /// <summary>
        /// Convenience method that constructs a new <see cref="IProvideParts{TTarget}"/>
        /// participant that will invoke your action, and participates it with this composer.
        /// Since this will construct a new participant, the new
        /// added instance is returned here.
        /// See also <see cref="DelegateComposerParticipant{TTarget}"/>.
        /// </summary>
        /// <typeparam name="TTarget">The type of the target handled
        /// by the specific <see cref="IComposer{TTarget}"/>.</typeparam>
        /// <param name="composer">Required.</param>
        /// <param name="provideParts">Required.</param>
        /// <param name="oneTimeOnly">Optional.</param>
        /// <returns>Not null: the added participant.</returns>
        /// <exception cref="ArgumentNullException"/>
        public static DelegateComposerParticipant <TTarget> ParticipatePartsDelegate <TTarget>(
            this IComposer <TTarget> composer,
            Action <ProvidePartsEventArgs <TTarget> > provideParts,
            bool oneTimeOnly = false)
        {
            if (composer == null)
            {
                throw new ArgumentNullException(nameof(composer));
            }
            DelegateComposerParticipant <TTarget> delegateParticipant = new DelegateComposerParticipant <TTarget>(provideParts);

            composer.Participate(delegateParticipant, oneTimeOnly);
            return(delegateParticipant);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Convenience method that constructs a new <see cref="IBootstrap{TTarget}"/>
        /// participant that will invoke your action, and participates it with this composer.
        /// Since this will construct a new participant, the new
        /// added instance is returned here.
        /// See also <see cref="DelegateComposerParticipant{TTarget}"/>.
        /// </summary>
        /// <typeparam name="TTarget">The type of the target handled
        /// by the specific <see cref="IComposer{TTarget}"/>.</typeparam>
        /// <param name="composer">Required.</param>
        /// <param name="bootstrap">Required.</param>
        /// <param name="oneTimeOnly">Optional.</param>
        /// <returns>Not null: the added participant.</returns>
        /// <exception cref="ArgumentNullException"/>
        public static DelegateComposerParticipant <TTarget> ParticipateBootstrapDelegate <TTarget>(
            this IComposer <TTarget> composer,
            Action <ComposerEventArgs <TTarget> > bootstrap,
            bool oneTimeOnly = false)
        {
            if (composer == null)
            {
                throw new ArgumentNullException(nameof(composer));
            }
            DelegateComposerParticipant <TTarget> delegateParticipant = new DelegateComposerParticipant <TTarget>(null, bootstrap);

            composer.Participate(delegateParticipant, oneTimeOnly);
            return(delegateParticipant);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Convenience method that constructs a new <see cref="IRequestComposition{TTarget}"/>
        /// participant that will raise the <see cref="IRequestComposition{TTarget}.CompositionRequested"/>
        /// event, and participates it with this composer.
        /// Since this will construct a new participant, the new
        /// added instance is returned here.
        /// See also <see cref="DelegateComposerParticipant{TTarget}"/>.
        /// </summary>
        /// <typeparam name="TTarget">The type of the target handled
        /// by the specific <see cref="IComposer{TTarget}"/>.</typeparam>
        /// <param name="composer">Required.</param>
        /// <param name="requestComposition">Will be set to an action that will
        /// raise the <see cref="IRequestComposition{TTarget}.CompositionRequested"/>
        /// event from the returned participant.</param>
        /// <param name="oneTimeOnly">Optional.</param>
        /// <returns>Not null: the added participant.</returns>
        /// <exception cref="ArgumentNullException"/>
        public static DelegateComposerParticipant <TTarget> ParticipateRequestCompositionDelegate <TTarget>(
            this IComposer <TTarget> composer,
            out Action <RequestCompositionEventArgs <TTarget> > requestComposition,
            bool oneTimeOnly = false)
        {
            if (composer == null)
            {
                throw new ArgumentNullException(nameof(composer));
            }
            DelegateComposerParticipant <TTarget> delegateParticipant
                = new DelegateComposerParticipant <TTarget>(out requestComposition);

            composer.Participate(delegateParticipant, oneTimeOnly);
            return(delegateParticipant);
        }