コード例 #1
0
        public object GetService(Type type)
        {
            Asserter.AssertIsNotNull(type, "type");

            if (_services.ContainsKey(type))
            {
                return(_services[type]);
            }

            return(null);
        }
コード例 #2
0
        public void AddService(Type type, object provider)
        {
            Asserter.AssertIsNotNull(type, "type");
            Asserter.AssertIsNotNull(provider, "provider");
            Asserter.Assert(!_services.ContainsKey(type), "Service is already present.");

            if (!type.IsAssignableFrom(provider.GetType()))
            {
                throw new ArgumentException(string.Format("Service type {0} must be assignable from type {1}.", provider.GetType().FullName, type.FullName));
            }

            _services.Add(type, provider);
        }
コード例 #3
0
        public Engine(DrawingSurface drawingSurface)
        {
            RootControl = (Control)App.Current.RootVisual;

            Asserter.AssertIsNotNull(RootControl, "RootControl");
            Asserter.AssertIsNotNull(drawingSurface, "drawingSurface");

            _drawingSurface             = drawingSurface;
            _content                    = new ContentManager(_gameServices);
            _content.RootDirectory      = "Content";
            _totalGameTime              = TimeSpan.Zero;
            _accumulatedElapsedGameTime = TimeSpan.Zero;
            _lastFrameElapsedGameTime   = TimeSpan.Zero;
            _targetElapsedTime          = TimeSpan.FromTicks(166667L);
            _drawState                  = new DrawState();
            _updateState                = new UpdateState();
            _gameServices               = new GameServiceContainer();
        }
コード例 #4
0
 public void RemoveService(Type type)
 {
     Asserter.AssertIsNotNull(type, "type");
     _services.Remove(type);
 }