本文整理汇总了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>();
}
示例2: Configure
protected override void Configure() {
container = new SimpleContainer();
container.Singleton<IWindowManager, WindowManager>();
container.Singleton<IEventAggregator, EventAggregator>();
container.PerRequest<IShell, ShellViewModel>();
}
示例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 要在其它子界面中用到,
}
示例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>();
}
示例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>();
}
示例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();
}
示例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>();
}
示例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));
}
示例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",
});
}
示例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;
}
示例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>();
}
示例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>();
}
示例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>();
}
示例14: Configure
protected override void Configure()
{
container = new SimpleContainer();
container.Instance(container);
container.Singleton<App>();
}
示例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>();
}