Example #1
0
 /// <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);
 }
        /// <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);
            };
        }
Example #3
0
 /// <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>();
 }
Example #4
0
        void ICompositionRoot.Compose(IServiceRegistry serviceRegistry)
        {
            CallCount++;
            serviceRegistry.Register<IFoo,Foo>();

            serviceRegistry.RegisterFallback((type, s) => type == typeof(IBar), request => new Bar());
        }
Example #5
0
 /// <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);
 }
 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));            
 }
Example #7
0
        /// <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);
        }
        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>();
        }
Example #9
0
 /// <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;
 }
Example #10
0
        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>>();
        }
Example #11
0
        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>();
        }
        /// <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;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphicsDeviceServiceLocal"/> class.
 /// </summary>
 /// <param name="registry">The registry.</param>
 /// <param name="graphicsDevice">The graphics device.</param>
 public GraphicsDeviceServiceLocal(IServiceRegistry registry, GraphicsDevice graphicsDevice)
 {
     if (registry != null)
     {
         registry.AddService(typeof(IGraphicsDeviceService), this);
     }
     GraphicsDevice = graphicsDevice;
 }
        private static void Register(this Container container, IServiceRegistry registry)
        {
            container.Register(registry.TypeRegistrations);

            container.Register(registry.CollectionTypeRegistrations);

            container.Register(registry.InstanceRegistrations);
        }
        public Bullet2PhysicsSystem(IServiceRegistry registry)
            : base(registry)
        {
            UpdateOrder = -1000; //make sure physics runs before everything
            registry.AddService(typeof(IPhysicsSystem), this);

            Enabled = true; //enabled by default
        }
 private void ConfigureContainer(IServiceRegistry registry)
 {
     registry.RegisterInstance<IFodyLogger>(this);
     registry.RegisterInstance<ModuleWeaver>(this);
     registry.RegisterInstance<ModuleDefinition>(this.ModuleDefinition);
     registry.RegisterAssembly(GetType().Assembly
         , (serviceType, implementingType) => typeof(IModuleProcessor).IsAssignableFrom(implementingType));
 }
        private static InputManager NewInputManagerWinforms(IServiceRegistry registry)
        {
#if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP && SILICONSTUDIO_XENKO_UI_WINFORMS
            return new InputManagerWinforms(registry);
#else
            return null;
#endif
        }
        private static InputManager NewInputManagerWpf(IServiceRegistry registry)
        {
#if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP && SILICONSTUDIO_XENKO_UI_WPF && !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGL
            return new InputManagerWpf(registry);
#else
            return null;
#endif
        }
        public void Compose(IServiceRegistry serviceRegistry)
        {
            serviceRegistry.RegisterFrom<CommonCompositionRoot>();
            serviceRegistry.RegisterFrom<ThreeProducibleUnitsCompositionRoot>();

            serviceRegistry.Register<IWorldAge, LinearWorldAge>(new PerContainerLifetime());
            serviceRegistry.Register<IWinnerStrategy, RedWinsIn3000Bce>(new PerContainerLifetime());
        }
        public void Compose(IServiceRegistry serviceRegistry)
        {
            serviceRegistry.Register<IAspectSerializer, AspectDataContractSerializer>(typeof(AspectDataContractSerializer).FullName, new PerContainerLifetime());

            serviceRegistry.Register<IAspectSerializer, AspectXmlSerializer>(typeof(AspectXmlSerializer).FullName, new PerContainerLifetime());

            serviceRegistry.Register<IAspectSerializerFactory, AspectSerializerFactory>(new PerContainerLifetime());
        }
Example #21
0
 public GameFontSystem(IServiceRegistry registry)
     : base(registry)
 {
     Visible = true;
     FontSystem = new FontSystem();
     Services.AddService(typeof(FontSystem), FontSystem);
     Services.AddService(typeof(IFontFactory), FontSystem);
 }
 public void Load(IServiceRegistry registry)
 {
     if (!registry.IsRegistered(typeof (IEventAggregator)))
     {
         registry.Register<IEventAggregator, EventAggregator>(true);
     }
     registry.Register<IMessageBus, PrismMessageBus>(true);
 }
Example #23
0
        /// <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);
        }
        public void Compose(IServiceRegistry serviceRegistry)
        {
            serviceRegistry.RegisterFrom<CommonCompositionRoot>();
            serviceRegistry.RegisterFrom<FourProducibleUnitsCompositionRoot>();

            serviceRegistry.Register<IWorldAge, DeceleratingWorldAge>(new PerContainerLifetime());
            serviceRegistry.Register<IWinnerStrategy, CityConquerorWins>(new PerContainerLifetime());
        }
        private static void Add(this IProfileRegistry registry, IServiceRegistry serviceRegistry)
        {
            registry.Add(serviceRegistry.TypeRegistrations);

            registry.Add(serviceRegistry.CollectionTypeRegistrations);

            registry.Add(serviceRegistry.InstanceRegistrations);
        }
        public DebugConsoleSystem(IServiceRegistry registry) : base(registry)
        {
            registry.AddService(typeof(DebugConsoleSystem), this);

            Visible = true;

            DrawOrder = 0xffffff;
            UpdateOrder = -100100; //before script
        }
