public void Show()
 {
     var failureReason = new NamedParameter("failureReason","The failure reason");
     var failures = new NamedParameter("failures",new List<string>{"Error1", "Error2"});
     ShellViewModel.StartModel = ContainerFactory.Container.Resolve<FailedInstallationViewModel>(failureReason, failures);
     var app = new App();
     app.Run();
 }
 //
 // GET: /Home/
 public ActionResult NormalDependencyInjection()
 {
     var service = DependencyResolver.Current.GetService<IMessageService>();
     //var chineseService = _container.Resolve<IMessageService>(new NamedParameter("serviceName", "chinese"));
     var param = new NamedParameter("Name", "chinese");
     var resolveNamed = new ResolvedParameter((p, c) => p.Name == "chinese_service", (p, c) => c.ResolveNamed<IMessageRepository>("chinese"));
     var chineseService = AutofacDependencyResolver.Current.ResolveByNamed<IMessageService>("chinese_service");
     return View();
 }
        private static IContainer BuildContainer()
        {
            var builder = new ContainerBuilder();
            var fileParameter = new NamedParameter("movieFile", new FileInfo("movies.txt"));

            builder.RegisterType<ColonDelimitedMovieFinder>().As<IMovieFinder>().WithParameter(fileParameter);
            builder.RegisterType<MovieLister>().AsSelf();

            return builder.Build();
        }
        /// <summary>
        /// Adds a parameter with a constant value.
        /// </summary>
        /// <param name="name">The name of the parameter.</param>
        /// <param name="value">The parameter value.</param>
        /// <returns>This GlobalParameterModule instance.</returns>
        public GlobalParameterModule AddParameter(string name, object value)
        {
            if (name == null)
                throw new ArgumentNullException(
                    "name",
                    "name should not be null.");

            if (name.Length == 0)
                throw new ArgumentException(
                    "name should not be an empty string.",
                    "name");

            NamedParameter parameter = new NamedParameter(name, value);

            this.parameters.Add(parameter);

            return this;
        }
Example #5
0
		public IDialogOption GetDialogOption(string text, ITextConfig config = null, ITextConfig hoverConfig = null,
			ITextConfig hasBeenChosenConfig = null, bool speakOption = true, bool showOnce = false)
		{
			IGame game = _resolver.Resolve<IGame>();
			if (config == null) config = new AGSTextConfig (autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
				brush: Hooks.BrushLoader.LoadSolidBrush(Colors.White), font: Hooks.FontLoader.LoadFont(null,10f));
			if (hoverConfig == null) hoverConfig = new AGSTextConfig (autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
				brush: Hooks.BrushLoader.LoadSolidBrush(Colors.Yellow), font: Hooks.FontLoader.LoadFont(null, 10f));
            if (hasBeenChosenConfig == null) hasBeenChosenConfig = new AGSTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
                brush: Hooks.BrushLoader.LoadSolidBrush(Colors.Gray), font: Hooks.FontLoader.LoadFont(null, 10f));
			ILabel label = _ui.GetLabel(string.Format("Dialog option: {0}", text), text, game.Settings.VirtualResolution.Width, 20f, 0f, 0f, config);
			label.Enabled = true;
			TypedParameter labelParam = new TypedParameter (typeof(ILabel), label);
			NamedParameter speakParam = new NamedParameter ("speakOption", speakOption);
			NamedParameter showOnceParam = new NamedParameter ("showOnce", showOnce);
            NamedParameter hoverParam = new NamedParameter ("hoverConfig", hoverConfig);
            NamedParameter wasChosenParam = new NamedParameter("hasBeenChosenConfig", hasBeenChosenConfig);
            TypedParameter playerParam = new TypedParameter(typeof(ICharacter), _gameState.Player);
            IDialogActions dialogActions = _resolver.Resolve<IDialogActions>(playerParam);
            TypedParameter dialogActionsParam = new TypedParameter(typeof(IDialogActions), dialogActions);
            IDialogOption option = _resolver.Resolve<IDialogOption>(labelParam, speakParam, showOnceParam, hoverParam, 
                                                                    wasChosenParam, playerParam, dialogActionsParam);
			return option;
		}
Example #6
0
 public IServiceRunner Create(RunMode runMode)
 {
     var parameter = new NamedParameter(HostModule.RUN_MODE_PARAMETER, runMode);
     return ContainerProvider.Instance.ApplicationContainer.Resolve<IServiceRunner>(parameter);
 }
 public void ScreenShot()
 {
     var failureReason = new NamedParameter("failureReason", "The failure reason");
     var failures = new NamedParameter("failures", new List<string> { "Error1", "Error2" });
     ContainerFactory.Container.Resolve<FailedInstallationViewModel>(failureReason, failures).TakeScreenShot();
 }