Exemplo n.º 1
0
 private static ICompositionContext CreateUserContext(ICompositionContext container, string name)
 {
     var context = container.CreateScopedContext(ScopeNames.User);
     var user = context.GetExport<IUser>();
     user.Name = name;
     return context;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultAppBootstrapper"/> class.
        /// </summary>
        /// <param name="compositionContext">Context for the composition.</param>
        /// <param name="appIntializerFactories">The app intializer factories.</param>
        public DefaultAppBootstrapper(ICompositionContext compositionContext, ICollection<IExportFactory<IAppInitializer, AppServiceMetadata>> appIntializerFactories)
        {
            Contract.Requires(compositionContext != null);

            this.CompositionContext = compositionContext;
            this.AppIntializerFactories = appIntializerFactories ?? new List<IExportFactory<IAppInitializer, AppServiceMetadata>>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultRequestProcessor" /> class.
        /// </summary>
        /// <param name="compositionContext">The composition context.</param>
        /// <param name="filterFactories">The filter factories.</param>
        public DefaultRequestProcessor(ICompositionContext compositionContext, IList<IExportFactory<IRequestProcessingFilter, RequestProcessingFilterMetadata>> filterFactories)
        {
            Contract.Requires(compositionContext != null);
            Contract.Requires(filterFactories != null);

            this.CompositionContext = compositionContext;
            this.filterFactories = filterFactories;
        }
        public object CreateViewModel(HttpContext httpContext, ICompositionContext compositionContext)
        {
            var productId = httpContext.GetRouteValue("id").ToString();

            return(new ProductViewModel()
            {
                ProductId = productId
            });
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OwinAppBootstrapper"/> class.
 /// </summary>
 /// <param name="compositionContext">Context for the composition.</param>
 /// <param name="appIntializerFactories">The app intializer factories.</param>
 public OwinAppBootstrapper(ICompositionContext compositionContext, ICollection<IExportFactory<IAppInitializer, AppServiceMetadata>> appIntializerFactories)
     : base(compositionContext, appIntializerFactories)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositionContextServiceProviderAdapter"/>
        /// class.
        /// </summary>
        /// <param name="compositionContext">Context for the composition.</param>
        public CompositionContextServiceProviderAdapter(ICompositionContext compositionContext)
        {
            Contract.Requires(compositionContext != null);

            this.compositionContext = compositionContext;
        }
 internal static void SetCompositionContext(this HttpRequest request, ICompositionContext compositionContext)
 {
     request.HttpContext.Items.Add(HttpRequestExtensions.CompositionContextKey, compositionContext);
 }
 private DefaultRequestProcessor CreateRequestProcessor(ICompositionContext compositionContainer, IList<IExportFactory<IRequestProcessingFilter, RequestProcessingFilterMetadata>> filterFactories = null)
 {
     filterFactories = filterFactories
                       ?? new List<IExportFactory<IRequestProcessingFilter, RequestProcessingFilterMetadata>>();
     return new DefaultRequestProcessor(compositionContainer, filterFactories);
 }
Exemplo n.º 9
0
 public object CreateViewModel(HttpContext httpContext, ICompositionContext compositionContext)
 {
     return(new CustomViewModel());
 }
 public object CreateViewModel(HttpContext httpContext, ICompositionContext compositionContext)
 {
     return(default);
        /// <summary>
        /// Sets the composition container to the ambient services.
        /// </summary>
        /// <param name="compositionContainer">The composition container.</param>
        /// <returns>
        /// The ambient services builder.
        /// </returns>
        public AmbientServicesBuilder WithCompositionContainer(ICompositionContext compositionContainer)
        {
            Contract.Requires(compositionContainer != null);

            this.AmbientServices.CompositionContainer = compositionContainer;

            return this;
        }
Exemplo n.º 12
0
 public object CreateViewModel(HttpContext httpContext, ICompositionContext compositionContext)
 {
     return(new InvocationCountViewModel());
 }