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


C# IContainer.TryResolve方法代码示例

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


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

示例1: BeforeAll

		public void BeforeAll ()
		{
			_container = Platform.Setup.CreateContainer ();
			Assert.True (_container.TryResolve (out _networkService)); //TODO use different url
			_language = new Language{ ShortName = "de" };
			_location = new Location { Path = "/wordpress/augsburg/" };
			_updateTime = new UpdateTime (0);
		}
开发者ID:Integreat,项目名称:app-cross_platform,代码行数:8,代码来源:NetworkServiceTest.cs

示例2: Start

        public void Start(ZetboxConfig config)
        {
            if (config == null) { throw new ArgumentNullException("config"); }
            if (container != null) { throw new InvalidOperationException("already started"); }

            Logging.Configure();
            AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config);

            container = Program.CreateMasterContainer(config);

            IServiceControlManager scm = null;
            if (container.TryResolve<IServiceControlManager>(out scm))
            {
                Logging.Log.Info("Starting Zetbox Services");
                scm.Start();
            }
            else
            {
                Logging.Log.Info("Service control manager not registered");
            }
        }
开发者ID:daszat,项目名称:zetbox,代码行数:21,代码来源:ServerManager.cs

示例3: InitializeClient

        // Move to another method to avoid loading Zetbox.Objects
        private void InitializeClient(string[] args, ZetboxConfig config)
        {
            InitializeSplashScreenImageResource();

            StartupScreen.ShowSplashScreen(Zetbox.Client.Properties.Resources.Startup_Message, Zetbox.Client.Properties.Resources.Startup_InitApp, 6, config);
            if (config.Server != null && config.Server.StartServer)
            {
                StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_Server);
                serverDomain = new ServerDomainManager();
                serverDomain.Start(config);
            }

            var builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Client.Modules);
            ConfigureContainerBuilder(config, builder);
            container = builder.Build();
            container.ApplyPerfCounterTracker();
            container.Resolve<IUIExceptionReporter>().BeginInit();
            API.AppDomainInitializer.InitializeFrom(container);

            StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_Launcher);

            LoadStyles(this.Resources);

            // Focus nightmare
            // http://stackoverflow.com/questions/673536/wpf-cant-set-focus-to-a-child-of-usercontrol/4785124#4785124
            EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(FocusFixLoaded));
            EventManager.RegisterClassHandler(typeof(Zetbox.Client.WPF.View.ZetboxBase.InstanceCollectionBase), UserControl.LoadedEvent, new RoutedEventHandler(FocusFixLoaded));

            // Init credentials explicit
            StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_EnsuringCredentials);
            var principalResolver = container.Resolve<IPrincipalResolver>();
            var credResolver = container.Resolve<ICredentialsResolver>();
            try
            {
                while (principalResolver.GetCurrent() == null)
                {
                    credResolver.InvalidCredentials();
                }
            }
            catch (AuthenticationException)
            {
                ReportExceptionAndExit(WpfToolkitResources.App_InvalidCredentials_Caption, WpfToolkitResources.App_InvalidCredentials);
            }
            catch (InvalidZetboxGeneratedVersionException)
            {
                ReportExceptionAndExit(WpfToolkitResources.App_InvalidZetboxGeneratedVersion_Caption, WpfToolkitResources.App_InvalidZetboxGeneratedVersion);
            }
            credResolver.Freeze();

            StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_Launcher);

            container.Resolve<IUIExceptionReporter>().EndInit();

            FixupDatabase(container.Resolve<Func<IZetboxContext>>());

            IServiceControlManager scm = null;
            if (container.TryResolve<IServiceControlManager>(out scm))
            {
                Logging.Log.Info("Starting Zetbox Services");
                scm.Start();
            }
            else
            {
                Logging.Log.Info("Service control manager not registered");
            }

            StartupScreen.CanCloseOnWindowLoaded();
            // delegate all business logic into another class, which
            // allows us to load the Zetbox.Objects assemblies _before_
            // they are needed.
            var launcher = container.Resolve<Launcher>();
            launcher.Show(args);
        }
开发者ID:daszat,项目名称:zetbox,代码行数:74,代码来源:App.cs

示例4: BeforeAll

		public void BeforeAll ()
		{
			_container = Platform.Setup.CreateContainer ();
			Assert.True (_container.TryResolve (out _persistenceService), "PersistenceService not found");
		}
