本文整理汇总了C#中IServiceRegistry类的典型用法代码示例。如果您正苦于以下问题:C# IServiceRegistry类的具体用法?C# IServiceRegistry怎么用?C# IServiceRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IServiceRegistry类属于命名空间,在下文中一共展示了IServiceRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: typeof
void ICompositionRoot.Compose(IServiceRegistry serviceRegistry)
{
CallCount++;
serviceRegistry.Register<IFoo,Foo>();
serviceRegistry.RegisterFallback((type, s) => type == typeof(IBar), request => new Bar());
}
示例2: SceneSystem
/// <summary>
/// Initializes a new instance of the <see cref="GameSystemBase" /> class.
/// </summary>
/// <param name="registry">The registry.</param>
/// <remarks>The GameSystem is expecting the following services to be registered: <see cref="IGame" /> and <see cref="IAssetManager" />.</remarks>
public SceneSystem(IServiceRegistry registry)
: base(registry)
{
registry.AddService(typeof(SceneSystem), this);
Enabled = true;
Visible = true;
}
示例3: DynamicEffectCompiler
/// <summary>
/// Initializes a new instance of the <see cref="DynamicEffectCompiler" /> class.
/// </summary>
/// <param name="services">The services.</param>
/// <param name="effectName">Name of the effect.</param>
/// <param name="asyncDynamicEffectCompiler">if set to <c>true</c> it can compile effect asynchronously.</param>
/// <exception cref="System.ArgumentNullException">services
/// or
/// effectName</exception>
public DynamicEffectCompiler(IServiceRegistry services, string effectName, int taskPriority = 0)
{
if (services == null) throw new ArgumentNullException("services");
if (effectName == null) throw new ArgumentNullException("effectName");
Services = services;
this.effectName = effectName;
this.taskPriority = taskPriority;
EffectSystem = Services.GetSafeServiceAs<EffectSystem>();
GraphicsDevice = Services.GetSafeServiceAs<IGraphicsDeviceService>().GraphicsDevice;
parameterCollections = new FastList<ParameterCollection>();
// Default behavior for fallback effect: load effect with same name but empty compiler parameters
ComputeFallbackEffect = (dynamicEffectCompiler, type, name, parameters) =>
{
ParameterCollection usedParameters;
var compilerParameters = new CompilerParameters();
// We want high priority
compilerParameters.TaskPriority = -1;
var effect = dynamicEffectCompiler.EffectSystem.LoadEffect(effectName, compilerParameters, out usedParameters).WaitForResult();
return new ComputeFallbackEffectResult(effect, usedParameters);
};
}
示例4: YamlManager
/// <summary>
/// Initializes a new instance of the <see cref="GameSystem" /> class.
/// </summary>
/// <param name="registry">The registry.</param>
public YamlManager(IServiceRegistry registry) : base(registry)
{
Services.AddService(this);
yamlSettings = new SerializerSettings();
attributeRegistry = yamlSettings.Attributes;
serializer = new Serializer(yamlSettings);
}
示例5: GameSystemBase
/// <summary>
/// Initializes a new instance of the <see cref="GameSystemBase" /> class.
/// </summary>
/// <param name="registry">The registry.</param>
/// <remarks>
/// The GameSystem is expecting the following services to be registered: <see cref="IGame"/> and <see cref="IAssetManager"/>.
/// </remarks>
protected GameSystemBase(IServiceRegistry registry)
{
if (registry == null) throw new ArgumentNullException("registry");
this.registry = registry;
game = (GameBase)Services.GetServiceAs<IGame>();
assetManager = Services.GetSafeServiceAs<IAssetManager>();
}
示例6: ScriptSystem
/// <summary>
/// Initializes a new instance of the <see cref="GameSystemBase" /> class.
/// </summary>
/// <param name="registry">The registry.</param>
/// <remarks>The GameSystem is expecting the following services to be registered: <see cref="IGame" /> and <see cref="AssetManager" />.</remarks>
public ScriptSystem(IServiceRegistry registry)
: base(registry)
{
Enabled = true;
Scheduler = new Scheduler();
Services.AddService(typeof(ScriptSystem), this);
}
示例7: AudioSystem
/// <summary>
/// Create an new instance of AudioSystem
/// </summary>
/// <param name="registry">The service registry in which to register the <see cref="AudioSystem"/> services</param>
public AudioSystem(IServiceRegistry registry)
: base(registry)
{
Enabled = true;
registry.AddService(typeof(AudioSystem), this);
}
示例8: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
// Register the app repository
serviceRegistry.Register<IAppRepository, AppRepository>();
// Register the app resource types
serviceRegistry.Register<IAppSprite, AppSprite>();
serviceRegistry.Register<IAppSound, AppSound>();
serviceRegistry.Register<IAppBackground, AppBackground>();
serviceRegistry.Register<IAppPath, AppPath>();
serviceRegistry.Register<IAppScript, AppScript>();
serviceRegistry.Register<IAppDataFile, AppDataFile>();
serviceRegistry.Register<IAppFont, AppFont>();
serviceRegistry.Register<IAppTimeline, AppTimeline>();
serviceRegistry.Register<IAppObject, AppObject>();
serviceRegistry.Register<IAppRoom, AppRoom>();
// Register teh resource managers
serviceRegistry.Register<IIndexedResourceManager<IAppSprite>, IndexedResourceManager<IAppSprite>>();
serviceRegistry.Register<IIndexedResourceManager<IAppSound>, IndexedResourceManager<IAppSound>>();
serviceRegistry.Register<IIndexedResourceManager<IAppBackground>, IndexedResourceManager<IAppBackground>>();
serviceRegistry.Register<IIndexedResourceManager<IAppPath>, IndexedResourceManager<IAppPath>>();
serviceRegistry.Register<IIndexedResourceManager<IAppScript>, IndexedResourceManager<IAppScript>>();
serviceRegistry.Register<IIndexedResourceManager<IAppDataFile>, IndexedResourceManager<IAppDataFile>>();
serviceRegistry.Register<IIndexedResourceManager<IAppFont>, IndexedResourceManager<IAppFont>>();
serviceRegistry.Register<IIndexedResourceManager<IAppTimeline>, IndexedResourceManager<IAppTimeline>>();
serviceRegistry.Register<IIndexedResourceManager<IAppObject>, IndexedResourceManager<IAppObject>>();
serviceRegistry.Register<IIndexedResourceManager<IAppRoom>, IndexedResourceManager<IAppRoom>>();
}
示例9: Compose
public void Compose(IServiceRegistry serviceRegistry)
{
serviceRegistry.Register<ILogFactory, Log4NetLogFactory>(new PerContainerLifetime());
serviceRegistry.Register<Type, ILog>((factory, type) => factory.GetInstance<ILogFactory>().GetLogger(type));
serviceRegistry.RegisterConstructorDependency(
(factory, info) => factory.GetInstance<Type, ILog>(info.Member.DeclaringType));
}
示例10: addServices
private static void addServices(IServiceRegistry registry)
{
var pipeline = new AssetPipeline();
registry.SetServiceIfNone<IAssetPipeline>(pipeline);
registry.SetServiceIfNone<IAssetFileRegistration>(pipeline);
registry.SetServiceIfNone(new AssetGraph());
registry.SetServiceIfNone(new AssetLogsCache());
registry.SetServiceIfNone<IAssetTagWriter, AssetTagWriter>();
registry.SetServiceIfNone<ICombinationDeterminationService, CombinationDeterminationService>();
registry.SetServiceIfNone<IAssetCombinationCache, AssetCombinationCache>();
registry.SetServiceIfNone<IAssetDependencyFinder, AssetDependencyFinderCache>();
registry.SetServiceIfNone<IAssetTagPlanner, AssetTagPlanner>();
registry.SetServiceIfNone<IAssetTagBuilder, AssetTagBuilder>();
registry.SetServiceIfNone<IAssetRequirements, AssetRequirements>();
registry.SetServiceIfNone<IMissingAssetHandler, TraceOnlyMissingAssetHandler>();
registry.SetServiceIfNone<IAssetTagPlanCache, AssetTagPlanCache>();
registry.SetServiceIfNone<ITransformerPolicyLibrary, TransformerPolicyLibrary>();
registry.SetServiceIfNone<IContentPlanner, ContentPlanner>();
registry.SetServiceIfNone<IContentPlanCache, ContentPlanCache>();
registry.SetServiceIfNone<IContentPipeline, ContentPipeline>();
registry.SetServiceIfNone<IContentWriter, ContentWriter>();
registry.SetServiceIfNone<IETagGenerator<IEnumerable<AssetFile>>, AssetFileEtagGenerator>();
}
示例11: configureServices
private void configureServices(IServiceRegistry services)
{
var configuration = new TemplateServiceConfiguration {BaseTemplateType = typeof (FubuRazorView)};
services.ReplaceService<ITemplateRegistry<IRazorTemplate>>(_templateRegistry);
services.ReplaceService<IFubuTemplateService>(new FubuTemplateService(_templateRegistry, new TemplateService(configuration), new FileSystem()));
services.ReplaceService<ITemplateServiceConfiguration>(configuration);
services.ReplaceService<IParsingRegistrations<IRazorTemplate>>(_parsings);
services.SetServiceIfNone<ITemplateDirectoryProvider<IRazorTemplate>, TemplateDirectoryProvider<IRazorTemplate>>();
services.SetServiceIfNone<ISharedPathBuilder>(new SharedPathBuilder());
var graph = new SharingGraph();
services.SetServiceIfNone(graph);
services.SetServiceIfNone<ISharingGraph>(graph);
services.FillType<IActivator, RazorActivator>();
services.FillType<ISharedTemplateLocator<IRazorTemplate>, SharedTemplateLocator<IRazorTemplate>>();
services.FillType<ISharingAttacher<IRazorTemplate>, MasterAttacher<IRazorTemplate>>();
services.FillType<ITemplateSelector<IRazorTemplate>, RazorTemplateSelector>();
services.FillType<IActivator, SharingAttacherActivator<IRazorTemplate>>();
services.FillType<IRenderStrategy, AjaxRenderStrategy>();
services.FillType<IRenderStrategy, DefaultRenderStrategy>();
services.SetServiceIfNone<IViewModifierService<IFubuRazorView>, ViewModifierService<IFubuRazorView>>();
services.FillType<IViewModifier<IFubuRazorView>, LayoutActivation>();
services.FillType<IViewModifier<IFubuRazorView>, PartialRendering>();
services.FillType<IViewModifier<IFubuRazorView>, FubuPartialRendering>();
}
示例12: SpriteAnimationSystem
/// <summary>
/// Creates a new instance of <see cref="SpriteAnimationSystem"/> and register it in the services.
/// </summary>
/// <param name="registry"></param>
public SpriteAnimationSystem(IServiceRegistry registry)
: base(registry)
{
registry.AddService(typeof(SpriteAnimationSystem), this);
DefaultFramesPerSecond = 30;
}
示例13: GameFontSystem
public GameFontSystem(IServiceRegistry registry)
: base(registry)
{
Visible = true;
FontSystem = new FontSystem();
Services.AddService(typeof(FontSystem), FontSystem);
Services.AddService(typeof(IFontFactory), FontSystem);
}
示例14: Bullet2PhysicsSystem
public Bullet2PhysicsSystem(IServiceRegistry registry)
: base(registry)
{
UpdateOrder = -1000; //make sure physics runs before everything
registry.AddService(typeof(IPhysicsSystem), this);
Enabled = true; //enabled by default
}
示例15: AudioSystem
/// <summary>
/// Create an new instance of AudioSystem
/// </summary>
/// <param name="registry">The service registry in which to register the <see cref="AudioSystem"/> services</param>
public AudioSystem(IServiceRegistry registry)
: base(registry)
{
Enabled = true;
AudioEngine = AudioEngineFactory.NewAudioEngine();
registry.AddService(typeof(AudioSystem), this);
}