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


C# IUnityContainer类代码示例

本文整理汇总了C#中IUnityContainer的典型用法代码示例。如果您正苦于以下问题:C# IUnityContainer类的具体用法?C# IUnityContainer怎么用?C# IUnityContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ApplicationStartup

        /// <summary>
        /// 起動処理
        /// </summary>
        /// <param name="container"></param>
        /// <param name="pipelines"></param>
        protected override void ApplicationStartup(IUnityContainer container, IPipelines pipelines)
        {
            // 認証設定
            EnableBasicAuth(container, pipelines);
            EnableFormAuth(container, pipelines);

            // DBの初期化処理
            container.Resolve<IDataBaseContextInitializer>().Initialize();

            // コントローラー群を起動
            //this.controllers = MakeControllers(container).ToArray();

            // todo debug admin追加
            var isNothingAdmin =
                from c in container.ToMaybe()
                from ev in c.Resolve<IDataBaseContext>().ToMaybe()
                let admin = ev.GetUser(u => u.Id == "admin").FirstOrNothing()
                where admin.IsNothing
                select ev;
            isNothingAdmin.On(ev => ev.AddUser(new User { Id = "admin", Name = "Admin", Password = "admin", Role = UserRole.Admin }));

            Nancy.Json.JsonSettings.MaxJsonLength = int.MaxValue;

            base.ApplicationStartup(container, pipelines);
        }
开发者ID:shchy,项目名称:tips,代码行数:30,代码来源:Bootstrapper.cs

示例2: PartPresenter

        public PartPresenter(PartPresenterView view, IUnityContainer container)
        {
            _container = container;
            View = view;
            View.DataContext = this;
            _regionManager = new RegionManager();
            RegionManager.SetRegionManager(View, _regionManager);

            _addPartCommand = new Lazy<DelegateCommand<object>>(() => new DelegateCommand<object>(AddPartExecuted));
            Action<int> add = (i) =>
            {
                var region = _regionManager.Regions["Page1Content" + i];
                if (region.Views.Count() == 0)
                {
                    var partView = _container.Resolve<PartView>();

                    region.Add(partView);
                    region.Activate(partView);

                }
            };

            add(1);
            add(2);
            add(3);
        }
开发者ID:Antares007,项目名称:InRetail,代码行数:26,代码来源:PartPresenter.cs

示例3: ShellViewModel

        public ShellViewModel(IUnityContainer container)
        {
            _container = container;

            InitCommands();
            LoadContacts();
        }
开发者ID:dmytrorudenko,项目名称:NewRepo,代码行数:7,代码来源:ShellViewModel.cs

示例4: RegisterTypes

        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            container.RegisterInstance<IMapper>(MapperBootstap.CreateMapper());
        }
开发者ID:goldnarms,项目名称:fridgedate,代码行数:11,代码来源:UnityConfig.cs

示例5: RegisterSerializers

 private void RegisterSerializers(IUnityContainer container) {
     container.RegisterType(typeof (ISolrDocumentSerializer<>), typeof (SolrDocumentSerializer<>));
     container.RegisterType(typeof (ISolrDocumentSerializer<Dictionary<string, object>>), typeof (SolrDictionarySerializer));
     container.RegisterType<ISolrFieldSerializer, DefaultFieldSerializer>();
     container.RegisterType<ISolrQuerySerializer, DefaultQuerySerializer>();
     container.RegisterType<ISolrFacetQuerySerializer, DefaultFacetQuerySerializer>();
 }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:7,代码来源:SolrNetContainerConfiguration.cs

示例6: RegisterTypes

        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();
            container.RegisterType<ApplicationDbContext>();
            container.RegisterType<ApplicationUserManager>();
            container.RegisterType<ApplicationSignInManager>();
            container.RegisterType<IAuthenticationManager>(
                new InjectionFactory(c => HttpContext.Current.GetOwinContext().Authentication));
            container.RegisterType<IUserStore<ApplicationUser>, UserStore<ApplicationUser>>(
               new InjectionConstructor(typeof(ApplicationDbContext)));
            // GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
            container.RegisterType<IRoleStore<IdentityRole, string>, RoleStore<IdentityRole>>(
            new InjectionConstructor(typeof(ApplicationDbContext)));

            container.RegisterType<IDriverepo, DriveRepo>();

            container.RegisterType<AccountController>(
                new InjectionConstructor(
                    typeof(ApplicationUserManager),
                    typeof(ApplicationSignInManager),
                    typeof(IDriverepo)));
            // TODO: Register your types here
            // container.RegisterType<IProductRepository, ProductRepository>();
        }
