当前位置: 首页>>代码示例>>C#>>正文


C# SimpleContainer.Singleton方法代码示例

本文整理汇总了C#中SimpleContainer.Singleton方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleContainer.Singleton方法的具体用法?C# SimpleContainer.Singleton怎么用?C# SimpleContainer.Singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleContainer的用法示例。


在下文中一共展示了SimpleContainer.Singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

        protected override void Configure()
        {
            _container = new SimpleContainer();

            _container.Singleton<IWindowManager, WindowManager>();
            _container.Singleton<IEventAggregator, EventAggregator>();

            _container.Singleton<IShell, ShellViewModel>();

            _container.Singleton<ConfigurationStore>();

            _container.Singleton<CreateAccountViewModel>();
            _container.Singleton<AccountsViewModel>();
            _container.Singleton<SessionsViewModel>();
            _container.Singleton<FooterViewModel>();
            _container.Singleton<LoggedOutViewModel>();

            _container.PerRequest<DetailsViewModel>();
            _container.PerRequest<CharacterViewModel>();
            _container.PerRequest<CharacterDetailsViewModel>();
            _container.PerRequest<HallOfFameCrawlerViewModel>();
            _container.Singleton<NoCharacterSelectedViewModel>();
            _container.PerRequest<ScrapbookViewModel>();
            _container.PerRequest<ScrapbookItemViewModel>();
        }
开发者ID:ebeeb,项目名称:SfSdk,代码行数:25,代码来源:SfBootstrapper.cs

示例2: Configure

        protected override void Configure() {
            container = new SimpleContainer();

            container.Singleton<IWindowManager, WindowManager>();
            container.Singleton<IEventAggregator, EventAggregator>();
            container.PerRequest<IShell, ShellViewModel>();
        }
开发者ID:alaskaninja,项目名称:Overheads,代码行数:7,代码来源:AppBootstrapper.cs

示例3: Configure

        protected override void Configure() {
            container = new SimpleContainer();
            GlobalData.SetContainer(container);

            container.Singleton<IWindowManager, WindowManager>();
            container.Singleton<IEventAggregator, EventAggregator>();
            container.Singleton<IShell, ShellViewModel>();//这里必须是,Singleton 因为 ShellViewModel 要在其它子界面中用到,
        }
开发者ID:bushadam,项目名称:QM,代码行数:8,代码来源:AppBootstrapper.cs

示例4: Configure

        protected override void Configure()
        {
            _container = new SimpleContainer();
            _container.Instance(_container);
            _container.Singleton<IWindowManager, WindowManager>();
            _container.Singleton<IEventAggregator, EventAggregator>();

            _container.Singleton<IUIManager, UIManager>();
            _container.Singleton<IEventDispatcher, EventDispatcher>();

            _container.Singleton<TextBlockViewManager>();
            _container.Singleton<ButtonViewManager>();
            _container.Singleton<ContainerViewManager>();
            _container.Singleton<StackPanelViewManager>();

            _container.Instance<IReactAssemblyProvider>(new ReactAssemblyProvider(SelectAssemblies));

            //            _container.PerRequest<IJavaScriptExecutor, JavaScriptCoreExecutor>();
            _container.PerRequest<IJavaScriptExecutor, WebSocketExecutor>();
            _container.Singleton<IReactBridge, ReactBridgeImpl>();
            _container.PerRequest<IModuleLoader, ModuleLoader>();
            _container.PerRequest<ReactRootViewModel>();
            _container.PerRequest<ReactTextBlockViewModel>();
            _container.PerRequest<ReactButtonViewModel>();
            _container.PerRequest<ReactContainerViewModel>();

            _container.PerRequest<IShell, ShellViewModel>();
            _container.PerRequest<CefSampleViewModel>();
            _container.PerRequest<WebSocketSampleViewModel>();
        }
开发者ID:joemcbride,项目名称:react-native-wpf,代码行数:30,代码来源:SampleAppBootstrapper.cs

示例5: Configure

        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton<IWindowManager, WindowManager>();
            container.Singleton<IEventAggregator, EventAggregator>();
            container.PerRequest<IShell, MainViewModel>();
            container.PerRequest<IScreen, FieldsViewModel>();
            container.PerRequest<IScreen, ServicesViewModel>();
            container.PerRequest<IScreen, CommissionsViewModel>();
        }