开发者ID:Integreat,项目名称:app-cross_platform,代码行数:5,代码来源:PersistenceServiceTest.cs

示例5: InitializeClient

        // Move to another method to avoid loading Zetbox.Objects
        private void InitializeClient(string[] args, ZetboxConfig config)
        {
            InitializeSplashScreenImageResource();

            StartupScreen.ShowSplashScreen(Zetbox.Client.Properties.Resources.Startup_Message, Zetbox.Client.Properties.Resources.Startup_InitApp, 6);
            if (config.Server != null && config.Server.StartServer)
            {
                StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_Server);
                serverDomain = new ServerDomainManager();
                serverDomain.Start(config);
            }
            else
            {
                StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_NoServerStart);
            }

            container = CreateMasterContainer(config);

            StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_Launcher);

            // Make Gendarme happy
            var resources = this.Resources;

            resources.BeginInit();
            resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/AppResources.xaml", UriKind.Relative) });

            // Create icon converter
            var iconConverter = new IconConverter(container.Resolve<IFrozenContext>(), container.Resolve<Func<IZetboxContext>>());
            resources["IconConverter"] = iconConverter;
            resources["ImageCtrlConverter"] = new ImageCtrlConverter(iconConverter);

            // Init all Converter that are not using a Context
            var templateSelectorFactory = container.Resolve<Zetbox.Client.WPF.Toolkit.VisualTypeTemplateSelector.Factory>();
            resources["defaultTemplateSelector"] = templateSelectorFactory(null);
            resources["listItemTemplateSelector"] = templateSelectorFactory("Zetbox.App.GUI.SingleLineKind");
            resources["dashBoardTemplateSelector"] = templateSelectorFactory("Zetbox.App.GUI.DashboardKind");

            // Manually add DefaultStyles and DefaultViews
            // Otherwise converter are unknown
            resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/Styles/DefaultStyles.xaml", UriKind.Relative) });
            resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/Styles/DefaultHighlightColorDefinitions.xaml", UriKind.Relative) });

            // Load registrated dictionaries from autofac
            foreach (var dict in container.Resolve<IEnumerable<Meta<ResourceDictionary>>>().Where(m => WPFHelper.RESOURCE_DICTIONARY_STYLE.Equals(m.Metadata[WPFHelper.RESOURCE_DICTIONARY_KIND])).Select(m => m.Value))
            {
                resources.MergedDictionaries.Add(dict);
            }

            resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/Zetbox.Client.WPF;component/Styles/DefaultViews.xaml", UriKind.Relative) });
            // Load registrated dictionaries from autofac
            foreach (var dict in container.Resolve<IEnumerable<Meta<ResourceDictionary>>>().Where(m => WPFHelper.RESOURCE_DICTIONARY_VIEW.Equals(m.Metadata[WPFHelper.RESOURCE_DICTIONARY_KIND])).Select(m => m.Value))
            {
                resources.MergedDictionaries.Add(dict);
            }

            resources.EndInit();

            // Init credentials explicit
            StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_EnsuringCredentials);
            container.Resolve<ICredentialsResolver>().EnsureCredentials();

            StartupScreen.SetInfo(Zetbox.Client.Properties.Resources.Startup_Launcher);

            // Tell icon converter that everything is initialized
            iconConverter.Initialized();

            // Focus nightmare
            // http://stackoverflow.com/questions/673536/wpf-cant-set-focus-to-a-child-of-usercontrol/4785124#4785124
            EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(FocusFixLoaded));
            EventManager.RegisterClassHandler(typeof(Zetbox.Client.WPF.View.ZetboxBase.InstanceCollectionBase), UserControl.LoadedEvent, new RoutedEventHandler(FocusFixLoaded));

            wpfResourcesInitialized = true;

            FixupDatabase(container.Resolve<Func<IZetboxContext>>());

            IServiceControlManager scm = null;
            if (container.TryResolve<IServiceControlManager>(out scm))
            {
                Logging.Log.Info("Starting Zetbox Services");
                scm.Start();
            }
            else
            {
                Logging.Log.Info("Service control manager not registered");
            }

            StartupScreen.CanCloseOnWindowLoaded();
            // delegate all business logic into another class, which
            // allows us to load the Zetbox.Objects assemblies _before_
            // they are needed.
            var launcher = container.Resolve<Launcher>();
            launcher.Show(args);
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:94,代码来源:App.cs


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