当前位置: 首页>>代码示例>>C#>>正文


C# IServiceLocator.GetInstance方法代码示例

本文整理汇总了C#中IServiceLocator.GetInstance方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceLocator.GetInstance方法的具体用法?C# IServiceLocator.GetInstance怎么用?C# IServiceLocator.GetInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceLocator的用法示例。


在下文中一共展示了IServiceLocator.GetInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

 public void Execute(IServiceLocator serviceLocator)
 {
     Execute(
         serviceLocator.GetInstance<IWindowManager>(),
         serviceLocator.GetInstance<IQuestionDialog>()
         );
 }
开发者ID:Buthrakaur,项目名称:WpfModularApp,代码行数:7,代码来源:MessageBoxResult.cs

示例2: PostProcessingGraphicsScreen

    public PostProcessingGraphicsScreen(IServiceLocator services)
      : base(services.GetInstance<IGraphicsService>())
    {
      _sampleFramework = services.GetInstance<SampleFramework>();

      _spriteBatch = new SpriteBatch(GraphicsService.GraphicsDevice);
      _clearGBufferRenderer = new ClearGBufferRenderer(GraphicsService);
      _rebuildZBufferRenderer = new RebuildZBufferRenderer(GraphicsService);
      _meshRenderer = new MeshRenderer();
      _skyRenderer = new SkyRenderer(GraphicsService);
      _billboardRenderer = new BillboardRenderer(GraphicsService, 2048);

      Scene = new Scene();
      PostProcessors = new PostProcessorChain(GraphicsService);

      // Use 2D texture for reticle.
      var contentManager = services.GetInstance<ContentManager>();
      _reticle = contentManager.Load<Texture2D>("Reticle");

      // Use the sprite font of the GUI.
      var uiContentManager = services.GetInstance<ContentManager>("UIContent");
      var spriteFont = uiContentManager.Load<SpriteFont>("UI Themes/BlendBlue/Default");
      DebugRenderer = new DebugRenderer(GraphicsService, spriteFont)
      {
        DefaultColor = new Color(0, 0, 0),
        DefaultTextPosition = new Vector2F(10),
      };
    }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例3: GuiGraphicsScreen

    /// <summary>
    /// Initializes a new instance of the <see cref="GuiGraphicsScreen"/> class.
    /// </summary>
    /// <param name="services">The service locator.</param>
    public GuiGraphicsScreen(IServiceLocator services)
      : base(services.GetInstance<IGraphicsService>())
    {
      Name = "GUI"; // Just for debugging.

      // Get required services.
      _inputService = services.GetInstance<IInputService>();
      _uiService = services.GetInstance<IUIService>();
      var contentManager = services.GetInstance<ContentManager>("UIContent");

      // Load a UI theme and create the UI renderer and the UI screen. See the
      // DigitalRune Game UI documentation and samples for more details.
      var theme = contentManager.Load<Theme>("UI Themes/BlendBlue/Theme");
      var renderer = new UIRenderer(GraphicsService.GraphicsDevice, theme);
      UIScreen = new UIScreen("Default", renderer)
      {
        Background = Color.Transparent,
        ZIndex = int.MaxValue,
      };
      _uiService.Screens.Add(UIScreen);

      // When the background is hidden, the UIScreen should block all input.
      UIScreen.InputProcessed += (s, e) =>
                                 {
                                   if (HideBackground)
                                   {
                                     // Set all input devices to 'handled'.
                                     _inputService.IsGamePadHandled(LogicalPlayerIndex.Any);
                                     _inputService.IsKeyboardHandled = true;
                                     _inputService.IsMouseOrTouchHandled = true;
                                   }
                                 };
    }
开发者ID:,项目名称:,代码行数:37,代码来源:

示例4: MainMenuComponent

 public MainMenuComponent(Microsoft.Xna.Framework.Game game, IServiceLocator services)
   : base(game)
 {
   _services = services;
   _inputService = services.GetInstance<IInputService>();
   _graphicsService = services.GetInstance<IGraphicsService>();
   _uiService = services.GetInstance<IUIService>();
 }
开发者ID:,项目名称:,代码行数:8,代码来源:

示例5: ExplosionObject

    public ExplosionObject(IServiceLocator services)
    {
      Name = "Explosion";

      _inputService = services.GetInstance<IInputService>();
      _simulation = services.GetInstance<Simulation>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
    }
开发者ID:,项目名称:,代码行数:8,代码来源:

