本文整理汇总了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);
}
示例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);
}
示例3: ShellViewModel
public ShellViewModel(IUnityContainer container)
{
_container = container;
InitCommands();
LoadContacts();
}
示例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());
}
示例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>();
}
示例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>();
}
示例7: ModuleInit
public ModuleInit(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, IModuleManager moduleManager)
{
this.regionManager = regionManager;
this.container = container;
this.eventAggregator = eventAggregator;
this.moduleManager = moduleManager;
}
示例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());
}
示例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);
});
}
示例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;
}
示例11: AXAClaimSearchBase
public AXAClaimSearchBase(ClaimPreviewControllerBase previewController, ISearchServiceHandler searchService, IUnityContainer container, AppModel appModel)
{
this._searchService = searchService;
this._container = container;
this._appModel = appModel;
this._previewController = previewController;
}
示例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;
}
示例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) });
}
}
示例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);
}
示例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);
});
}