Example #27
0
        public void Compose(IServiceRegistry serviceRegistry)
        {
            serviceRegistry.RegisterAssembly("DrawPub*.dll");
            serviceRegistry.Register<IInterceptor, LogInterceptor>("LogInterceptor");

            serviceRegistry.Intercept(sr => sr.ServiceType == typeof(IUserAppplicationService), DefineProxyType);
            serviceRegistry.Intercept(sr => sr.ServiceType == typeof(IUserRepository), DefineProxyType);
            serviceRegistry.Intercept(sr => sr.ServiceType == typeof(IConnectionProvider), DefineProxyType);
        }
        public void Compose(IServiceRegistry serviceRegistry)
        {
            var players = new[] { new Player("Red"), new Player("Blue") };
            serviceRegistry.Register(_ => players, new PerContainerLifetime());

            serviceRegistry.Register<RoundRobinTurns>(new PerContainerLifetime());
            serviceRegistry.Register<ITurnTaking>(c => c.GetInstance<RoundRobinTurns>());
            serviceRegistry.Register<INotifyBeginningNextRound>(c => c.GetInstance<RoundRobinTurns>());
        }
Example #29
0
 public void Compose(IServiceRegistry serviceRegistry)
 {
     serviceRegistry.Register<IFileParserFactory, FileParserFactory>(new PerContainerLifetime());
     serviceRegistry.Register<FIleParserManagerFactory>();
     serviceRegistry.Register<IFileParserManager>((serviceFactory) => new LoggingFileParserManager(serviceFactory.GetInstance<FIleParserManagerFactory>().Create()));
     serviceRegistry.Register<ICharacteristicBuilder, CharacteristicBuilder>(new PerContainerLifetime());
     serviceRegistry.Register<ICharacteristicManagerFactory, CharacteristicManagerFactory>();
     serviceRegistry.Register<ISignalProcessorServiceFactory, SignalProcessorServiceFactory>(new PerRequestLifeTime());
 }
        public void Scan(Assembly assembly, IServiceRegistry serviceRegistry, Func<LightInject.ILifetime> lifetimeFactory, Func<Type, Type, bool> shouldRegister)
        {
            var serviceTypes = namedTypeExtractor.Execute(assembly);
            foreach (var type in serviceTypes)
            {
                foreach (NamedAttribute attr in type.GetCustomAttributes(typeof(NamedAttribute), false))
                {
                    Type serviceType = attr.ServiceType;
                    if (serviceType == null)
                    {
                        var interfaces = type.GetInterfaces();
                        if (interfaces.Length != 1)
                        {
                            throw new ArgumentException("As service type not specified, a unique interface is required to be implemented or inherited by the type, or a base class is required to be inherited by the type, please supply the parameter value explicitly.", "ServiceType");
                        }

                        serviceType = interfaces[0];
                    }

                    LightInject.ILifetime lifetime;
                    if (attr.LifetimeType != null)
                    {
                        if (!typeof(ILifetime).IsAssignableFrom(attr.LifetimeType))
                        {
                            throw new ArgumentException("Type is not an implementation of the ILifetime interface.", "LifetimeType");
                        }

                        if (attr.LifetimeType == typeof(PerContainerLifetime))
                        {
                            lifetime = new LightInject.PerContainerLifetime();
                        }
                        else if (attr.LifetimeType == typeof(PerLookupLifetime))
                        {
                            lifetime = null;
                        }
                        else
                        {
                            lifetime = new AdapterLifetime((ILifetime)Activator.CreateInstance(attr.LifetimeType));
                        }
                    }
                    else
                    {
                        lifetime = new LightInject.PerContainerLifetime();
                    }

                    if (attr.ServiceName == null)
                    {
                        serviceRegistry.Register(serviceType, type, lifetime);
                    }
                    else
                    {
                        serviceRegistry.Register(serviceType, type, attr.ServiceName, lifetime);
                    }
                }
            }
        }
Example #31
0
 /// <summary>
 /// Registers a scoped service of type <typeparamref name="TService"/> as a concrete service.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <typeparam name="TService">The type of service to register.</typeparam>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterScoped <TService>(this IServiceRegistry serviceRegistry)
 => serviceRegistry.Register <TService>(new PerScopeLifetime());