示例6: BallShooterObject

    public BallShooterObject(IServiceLocator services)
    {
      Name = "BallShooter";
      Speed = 100;

      _inputService = services.GetInstance<IInputService>();
      _simulation = services.GetInstance<Simulation>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
    }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例7: SampleGraphicsScreen

        public SampleGraphicsScreen(IServiceLocator services)
            : base(services.GetInstance<IGraphicsService>())
        {
            _sampleFramework = services.GetInstance<SampleFramework>();

              Name = "SampleScreen";
              ClearBackground = false;
              BackgroundColor = new Color(220, 220, 220);
              DrawReticle = false;
              UseFixedWidthFont = false;

              // Use 2D texture for reticle.
              var contentManager = services.GetInstance<ContentManager>();
              _reticle = contentManager.Load<Texture2D>("Reticle");

              // Get the sprite fonts used in the UI theme.
              var uiContentManager = services.GetInstance<ContentManager>("UIContent");
              _defaultFont = uiContentManager.Load<SpriteFont>("UI Themes/BlendBlue/Default");
              _fixedWidthFont = uiContentManager.Load<SpriteFont>("UI Themes/BlendBlue/Console");

              // Set up 2D camera such that (0, 0) is upper, left corner of screen and
              // (screenWidth, screenHeight) is lower, right corner of screen.
              var graphicsDevice = GraphicsService.GraphicsDevice;
              int screenWidth = graphicsDevice.PresentationParameters.BackBufferWidth;
              int screenHeight = graphicsDevice.PresentationParameters.BackBufferHeight;
              var projection = new OrthographicProjection
              {
            Near = 0, Far = 2000,
            Left = 0, Right = screenWidth,
            Top = 0, Bottom = screenHeight,
              };
              var camera = new Camera(projection);
              _cameraNode2D = new CameraNode(camera)
              {
            PoseWorld = new Pose(new Vector3F(0, 0, 1000)),
              };

              // Initialize renderers.
              _spriteBatch = new SpriteBatch(graphicsDevice);
              _meshRenderer = new MeshRenderer();
              _billboardRenderer = new BillboardRenderer(GraphicsService, 2048);
              DebugRenderer2D = new DebugRenderer(GraphicsService, _defaultFont)
              {
            SpriteFont = _defaultFont,
            DefaultColor = new Color(0, 0, 0),
            DefaultTextPosition = new Vector2F(10)
              };
              DebugRenderer = new DebugRenderer(GraphicsService, _defaultFont)
              {
            SpriteFont = _defaultFont,
            DefaultColor = new Color(0, 0, 0),
            DefaultTextPosition = new Vector2F(10)
              };

              Scene = new Scene();
        }
开发者ID:,项目名称:,代码行数:56,代码来源:

示例8: RectangleObject

    public RectangleObject(IServiceLocator services)
    {
      _inputService = services.GetInstance<IInputService>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
      _debugRenderer = services.GetInstance<DebugRenderer>("DebugRenderer2D");

      _left = RandomHelper.Random.NextInteger(0, 1000);
      _top = RandomHelper.Random.NextInteger(0, 600);
      SetRandomColor();
    }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例9: Editor2DCameraObject

        public Editor2DCameraObject(IServiceLocator services)
        {
            Name = "Editor2DCamera";

            _services = services;
            _inputService = services.GetInstance<IInputService>();
            _animationService = services.GetInstance<IAnimationService>();

            IsEnabled = true;
        }
开发者ID:mattbettcher,项目名称:kbPCB,代码行数:10,代码来源:Editor2DCameraObject.cs