开发者ID:ravikumar533,项目名称:MyDrive,代码行数:29,代码来源:UnityConfig.cs

示例7: ModuleInit

 public ModuleInit(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, IModuleManager moduleManager)
 {
     this.regionManager = regionManager;
     this.container = container;
     this.eventAggregator = eventAggregator;
     this.moduleManager = moduleManager;
 }
开发者ID:skidamian,项目名称:Projekt-SI,代码行数:7,代码来源:ModuleInit.cs

示例8: ConfigureContainer

        /// <summary>
        ///     Configures the container.
        /// </summary>
        /// <param name="container">The container.</param>
        protected override void ConfigureContainer(IUnityContainer container)
        {
            if (Interceptor == null)
            {
                return;
            }

            var interceptorType = TypeResolver.ResolveType(Interceptor.TypeName);
            if (!typeof (IInstanceInterceptor).IsAssignableFrom(interceptorType))
            {
                throw new ConfigurationErrorsException(Resources.ExceptionOnlyInstanceInterceptorBeSupported);
            }

            var builderName = interceptorType.AssemblyQualifiedName;
            var source =
                Interceptor.Injection.SelectMany(
                    (InjectionMemberElement element) =>
                        element.GetInjectionMembers(container, typeof (IInstanceInterceptor), interceptorType,
                            builderName));
            container.RegisterType(typeof (IInstanceInterceptor), interceptorType, builderName,
                new ContainerControlledLifetimeManager(), source.ToArray());

            var buildKey = new NamedTypeBuildKey(typeof (IInstanceInterceptor), builderName);
            var instance =
                new ResolvedAutoInterceptorPolicy(
                    (NamedTypeBuildKey key) => container.Resolve<IInstanceInterceptor>(key.Name), buildKey);
            container.RegisterInstance(typeof (AutoInterceptorPolicy),
                typeof (AutoInterceptorPolicy).AssemblyQualifiedName, instance, new ContainerControlledLifetimeManager());
        }
开发者ID:Chinaccn,项目名称:surfboard,代码行数:33,代码来源:AutoInterceptionElement.cs

