Example #1
0
        public override void Load()
        {
            IBindingWithOrOnSyntax <T> bindingWithOrOnSyntax = base.Kernel.Bind <ITask>().To <T>().InTaskScope <T>().Named(taskName);

            if (constructorArgs != null)
            {
                foreach (string current in constructorArgs.Keys)
                {
                    bindingWithOrOnSyntax.WithConstructorArgument(current, constructorArgs[current]);
                }
            }

            base.Kernel.Bind <ITask>().To <NinjectTaskScopeManager>()
            .WhenAnyAncestorNamed(this.taskName + "_timerManager")
            .Named(this.taskName + "_ninjectTask")
            .WithConstructorArgument("taskName", taskName);

            base.Kernel.Bind <ITimerManager>().To <TaskExecutorTimerManager>()
            .Named(this.taskName + "_timerManager")
            .WithConstructorArgument("executeBy", ExecuteBy)
            .WithConstructorArgument("day", Day)
            .WithConstructorArgument("hourStart", HourStart)
            .WithConstructorArgument("hourEnd", HourEnd)
            .WithConstructorArgument("dayOfWeek", DayOfWeek)
            .WithConstructorArgument("minuteStart", MinuteStart)
            .WithConstructorArgument("minuteEnd", MinuteEnd);
        }
Example #2
0
 public EagerAndLazyBindingsWithOrOnSyntax
 (
     IBindingWithOrOnSyntax <T2> eager,
     IBindingWithOrOnSyntax <Lazy <T1> > lazy
 )
 {
     Eager = eager;
     Lazy  = lazy;
 }
Example #3
0
        /// <summary>Binds a runtime mode with a particular name that can be invoked when the program starts using command line arguments.</summary>
        /// <typeparam name="T">The concrete type of the runtime mode to bind.</typeparam>
        /// <param name="root">The binding root.</param>
        /// <param name="name">The name of the runtime mode. This name must be specified in the command line arguments for this runtime mode to be used.</param>
        public static IBindingWithOrOnSyntax <T> BindRuntimeMode <T>(this IBindingRoot root, string name) where T : class, IRuntimeMode
        {
            // Create bindings for the runtime mode so it can be constructed by the container
            IBindingWithOrOnSyntax <T> binding = root.Bind <IRuntimeMode>().To <T>().InSingletonScope().Named(name);

            // Create a named binding for the runtime mode used by the main program
            root.Bind <INamedBinding <IRuntimeMode> >().To <LazyNamedBindingWrapper <T> >().InSingletonScope().Named(name);
            root.Bind <string>().ToConstant(name).WhenInjectedInto <LazyNamedBindingWrapper <T> >().Named("NAME");
            root.BindLazy <T>().WhenInjectedInto <LazyNamedBindingWrapper <T> >();

            return(binding);
        }
Example #4
0
 public LazyBindingWithOrOnSyntax
 (
     IBindingToSyntax <T1> eager,
     IBindingToSyntax <Lazy <T1> > lazy,
     IKernel kernel,
     string name,
     bool inSingletonScope
 )
 {
     _kernel = kernel;
     _name   = name;
     _eager  = eager.To <T2>().Named(name);
     _lazy   = inSingletonScope
         ? lazy.ToMethod(GetInstance).InSingletonScope().Named(name)
         : lazy.ToMethod(GetInstance).Named(name);
 }
 /// <summary>
 /// Indicates that instances associated with this binding will be proxied.
 /// </summary>
 /// <typeparam name="T">The type associated with this binding.</typeparam>
 /// <param name="bindingSyntax">The binding syntax target.</param>
 /// <returns>
 ///     An <see cref="IAdviceTargetSyntax"/> instance which allows the attachment of an <see cref="IInterceptor"/>.
 /// </returns>
 public static IAdviceTargetSyntax Intercept <T>(this IBindingWithOrOnSyntax <T> bindingSyntax)
 {
     return(DoIntercept(bindingSyntax));
 }
Example #6
0
 /// <summary>
 /// Indicates that instances associated with this binding will be proxied.
 /// </summary>
 /// <typeparam name="T">The type associated with this binding.</typeparam>
 /// <param name="bindingSyntax">The binding syntax target.</param>
 /// <param name="additionalInterfaces">The additional interfaces for the proxy.</param>
 /// <returns>
 ///     An <see cref="IAdviceTargetSyntax"/> instance which allows the attachment of an <see cref="IInterceptor"/>.
 /// </returns>
 public static IAdviceTargetSyntax Intercept <T>(this IBindingWithOrOnSyntax <T> bindingSyntax, params Type[] additionalInterfaces)
 {
     return(DoIntercept(bindingSyntax, additionalInterfaces));
 }