示例10: MyGameComponent

    public MyGameComponent(Microsoft.Xna.Framework.Game game, IServiceLocator services)
      : base(game)
    {
      // Get the services that this component needs regularly.
      _services = services;
      _inputService = services.GetInstance<IInputService>();
      _simulation = services.GetInstance<Simulation>();
      _graphicsService = services.GetInstance<IGraphicsService>();
      _gameObjectService = services.GetInstance<IGameObjectService>();
      _uiService = services.GetInstance<IUIService>();

      // Add gravity and damping to the physics simulation.
      _simulation.ForceEffects.Add(new Gravity());
      _simulation.ForceEffects.Add(new Damping());

      // Create the DeferredGraphicsScreen and some 3D objects.
      _deferredGraphicsScreen = new DeferredGraphicsScreen(services);
      _deferredGraphicsScreen.DrawReticle = true;
      _graphicsService.Screens.Insert(0, _deferredGraphicsScreen);

      // The GameObjects below expect try to retrieve DebugRenderer and Scene via
      // service container.
      var serviceContainer = (ServiceContainer)services;
      serviceContainer.Register(typeof(DebugRenderer), null, _deferredGraphicsScreen.DebugRenderer);
      serviceContainer.Register(typeof(IScene), null, _deferredGraphicsScreen.Scene);

      _cameraGameObject = new CameraObject(services);
      _gameObjectService.Objects.Add(_cameraGameObject);
      _deferredGraphicsScreen.ActiveCameraNode = _cameraGameObject.CameraNode;
      _gameObjectService.Objects.Add(new GrabObject(services));
      _gameObjectService.Objects.Add(new StaticSkyObject(services));
      _gameObjectService.Objects.Add(new GroundObject(services));
      for (int i = 0; i < 10; i++)
        _gameObjectService.Objects.Add(new DynamicObject(services, 1));

      // Get the "SampleUI" screen that was created by the StartScreenComponent.
      _uiScreen = _uiService.Screens["SampleUI"];

      // Add a second GraphicsScreen. This time it is a DelegateGraphicsScreen that
      // draws the UI over DeferredGraphicsScreen.
      _delegateGraphicsScreen = new DelegateGraphicsScreen(_graphicsService)
      {
        RenderCallback = context => _uiScreen.Draw(context.DeltaTime)
      };
      _graphicsService.Screens.Insert(1, _delegateGraphicsScreen);

      // Create the game menu window. But do not display it yet.
      _gameMenuWindow = new GameMenuWindow
      {
        // If the menu is opened and closed a lot, it is more efficient when _gameMenuWindow.Close()
        // makes the window invisible but does not remove it from the screen.
        HideOnClose = true,
      };
    }
开发者ID:,项目名称:,代码行数:54,代码来源:

示例11: InGameUIScreen

    public InGameUIScreen(IServiceLocator services, IUIRenderer renderer)
      : base("InGame", renderer)
    {
      var gameObjectService = services.GetInstance<IGameObjectService>();
      _cameraObject = (CameraObject)gameObjectService.Objects["Camera"];

      _simulation = services.GetInstance<Simulation>();

      Background = Color.White;

      // Add one window to the screen.
      Window window = new InGameWindow(services) { X = 175, Y = 30 };
      window.Show(this);
    }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例12: WeightedBlendedOITScreen

    public WeightedBlendedOITScreen(IServiceLocator services)
      : base(services.GetInstance<IGraphicsService>())
    {
      Coverage = GraphicsScreenCoverage.Full;
      Scene = new Scene();
      EnableWboit = true;

      _meshRenderer = new MeshRenderer();

      var content = services.GetInstance<ContentManager>();
      _wboitEffect = content.Load<Effect>("WeightedBlendedOIT/WeightedBlendedOIT");
      _parameterViewportSize = _wboitEffect.Parameters["ViewportSize"];
      _parameterTextureA = _wboitEffect.Parameters["TextureA"];
      _parameterTextureB = _wboitEffect.Parameters["TextureB"];
    }
开发者ID:,项目名称:,代码行数:15,代码来源:

示例13: ExecuteCore

        /// <summary>
        /// Executes the task.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        protected override void ExecuteCore(IServiceLocator serviceLocator)
        {
            IEnumerable<IModelMetadataConfiguration> configurations = serviceLocator.GetAllInstances<IModelMetadataConfiguration>();

            IModelMetadataRegistry registry = serviceLocator.GetInstance<IModelMetadataRegistry>();

            configurations.Each(configuration => registry.Register(configuration.ModelType, configuration.Configurations));

            ModelMetadataProviders.Current = serviceLocator.GetInstance<CompositeModelMetadataProvider>();

            // We have to make sure that custom provider will appear first,
            // otherwise it will return wrong validation messages.
            serviceLocator.GetAllInstances<ModelValidatorProvider>()
                          .Each(provider => ModelValidatorProviders.Providers.Insert(0, provider));
        }
开发者ID:GTuritto,项目名称:AspNetMvcExtensibility,代码行数:19,代码来源:RegisterModelMetadata.cs

示例14: ReadSettings

        public void ReadSettings(IServiceLocator services)
        {
            var settings = services.GetInstance(SettingAddress.OwnerType);
            Uri = (Uri) SettingAddress.GetValue(settings);

            SettingsRules.Each(x => x.ApplySettings(settings, this));
        }
开发者ID:DarthFubuMVC,项目名称:fubumvc,代码行数:7,代码来源:ChannelNode.cs

示例15: Initialize

 public override void Initialize(IServiceLocator locator)
 {
     //Initializácia kodových tabuliek modulu administrácia
     locator.GetInstance<AdministrationCodeTableService>()
         .Initialize();
     
 }
开发者ID:aytacozkan,项目名称:nisproject,代码行数:7,代码来源:Configuration.cs


注:本文中的IServiceLocator.GetInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。