示例9: Show

		public static FSharpAsync<Result> Show(IUnityContainer container, Model model) {
			return container.StartViewActivity<Result>(context => {
				var view = new UserManagementView(model, context);
				var presenter = container.Resolve<IViewPresenter>();
				presenter.ShowView(view);
			});
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:7,代码来源:UserManagementView.xaml.cs

示例10: ConnectionPresenter

        public ConnectionPresenter(IUnityContainer container, IConnectionView view,
             IShellPresenter regionManager)
        {
            View = view;
            this.container = container;
            this.service = new WMSServiceClient();
            View.Model = this.container.Resolve<ConnectionModel>();
            this.regionManager = regionManager;

            //Event Delegate
            View.New += new EventHandler<EventArgs>(this.OnNew);
            View.LoadData += new EventHandler<DataEventArgs<Connection>>(this.OnLoadData);
            View.LoadChilds += new EventHandler<DataEventArgs<ConnectionType>>(this.OnLoadChilds);
            View.Save += new EventHandler<EventArgs>(this.OnSave);
            View.Delete += new EventHandler<EventArgs>(this.OnDelete);
            View.TestConnection += new EventHandler<EventArgs>(this.OnTestConnection);

            View.Model.ListCnnType = service.GetConnectionType(new ConnectionType());

            if (View.Model.ListCnnType != null && View.Model.ListCnnType.Count == 1)
                LoadChilds(View.Model.ListCnnType[0]);

            View.Model.Record = null;
            View.DpChilds.Visibility = Visibility.Collapsed;

        }
开发者ID:erwin-hamid,项目名称:LogPro,代码行数:26,代码来源:ConnectionPresenter.cs

示例11: AXAClaimSearchBase

 public AXAClaimSearchBase(ClaimPreviewControllerBase previewController, ISearchServiceHandler searchService, IUnityContainer container, AppModel appModel)
 {
     this._searchService = searchService;
     this._container = container;
     this._appModel = appModel;
     this._previewController = previewController;
 }
开发者ID:victorxata,项目名称:261120,代码行数:7,代码来源:AXAClaimSearchBase.cs

示例12: KZFlyoutDialog

        public KZFlyoutDialog(IUnityContainer container)
        {
            KZHelper = container.Resolve<IKZHelper>();

            action = new FlyoutAction();
            CommandYes = new FlyoutCommand {Text = "យល់ព្រម", Result = DialogResult.Yes};
            CommandNo = new FlyoutCommand {Text = "មិនយល់ព្រម", Result = DialogResult.No};
            action.Commands.Add(CommandYes);
            action.Commands.Add(CommandNo);


            properties = new FlyoutProperties();
            //properties.Appearance.BackColor = Color.Blue;
            //properties.Appearance.Options.UseBackColor = true;

            properties.Appearance.Font = KZHelper.KZFonts.ContentFont;
            properties.Appearance.Options.UseFont = true;
            properties.AppearanceCaption.Font = KZHelper.KZFonts.HeaderFont;
            properties.AppearanceCaption.Options.UseFont = true;
            properties.AppearanceButtons.Font = KZHelper.KZFonts.ContentFont;
            properties.AppearanceButtons.Options.UseFont = true;
            properties.AppearanceDescription.Font = KZHelper.KZFonts.ContentFont;
            properties.AppearanceDescription.Options.UseFont = true;


            properties.ButtonSize = new Size(150, 40);
            properties.Style = FlyoutStyle.MessageBox;
        }
开发者ID:konzuk,项目名称:LoanProjectSQL,代码行数:28,代码来源:KZFlyoutDialog.cs

示例13: ConfigureOwin

        public void ConfigureOwin(IAppBuilder app, IUnityContainer container)
        {
            JobStorage.Current = CreateJobStorage(Stage.ConfigureOwin);

            // Configure Hangfire dashboard

            var securityService = container.Resolve<ISecurityService>();
            var moduleInitializerOptions = container.Resolve<IModuleInitializerOptions>();

            var appPath = "/" + moduleInitializerOptions.RoutePrefix;

            var authorizationFilters = new[]
            {
                    new PermissionBasedAuthorizationFilter(securityService)
                    {
                        Permission = PredefinedPermissions.BackgroundJobsManage
                    }
                };

            var dashboardOptions = new DashboardOptions
            {
                AppPath = appPath,
                AuthorizationFilters = authorizationFilters
            };

            app.UseHangfireDashboard(appPath + "hangfire", dashboardOptions);

            // Configure Hangfire server
            if (_options.StartServer)
            {
                app.UseHangfireServer(new BackgroundJobServerOptions { Activator = new UnityJobActivator(container) });
            }
        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:33,代码来源:HangfireLauncher.cs

示例14: RegisterUIShell

 protected virtual void RegisterUIShell(IUnityContainer container)
 {
     var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
     PackageViewModel.IsWaitCursorEnabled.Subscribe(_ =>
     {
         ErrorHandler.ThrowOnFailure(uiShell.SetWaitCursor());
     });
     PackageViewModel.MessageBoxParameter.Subscribe(_ =>
     {
         var result = 0;
         ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(MessageBoxParameter.ReservedUInt,
                                                            ref MessageBoxParameter.ReservedGuid,
                                                            _.Title,
                                                            _.Text,
                                                            MessageBoxParameter.EmptyHelpFile,
                                                            MessageBoxParameter.EmptyHelpContextId,
                                                            _.Button,
                                                            _.DefaultButton,
                                                            _.Icon,
                                                            MessageBoxParameter.NotSysAlert,
                                                            out result));
         _.Result = (VSConstants.MessageBoxResult)result;
     });
     container.RegisterInstance(uiShell);
 }
开发者ID:umaranis,项目名称:Prig,代码行数:25,代码来源:PackageView.cs

示例15: Show

		public static FSharpAsync<Unit> Show(IUnityContainer container) {
			return container.StartViewActivity<Unit>(context => {
				var view = new AboutView(context);
				var presenter = container.Resolve<IViewPresenter>();
				presenter.ShowView(view);
			});
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:7,代码来源:AboutView.xaml.cs


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