本文整理汇总了C#中ServiceContainer类的典型用法代码示例。如果您正苦于以下问题:C# ServiceContainer类的具体用法?C# ServiceContainer怎么用?C# ServiceContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceContainer类属于命名空间,在下文中一共展示了ServiceContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ChildContainerShouldBeDisposed
public void ChildContainerShouldBeDisposed()
{
var ioc = new ServiceContainer();
var childContainer = ioc.CreateChildContainer();
ioc.Dispose();
Assert.That(() => childContainer.Clear(), Throws.TypeOf(typeof(ObjectDisposedException)));
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:7,代码来源:ServiceContainerTest.cs
示例2: EnableLightInject
public static IServiceContainer EnableLightInject(this HttpConfiguration configuration)
{
var container = new ServiceContainer();
container.RegisterApiControllers();
container.EnableWebApi(configuration);
return container;
}
开发者ID:seesharper,项目名称:LightInject.WebApiSkeleton,代码行数:7,代码来源:ConfigurationExtensions.cs
示例3: Main
public static void Main(string[] args)
{
var argumentParser = ApplicationArgumentsConfigurationSetup.CreateCommandLineParser();
ICommandLineParserResult parseResult = argumentParser.Parse(args);
if (!parseResult.HasErrors && !parseResult.EmptyArgs)
{
using (var serviceContainer = new ServiceContainer())
{
serviceContainer.RegisterFrom<CompositionRoot>();
IFileSystemMonitorServiceFactory factory = serviceContainer.GetInstance<IFileSystemMonitorServiceFactory>(CompositionRoot.LoggingFileSystemMonitorServiceFactory);
FileSystemMonitorServiceConfiguration configuration = CreateConfiguration(argumentParser.Object);
var logger = serviceContainer.GetInstance<ILogger>();
logger.Log(LogLevel.Trace, "From: {0} To: {1}", configuration.FolderToMonitor, configuration.TargetFolder);
FileSystemMonitorService service = factory.Create(configuration);
ServiceBase.Run(service);
}
}
else
{
argumentParser.HelpOption.ShowHelp(argumentParser.Options);
}
}
开发者ID:RamanBut-Husaim,项目名称:.NET-Practice,代码行数:27,代码来源:Program.cs
示例4: InitializeLightInject
private static void InitializeLightInject(HttpConfiguration config)
{
var container = new ServiceContainer();
container.RegisterFrom<Composition.CompositionModule>();
container.RegisterApiControllers();
container.EnableWebApi(config);
}
开发者ID:dzimchuk,项目名称:SASRotation,代码行数:7,代码来源:Startup.cs
示例5: Scan_HostAssembly_DoesNotConfigureInternalServices
public void Scan_HostAssembly_DoesNotConfigureInternalServices()
{
var container = new ServiceContainer();
container.RegisterAssembly(typeof(ServiceContainer).Assembly);
var result = container.AvailableServices.Where(si => si.ImplementingType.Namespace == "LightInject");
Assert.IsFalse(container.AvailableServices.Any(si => si.ImplementingType != null && si.ImplementingType.Namespace == "LightInject"));
}
开发者ID:hendryten,项目名称:LightInject,代码行数:7,代码来源:AssemblyScannerTests.cs
示例6: Main
static void Main(string[] args)
{
MongoDBRepository.RegisterMongoDBContext(new TripperCenterDBContext());
MongoDBRepository.RegisterMongoDBContext(new DeliveryCenterDBContext());
MongoDBRepository.RegisterMongoDBContext(new StatusCenterDBContext());
MongoDBRepository.RegisterMongoDBContext(new RelationCenterDBContext());
MongoDBRepository.RegisterMongoIndex();
var ass = WinAssemblyUtility.GetAssembly();
HostInfo host = new HostInfo(ConfigurationManager.AppSettings["WcfHostAddress"]).LoadTypesFromAssemblies(ass);
using (ServiceContainer container = new ServiceContainer())
{
container.Open(host);
Console.WriteLine("press close to stop host");
while (true)
{
if ("close" == Console.ReadLine().ToLower())
{
container.Close(host);
break;
}
}
Console.WriteLine("press 'Enter' to quit");
Console.ReadKey();
}
}
开发者ID:WinHuStudio,项目名称:iTrip,代码行数:27,代码来源:Program.cs
示例7: Main
static void Main(string[] args)
{
Console.WriteLine("Start");
var container = new ServiceContainer();
container.Register<IDataBaseController, DataBaseController>();
IDataBaseController _dbController = container.GetInstance<IDataBaseController>();
Product p1 = new Product()
{
Id = 1
};
Product p2 = new Product()
{
Id = 2
};
Product p3 = null;
_dbController.InsertProduct(p1);
_dbController.InsertProduct(p3);
_dbController.InsertProduct(p2);
Console.WriteLine("End");
Console.ReadLine();
}
开发者ID:AlehSkamarokhau,项目名称:PrototypeApps,代码行数:29,代码来源:Program.cs
示例8: Register
public static void Register(ServiceContainer container)
{
container.Register<IBotManager, BotManager>();
container.Register<IMessageHandler, MessageHandler>();
container.Register<ICommandHelper, CommandHelper>();
DataDependenciesConfig.Register(container);
}
开发者ID:spoofi,项目名称:FreudBot,代码行数:7,代码来源:LogicDependenciesConfig.cs
示例9: RegisterFactory_WithCompositionRoot_ShouldBeNotNull
public void RegisterFactory_WithCompositionRoot_ShouldBeNotNull()
{
var container = new ServiceContainer();
var directory = AppDomain.CurrentDomain.BaseDirectory;
var finder = AssemblyFinder.Builder.UsePath(directory).Create;
container.RegisterFrom<ServiceLocatorCompositionRoot>();
var assemblies = finder.GetAssembliesTagged<AssemblyTagAttribute>();
container.RegisterFactory(assemblies);
container.Register<IDoSomething, DoSomething>(typeof(DoSomething).FullName);
var instance = container.GetInstance<IObjectFactory>();
instance.ShouldNotBeNull();
instance.ConfigurationProvider.Configuration.Items.ShouldNotBeEmpty();
instance.ConfigurationProvider.Configuration.Items.Count.ShouldBe(1);
instance.ConfigurationProvider.Sources.ShouldNotBeEmpty();
instance.ConfigurationProvider.Sources.Length.ShouldBe(2);
instance.ShouldBeAssignableTo<IObjectFactory>();
instance.ShouldBeOfType<ObjectFactory>();
}
开发者ID:raulnq,项目名称:Jal.Factory,代码行数:32,代码来源:ServiceContainerExtensionTests.cs
示例10: RegisterContainer
private void RegisterContainer()
{
var container = new ServiceContainer();
container.RegisterApiControllers();
container.RegisterFrom<CompositionRoot>();
container.EnableWebApi(this);
}
开发者ID:Takaloy,项目名称:Hello-Owin-World,代码行数:7,代码来源:WebApiConfig.cs
示例11: LoadContentArgs
//monoFrameworkAlias.Microsoft.Xna.Framework.Graphics.GraphicsDevice monoDevice)
//public monoFrameworkAlias.Microsoft.Xna.Framework.Graphics.GraphicsDevice MonoDevice { get; private set; }
public LoadContentArgs(GraphicsDevice device, GraphicsDeviceService graphicsService, ServiceContainer services)
{
GraphicsDevice = device;
GraphicsService = graphicsService;
Services = services;
//MonoDevice = monoDevice;
}
开发者ID:rickbatka,项目名称:co-op-engine,代码行数:9,代码来源:GraphicsControlBase.cs
示例12: MoveCreatorForm
public MoveCreatorForm()
{
//set up defaults
this.movelist = new Dictionary<String, Move>();
this.directoryHome = "../../../HeroesOfRock";
this.FormClosing += ContentList_FormClosing; ;
this.appClose = true;
//set up content manager
GraphicsDeviceService gds = GraphicsDeviceService.AddRef(this.Handle,
this.ClientSize.Width, this.ClientSize.Height);
ServiceContainer services = new ServiceContainer();
services.AddService<IGraphicsDeviceService>(gds);
this.content = new ContentManager(services, String.Concat(directoryHome, "/HeroesOfRock/bin/x86/Debug/Content"));
//Load and/or parse predefined objects
LoadMoveList(content.Load<Move[]>("Movelist"));
this.audioClips = Directory.GetFiles(String.Concat(content.RootDirectory, "/Audio")).ToList<string>();
this.particleFX = Directory.GetFiles(String.Concat(content.RootDirectory, "/ParticleFX")).ToList<string>();
//if null, will back up to the content default
BackUpMoveList(null);
InitializeComponent();
RefreshList();
}
开发者ID:scotttorgeson,项目名称:HeroesOfRock,代码行数:25,代码来源:ContentList.cs
示例13: GetInstance_NoServices_CallsAssemblyScannerOnlyOnce
public void GetInstance_NoServices_CallsAssemblyScannerOnlyOnce()
{
var scannerMock = new Mock<IAssemblyScanner>();
var serviceContainer = new ServiceContainer();
serviceContainer.AssemblyScanner = scannerMock.Object;
try
{
serviceContainer.GetInstance<IFoo>();
}
catch
{
try
{
serviceContainer.GetInstance<IFoo>();
}
catch
{
}
}
finally
{
scannerMock.Verify(a => a.Scan(typeof(IFoo).Assembly, It.IsAny<IServiceRegistry>(), LifeCycleType.Transient, It.IsAny<Func<Type, bool>>()), Times.Once());
}
}
开发者ID:stegenish,项目名称:LightInject,代码行数:25,代码来源:AssemblyScannerTests.cs
示例14: Create_WithCustomerOlderThan25_ShouldBeNotEmpty
public void Create_WithCustomerOlderThan25_ShouldBeNotEmpty()
{
var container = new ServiceContainer();
var directory = AppDomain.CurrentDomain.BaseDirectory;
var finder = AssemblyFinder.Builder.UsePath(directory).Create;
container.RegisterFrom<ServiceLocatorCompositionRoot>();
var assemblies = finder.GetAssembliesTagged<AssemblyTagAttribute>();
container.RegisterFactory(assemblies);
container.Register<IDoSomething, DoSomething>(typeof(DoSomething).FullName);
var factory = container.GetInstance<IObjectFactory>();
var customer = new Customer(){Age = 25};
var services = factory.Create<Customer, IDoSomething>(customer);
services.ShouldNotBeEmpty();
services.Length.ShouldBe(1);
services[0].ShouldBeAssignableTo<IDoSomething>();
services[0].ShouldBeOfType<DoSomething>();
}
开发者ID:raulnq,项目名称:Jal.Factory,代码行数:30,代码来源:Tests.cs
示例15: InitializeServices
/// <summary>
/// Инициализатор сервисов.
/// </summary>
/// <param name="sysInfo">Информация о системе.</param>
/// <param name="container">Сервисы.</param>
public static void InitializeServices(ServiceContainer container, SystemInfoParam sysInfo)
{
container.RegisterService<IRegexCacheService>(new RegexCacheService(container));
container.RegisterService<IYoutubeIdService>(new YoutubeIdService(container));
container.RegisterService<IDateService>(new DateService(container));
container.RegisterService<ICaptchaService>(new CaptchaService(container));
container.RegisterService<ILinkHashService>(new LinkHashService(container));
container.RegisterService<ISerializerCacheService>(new SerializerCacheService(container));
container.RegisterService<IStorageService>(new StorageService(container));
container.RegisterService<ILinkTransformService>(new LinkTransformService(container));
container.RegisterService<INetworkLogic>(new NetworkLogicService(container));
container.RegisterService<ISystemInfo>(new SystemInfo(container, sysInfo));
container.RegisterService<IThreadTreeProcessService>(new ThreadTreeProcessService(container));
container.RegisterService<ILiveTileService>(new LiveTileService(container));
container.RegisterService<IJsonService>(new JsonService(container));
container.RegisterService<IYoutubeUriService>(new YoutubeUriService(container));
container.RegisterService<IApiKeyService>(new ApiKeyService(container));
container.RegisterService<INavigationKeyService>(new NavigationKeyService(container));
container.RegisterService<IBoardLinkKeyService>(new BoardLinkKeyService(container));
container.RegisterService<IMarkupService>(new MarkupService(container));
var engines = new NetworkEngines(container);
container.RegisterService<INetworkEngines>(engines);
container.RegisterService<INetworkEngineInstaller>(engines);
}
开发者ID:Opiumtm,项目名称:DvachBrowser3,代码行数:30,代码来源:CoreServicesInitializer.cs
示例16: RegistServices
/// <summary>
/// Регистрация сервисов модуля
/// </summary>
/// <param name="container"></param>
public override void RegistServices(ServiceContainer container)
{
container.RegisterService(new FaceRecognizerService());
container.RegisterService(new VoiceAssistantService());
container.RegisterService(new DatabaseService());
container.RegisterService(new HumanService());
}
开发者ID:IITTeam,项目名称:FaceDetection,代码行数:11,代码来源:CoreModule.cs
示例17: TagLineListForm
public TagLineListForm(IServiceProvider provider, IEnumerable<TagLineInfo> tagLines)
{
if (provider == null)
throw new ArgumentNullException(nameof(provider));
if (tagLines == null)
throw new ArgumentNullException(nameof(tagLines));
_serviceManager = new ServiceContainer(provider);
_tagLines = new ObservableList<TagLineInfo>(tagLines);
InitializeComponent();
_serviceManager.Publish<ITagLineListFormService>(new TagLineListFormService(this));
_serviceManager.Publish<IDefaultCommandService>(new DefaultCommandService("Janus.Forum.TagLine.Edit"));
_toolbarGenerator = new StripMenuGenerator(_serviceManager, _toolStrip, "Forum.TagLine.Toolbar");
_contextMenuGenerator = new StripMenuGenerator(_serviceManager, _contextMenuStrip, "Forum.TagLine.ContextMenu");
_listImages.Images.Add(
_serviceManager.GetRequiredService<IStyleImageManager>()
.GetImage(@"MessageTree\Msg", StyleImageType.ConstSize));
UpdateData();
_tagLines.Changed += (sender, e) => UpdateData();
}
开发者ID:rsdn,项目名称:janus,代码行数:27,代码来源:TagLineListForm.cs
示例18: Register
public static void Register(HttpConfiguration configuration)
{
var container = new ServiceContainer();
container.RegisterApiControllers();
container.Register<ITicketRepository, TicketRepository>(new PerContainerLifetime());
container.EnableWebApi(configuration);
}
开发者ID:santosh-mnrec,项目名称:demo-realtime-tickets,代码行数:7,代码来源:DependencyConfig.cs
示例19: MessageForm
public MessageForm(
[NotNull] IServiceProvider provider,
MessageFormMode mode,
MessageInfo message)
{
if (provider == null)
throw new ArgumentNullException(nameof(provider));
_serviceManager = new ServiceContainer(provider);
InitializeComponent();
_formMode = mode;
_messageInfo = message ?? new MessageInfo();
_previewSourceNum = OutboxManager.RegisterPreviewSource(this);
_serviceManager.Publish<IMessageEditorService>(
new MessageEditorService(this));
CustomInitializeComponent();
_menuGenerator = new StripMenuGenerator(_serviceManager, _menuStrip, "MessageEditor.Menu");
_toolbarGenerator = new StripMenuGenerator(_serviceManager, _toolStrip, "MessageEditor.Toolbar");
_tagsbarGenerator = new SmilesToolbarGenerator(_serviceManager, "Forum.MessageEditor.TagsBar", _tagsBar);
_syntaxExtSvc = provider.GetRequiredService<IEditorSyntaxExtensibilityService>();
}
开发者ID:rsdn,项目名称:janus,代码行数:27,代码来源:MessageForm.cs
示例20: Project
public Project()
{
Uid = Guid.NewGuid();
_services = new ServiceContainer();
Name = "Project";
_levels = new NamedResourceCollection<Level>();
_levels.Modified += (s, e) => OnModified(EventArgs.Empty);
_libraryManager = new LibraryManager();
_libraryManager.Libraries.Modified += (s, e) => OnModified(EventArgs.Empty);
Library defaultLibrary = new Library();
_libraryManager.Libraries.Add(defaultLibrary);
Extra = new List<XmlElement>();
_texturePool = new MetaTexturePool();
_texturePool.AddPool(defaultLibrary.Uid, defaultLibrary.TexturePool);
_tilePools = new MetaTilePoolManager(_texturePool);
_tilePools.AddManager(defaultLibrary.Uid, defaultLibrary.TilePoolManager);
_objectPools = new MetaObjectPoolManager(_texturePool);
_objectPools.AddManager(defaultLibrary.Uid, defaultLibrary.ObjectPoolManager);
_tileBrushes = new MetaTileBrushManager();
_tileBrushes.AddManager(defaultLibrary.Uid, defaultLibrary.TileBrushManager);
SetDefaultLibrary(defaultLibrary);
_services.AddService(typeof(TilePoolManager), _tilePools);
ResetModified();
}
开发者ID:jaquadro,项目名称:Treefrog,代码行数:35,代码来源:Project.cs
注:本文中的ServiceContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论