Example #32
0
 /// <summary>
 /// Registers a singleton service of type <typeparamref name="TService"/> using a factory function.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="factory">The factory function used to create the service instance.</param>
 /// <param name="serviceName">The name of the service to register.</param>
 /// <typeparam name="TService">The type of service to register.</typeparam>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterSingleton <TService>(this IServiceRegistry serviceRegistry, Func <IServiceFactory, TService> factory, string serviceName)
 => serviceRegistry.Register <TService>(factory, serviceName, new PerContainerLifetime());
Example #33
0
        public LoadWallPostLookupsAction(IServiceRegistry serviceRegistry)
        {
            Guard.ArgumentNotNull(serviceRegistry, "serviceRegistry");

            this.serviceRegistry = serviceRegistry;
        }
 /// <summary>
 /// Registers all <see cref="ApiController"/> implementations found in this assembly.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 public static void RegisterApiControllers(this IServiceRegistry serviceRegistry)
 {
     RegisterApiControllers(serviceRegistry, Assembly.GetCallingAssembly());
 }
Example #35
0
 protected GamePlatform(Game game)
 {
     this.game = game;
     Services  = game.Services;
     Services.AddService(typeof(IGraphicsDeviceFactory), this);
 }
Example #36
0
 private void RegisterGlobeServices(IServiceRegistry serviceRegistry)
 {
     serviceRegistry.Register <IWorldGenerator, WorldGenerator>();
 }
Example #37
0
 /// <summary>
 /// Registers the <paramref name="serviceType"/> with a given <paramref name="lifetime"/> using the non-generic <paramref name="factory"/> to resolve the instance.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceType">The type of service to register.</param>
 /// <param name="factory">The factory used to resolve the instance.</param>
 /// <param name="lifetime">The <see cref="ILifetime"/> used to control the lifetime of the service.</param>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry Register(this IServiceRegistry serviceRegistry, Type serviceType, Func <IServiceFactory, object> factory, ILifetime lifetime)
 => Register(serviceRegistry, serviceType, factory, string.Empty, lifetime);
Example #38
0
 /// <summary>
 /// Registers a transient <paramref name="serviceType"/> using the non-generic <paramref name="factory"/> to resolve the instance.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceType">The type of service to register.</param>
 /// <param name="factory">The factory used to resolve the instance.</param>
 /// <param name="serviceName">The name the service to register.</param>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterTransient(this IServiceRegistry serviceRegistry, Type serviceType, Func <IServiceFactory, object> factory, string serviceName)
 {
     return(serviceRegistry.Register(serviceType, factory, serviceName));
 }
Example #39
0
 public void RegisterServices(IServiceRegistry serviceRegistry)
 {
     RegisterSchemeService(serviceRegistry);
     RegisterAuxServices(serviceRegistry);
     RegisterGlobeServices(serviceRegistry);
 }
Example #40
0
 /// <summary>
 /// Registers a singleton service of type <typeparamref name="TService"/> with an implementing type of <typeparamref name="TImplementation"/>.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceName">The name of the service to register.</param>
 /// <typeparam name="TService">The type of service to register.</typeparam>
 /// <typeparam name="TImplementation">The type implementing the service type.</typeparam>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterSingleton <TService, TImplementation>(this IServiceRegistry serviceRegistry, string serviceName)
     where TImplementation : TService
 => serviceRegistry.Register <TService, TImplementation>(serviceName, new PerContainerLifetime());
Example #41
0
 /// <summary>
 /// Registers a singleton service of type <typeparamref name="TService"/> as a concrete service.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <typeparam name="TService">The type of service to register.</typeparam>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterSingleton <TService>(this IServiceRegistry serviceRegistry)
 => serviceRegistry.Register <TService>(new PerContainerLifetime());
Example #42
0
 /// <summary>
 /// Registers a scoped service of type <typeparamref name="TService"/> with an implementing type of <typeparamref name="TImplementation"/>.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceName">The name of the service to register.</param>
 /// <typeparam name="TService">The type of service to register.</typeparam>
 /// <typeparam name="TImplementation">The type implementing the service type.</typeparam>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterScoped <TService, TImplementation>(this IServiceRegistry serviceRegistry, string serviceName)
     where TImplementation : TService
 => serviceRegistry.Register <TService, TImplementation>(serviceName, new PerScopeLifetime());
Example #43
0
 /// <summary>
 /// Registers the <paramref name="serviceType"/> using the non-generic <paramref name="factory"/> to resolve the instance.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceType">The type of service to register.</param>
 /// <param name="factory">The factory used to resolve the instance.</param>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry Register(this IServiceRegistry serviceRegistry, Type serviceType, Func <IServiceFactory, object> factory)
 => Register(serviceRegistry, serviceType, factory, string.Empty, null);