开发者ID:TheBorusik,项目名称:OperatorCreator,代码行数:11,代码来源:AppBootstrapper.cs

示例6: Configure

        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton<IWindowManager, WindowManager>();
            container.Singleton<IEventAggregator, EventAggregator>();
            container.PerRequest<IShell, ShellViewModel>();
            container.Singleton<ISearchService, SearchService>();
            container.Singleton<MainViewModel>();

            AddCustomConventions();
        }
开发者ID:vincenzo-petronio,项目名称:LibraryHelper,代码行数:12,代码来源:AppBootstrapper.cs

示例7: Configure

		protected override void Configure()
		{
			container = new SimpleContainer();

			container.Singleton<IWindowManager, WindowManager>();
			container.Singleton<IEventAggregator, EventAggregator>();
			container.PerRequest<IShell, ShellViewModel>();

            // Services registrations.
            container.Singleton<IFileSelector, FileSelector>();
            container.Singleton<FileHashGenerator>();
		}
开发者ID:swcomp,项目名称:SW.FileHashChecker,代码行数:12,代码来源:AppBootstrapper.cs

示例8: SingletonTest

		public void SingletonTest()
		{
			SimpleContainer sc = new SimpleContainer();
			sc.Singleton<Test1>();
			var result = sc.GetInstance<Test1>();
			Assert.IsNotNull(result);

			var result2 = sc.GetInstance<Test1>();
			Assert.IsNotNull(result2);
			Assert.AreEqual(result, result2);

			sc.Singleton<ITest2, Test2>();
			var result3 = sc.GetInstance<ITest2>();
			Assert.IsNotNull(result3);
			Assert.IsInstanceOfType(result3, typeof(ITest2));
			Assert.IsInstanceOfType(result3, typeof(Test2));
			Assert.AreNotEqual(result2, result3);

			var result4 = sc.GetInstance<Test2>();
			Assert.IsNotNull(result4);
			Assert.IsInstanceOfType(result4, typeof(ITest2));
			Assert.IsInstanceOfType(result4, typeof(Test2));
			Assert.AreEqual(result3, result4);



			sc.Singleton<ITest4, Test4>();
			ITest4 result5;
			bool thrown = false;
			try
			{
				result5 = sc.GetInstance<ITest4>();
			}
			catch (TypeLoadException)
			{
				thrown = true;
			}

			Assert.IsTrue(thrown);
			sc.Singleton<ITest3, Test3>();

			result5 = sc.GetInstance<ITest4>();

			Assert.IsNotNull(result5);
			Assert.IsInstanceOfType(result5, typeof(ITest4));
			Assert.IsInstanceOfType(result5, typeof(Test4));
			Assert.IsNotNull(result5.Test3);
			Assert.IsInstanceOfType(result5.Test3, typeof(ITest3));
			Assert.IsInstanceOfType(result5.Test3, typeof(Test3));
		}
开发者ID:holtsoftware,项目名称:House,代码行数:50,代码来源:SimpleContainerTests.cs

示例9: Configure

        protected override void Configure() {
            container = new SimpleContainer();

            container.Singleton<IWindowManager, WindowManager>();
            container.Singleton<IEventAggregator, EventAggregator>();
            container.PerRequest<IShell, ShellViewModel>();

            container.Instance(new Company
                {
                    Name = "The Company",
                    Address = "Some Road",
                    Website = "http://thecompany.com",
                });
        }
开发者ID:Geminior,项目名称:Caliburn.Micro.Extras,代码行数:14,代码来源:AppBootstrapper.cs

示例10: BuildContainer

        private ISimpleContainer BuildContainer()
        {
            var container = new SimpleContainer();
            container.Singleton<IDocumentExecuter>(new DocumentExecuter());
            container.Singleton<IDocumentWriter>(new DocumentWriter(true));

            container.Singleton(new StarWarsData());
            container.Register<StarWarsQuery>();
            container.Register<HumanType>();
            container.Register<DroidType>();
            container.Register<CharacterInterface>();
            container.Singleton(new StarWarsSchema(type => (GraphType) container.Get(type)));

            return container;
        }
