本文整理汇总了C#中IUnityContainer类的典型用法代码示例。如果您正苦于以下问题:C# IUnityContainer类的具体用法?C# IUnityContainer怎么用?C# IUnityContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IUnityContainer类属于命名空间,在下文中一共展示了IUnityContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: RegisterTypes
public static void RegisterTypes(IUnityContainer container)
{
//for Sql Server
container.RegisterType(typeof(IRepository), typeof(EFRepository));
//for xml file
//container.RegisterType(typeof(IRepository), typeof(XmlRepository));
}
开发者ID:ringill,项目名称:Calculator_01,代码行数:7,代码来源:Bootstrapper.cs
示例17: RegisterTypes
private static void RegisterTypes(IUnityContainer container)
{
container.RegisterType(
typeof(Notificator),
new PerUserCacheLifetimeManager(),
new InjectionConstructor());
container.RegisterType<IEntityService, EntityService>();
container.RegisterType<IValidatingEntities, EntityValidator>();
container.RegisterType<IValidatingFiles, FileValidator>();
container.RegisterType<IConfigurationProvider, ConfigurationProvider>();
container.RegisterType<IConfiguration, Core.Configuration>();
container.RegisterType<IFetchingRecords, RecordsSource>();
container.RegisterType<IFetchingRecordsHierarchy, RecordsHierarchySource>();
container.RegisterType<IExecutingDbCommand, DbCommandExecutor>();
container.RegisterType<ICreatingRecords, RecordsCreator>();
container.RegisterType<IUpdatingRecords, RecordsUpdater>();
container.RegisterType<IDeletingRecords, RecordsDeleter>();
container.RegisterType<IComparingRecords, RecordsComparer>();
container.RegisterType<IDescribingChanges, ChangesDescriber>();
container.RegisterType<IProvidingUser, HttpContextUserProvider>();
container.RegisterType<ICreatingNameFiles, FileNameCreator>();
container.RegisterType<IDeletingFiles, FileDeleter>();
container.RegisterType<IHandlingFiles, FileHandler>();
container.RegisterType<IResizingImages, ImageResizer>();
container.RegisterType<ISavingFiles, FileSaver>();
container.RegisterType<IFilterFactory, FilterFactory>();
container.RegisterType<IRecordsService, RecordsService>();
container.RegisterType<IIlaroAdmin, IlaroAdmin>(new ContainerControlledLifetimeManager());
}
开发者ID:tassyo1,项目名称:Ilaro.Admin,代码行数:30,代码来源:Bootstrapper.cs
示例18: ModuleB
public ModuleB(IUnityContainer container, IRegionManager regionManager)
{
Container = container;
RegionManager = regionManager;
RegisterViewsAndServices();
}
开发者ID:CarlosVV,项目名称:mediavf,代码行数:7,代码来源:ModuleB.cs
示例19: RegisterTypes
public static void RegisterTypes(IUnityContainer container)
{
var hierarchy = (Hierarchy)LogManager.GetRepository();
hierarchy.Root.RemoveAllAppenders();
hierarchy.Root.Level = Level.Debug;
hierarchy.RaiseConfigurationChanged(EventArgs.Empty);
FileAppender fileAppender = new RollingFileAppender();
fileAppender.AppendToFile = true;
fileAppender.LockingModel = new FileAppender.MinimalLock();
fileAppender.File = HttpContext.Current.Server.MapPath("~/TestHarness1.log.txt");
var patternLayout = new PatternLayout { ConversionPattern = "%d [%2%t] %-5p [%-10c] %m%n%n" };
patternLayout.ActivateOptions();
fileAppender.Layout = patternLayout;
fileAppender.ActivateOptions();
BasicConfigurator.Configure(fileAppender);
var logger = LogManager.GetLogger(typeof(IServiceBus));
container.RegisterInstance<ILog>(logger, new ContainerControlledLifetimeManager());
var ftpClient = new FtpQueueClient();
ftpClient.ConnectAsync(new Uri("ftp://ftp.jdibble.co.uk/site1/Personal/service-bus-ftp/queue"), new NetworkCredential("jdibble-001", "jli798ik")).Wait();
container.RegisterInstance<IFtpQueueClient>(ftpClient, new ContainerControlledLifetimeManager());
container.RegisterType<IQueueManager, FtpQueueManager>(new ContainerControlledLifetimeManager());
container.RegisterType<SharedMessageHandler>();
var messageDictionary = new MessageTypeDictionary
{
{ ServiceBus.Messaging.MessageExtensions.MessageTypeSignature<SharedMessage>(), typeof(SharedMessage) },
{ ServiceBus.Messaging.MessageExtensions.MessageTypeSignature<NonSharedMessage>(), typeof(NonSharedMessage) },
{ ServiceBus.Messaging.MessageExtensions.MessageTypeSignature<SharedEvent>(), typeof(SharedEvent) }
};
container.RegisterInstance<IMessageSerialiser>(new JsonMessageSerialiser(messageDictionary), new ContainerControlledLifetimeManager());
var serviceBus =
ServiceBusBuilder.Configure()
.WithLogger(container.Resolve<ILog>())
.WithHostAddress(new Uri("http://servicebus-ftp.jdibble.co.uk"))
.WithHttpTransport(new JsonMessageSerialiser(messageDictionary))
.AsMvcServiceBus(RouteTable.Routes, container.Resolve<IQueueManager>())
.Build()
.WithMessageHandler(container.Resolve<SharedMessageHandler>())
.Subscribe(container.Resolve<SharedEventHandler>())
.WithPeerAsync(new Peer(new Uri("http://servicebus-ftp2.jdibble.co.uk"))).Result;
serviceBus.WithPeerAsync(new Peer(new Uri("http://servicebus.jdibble.co.uk")));
serviceBus.WithPeerAsync(new Peer(new Uri("http://servicebus2.jdibble.co.uk")));
container.RegisterInstance(serviceBus, new ContainerControlledLifetimeManager());
container.RegisterType<ServiceBusHub>(new ContainerControlledLifetimeManager());
}
开发者ID:dibble-james,项目名称:ServiceBus,代码行数:60,代码来源:Bootstrapper.cs
示例20: UnityMvcDependencyResolver
public UnityMvcDependencyResolver(IUnityContainer unityContainer)
{
if (unityContainer == null)
throw new ArgumentNullException("unityContainer");
this.unityContainer = unityContainer;
}
开发者ID:ideesdumidi,项目名称:TournamentMaker,代码行数:7,代码来源:UnityMvcDependencyResolver.cs
注:本文中的IUnityContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论