Example #44
0
 /// <summary>
 /// Registers a singleton service of type <paramref name="serviceType"/> as a concrete service type.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceType">The type of service to register.</param>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterSingleton(this IServiceRegistry serviceRegistry, Type serviceType)
 => serviceRegistry.Register(serviceType, new PerContainerLifetime());
Example #45
0
 public void SetUp()
 {
     theServices = new FubuRegistry().BuildGraph().Services;
 }
 /// <summary>
 /// Sets the registry instance ServiceManager works with
 /// </summary>
 /// <param name="registry"></param>
 public static void SetRegistry(IServiceRegistry registry)
 {
     Registry = registry ?? throw new ArgumentNullException(nameof(registry));
 }
Example #47
0
        /// <summary>
        /// Подготовка дополнительных сервисов
        /// </summary>
        private void RegisterAuxServices(IServiceRegistry container)
        {
            var dice = new LinearDice();

            container.Register <IDice>(factory => dice, LightInjectWrapper.CreateSingleton());
        }
Example #48
0
 /// <summary>
 /// Installs the specified service registry.
 /// </summary>
 /// <param name="serviceRegistry">The service registry.</param>
 public void Install(IServiceRegistry serviceRegistry)
 {
     serviceRegistry.RegisterAssembly(typeof(BaseApplication <,>).Assembly,
                                      (s, _) => s.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IBaseApplication <,>)));
 }
Example #49
0
 /// <summary>
 /// Registers a scoped <paramref name="serviceType"/> using the non-generic <paramref name="factory"/> to resolve the instance.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceType">The type of service to register.</param>
 /// <param name="factory">The factory used to resolve the instance.</param>
 /// <param name="serviceName">The name the service to register.</param>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterScoped(this IServiceRegistry serviceRegistry, Type serviceType, Func <IServiceFactory, object> factory, string serviceName)
 {
     return(serviceRegistry.Register(serviceType, factory, serviceName, new PerScopeLifetime()));
 }
Example #50
0
 public DefaultSliderRenderer(IServiceRegistry services)
     : base(services)
 {
 }
 public DefaultTextBlockRenderer(IServiceRegistry services)
     : base(services)
 {
 }
Example #52
0
 public InputManager(IServiceRegistry registry) : base(registry)
 {
     HasKeyboard = true;
     HasMouse    = false;
     HasPointer  = true;
 }
 /// <summary>
 /// Resets ServiceManager to its initial state just like right
 /// after the framework invokes its static constructor
 /// </summary>
 public static void Reset()
 {
     Registry = new ServiceRegistry();
 }
Example #54
0
 public SceneEditorView(IServiceRegistry services) : base(services)
 {
 }
Example #55
0
 public ResumeManager(IServiceRegistry services)
 {
     GraphicsDevice = services.GetServiceAs <IGraphicsDeviceService>().GraphicsDevice;
 }
Example #56
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameWindowRenderer" /> class.
 /// </summary>
 /// <param name="registry">The registry.</param>
 /// <param name="gameContext">The window context.</param>
 public GameWindowRenderer(IServiceRegistry registry, GameContext gameContext = null)
     : base(registry)
 {
     GameContext = gameContext ?? new GameContext();
 }
Example #57
0
 public HierarchyView(IServiceRegistry service) : base(service)
 {
 }
Example #58
0
 public CameraScript(IServiceRegistry registry) : base(registry)
 {
     Speed     = 10.0f;
     MoveSpeed = 2.0f;
 }
Example #59
0
 /// <summary>
 /// Registers a scoped service of type <paramref name="serviceType"/> as a concrete service type.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceType">The type of service to register.</param>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterScoped(this IServiceRegistry serviceRegistry, Type serviceType)
 => serviceRegistry.Register(serviceType, new PerScopeLifetime());
Example #60
0
 /// <summary>
 /// Registers a singleton service of type <paramref name="serviceType"/> with an implementing type of <paramref name="implementingType"/>.
 /// </summary>
 /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/>.</param>
 /// <param name="serviceType">The type of service to register.</param>
 /// <param name="implementingType">The type implementing the service type.</param>
 /// <param name="serviceName">The name of the service to register.</param>
 /// <returns>The <see cref="IServiceRegistry"/>, for chaining calls.</returns>
 public static IServiceRegistry RegisterSingleton(this IServiceRegistry serviceRegistry, Type serviceType, Type implementingType, string serviceName)
 => serviceRegistry.Register(serviceType, implementingType, serviceName, new PerContainerLifetime());