开发者ID:graphql-dotnet,项目名称:graphql-dotnet,代码行数:15,代码来源:Bootstrapper.cs

示例11: Application

        public Application(SimpleContainer container)
        {
            this.container = container;

            Initialize();

            ViewModelLocator.AddNamespaceMapping("NDC.Build.Forms.Core.Views", "NDC.Build.Core.ViewModels");
            ViewLocator.AddNamespaceMapping("NDC.Build.Core.ViewModels", "NDC.Build.Forms.Core.Views");

            MessageBinder.SpecialValues.Add("$tappedItem", GetTappedItem);

            container.Instance<FormsApplication>(this);

            container
               .Singleton<ITeamServicesClient, OfflineTeamServicesClient>()
               .Singleton<IAuthenticationService, OfflineAuthenticationService>()
               .Singleton<IApplicationNavigationService, ApplicationNavigationService>()
               .Singleton<IDialogService, ActionSheetDialogService>();

            container
                .PerRequest<LoginViewModel>()
                .PerRequest<ProjectsViewModel>()
                .PerRequest<BuildsViewModel>();

            DisplayRootView<LoginView>();
        }
开发者ID:nigel-sampson,项目名称:talks,代码行数:26,代码来源:Application.cs

示例12: Application

        public Application(SimpleContainer container)
        {
            this.container = container;

            ConventionManager.AddElementConvention<SearchBar>(SearchBar.TextProperty, "Text", "SearchButtonPressed");

            ViewModelLocator.AddNamespaceMapping("Hubb.Forms.Core.Views", "Hubb.Core.ViewModels");
            ViewLocator.AddNamespaceMapping("Hubb.Core.ViewModels", "Hubb.Forms.Core.Views");

            Initialize();

            container
                .Instance<IGitHubClient>(new GitHubClient(new ProductHeaderValue("hubb-forms", "1.0.0")));

            container
                .Singleton<IAuthenticationService, AuthenticationService>()
                .Singleton<IRepositoryService, RepositoryService>()
                .Singleton<IAppNavigationService, AppNavigationService>();

            container
                .PerRequest<LoginViewModel>()
                .PerRequest<RepositorySearchViewModel>();

            DisplayRootView<LoginView>();
        }
开发者ID:nigel-sampson,项目名称:talks,代码行数:25,代码来源:Application.cs

示例13: Configure

        protected override void Configure()
        {
            _container = new SimpleContainer();

            _container.Singleton<IImageService, ImageService>();
            _container.Singleton<ISettingsService, SettingsService>();
            _container.Singleton<ILoggerService, LoggerService>();
            _container.Singleton<IParserService, ParserService>();
            _container.Singleton<IWindowManager, WindowManager>();

            _container.Singleton<MainViewModel>();
            _container.Singleton<AbilityViewModel>();
            _container.Singleton<LogViewModel>();
            _container.Singleton<AboutViewModel>();
            _container.Singleton<SettingsViewModel>();
        }
开发者ID:ahmetabdi,项目名称:swtor-caster,代码行数:16,代码来源:Bootstrapper.cs

示例14: Configure

        protected override void Configure()
        {
            container = new SimpleContainer();
            container.Instance(container);

            container.Singleton<App>();
        }
开发者ID:mvermef,项目名称:Caliburn.Micro,代码行数:7,代码来源:Application.cs

示例15: Configure

		protected override void Configure()
		{
			container = new SimpleContainer();

            container.Instance(container);
			
            container.Singleton<IWindowManager, WindowManager>();
			container.Singleton<IEventAggregator, EventAggregator>();
            container.Singleton<IIndexService, IndexService>();
            
            container.PerRequest<ShellViewModel>();
            container.PerRequest<OverviewViewModel>();

            container.PerRequest<IFolderBrowser, FolderBrowser>();
            container.PerRequest<IMessageBox, Luke.Net.Lib.UI.MessageBox>();
		}
开发者ID:paulirwin,项目名称:Luke.Net,代码行数:16,代码来源:AppBootstrapper.cs


注:本文中的SimpleContainer.Singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。