示例#1
0
        public DataSource()
        {
            string       pathToData = FetchPath("Data", "plist");
            NSDictionary dict       = NSDictionary.FromFile(pathToData);

            nameStorage = new TitleStorage(dict);
        }
示例#2
0
        /// <summary>
        /// Called when graphics resources need to be loaded. Override this method to load any
        /// game-specific graphics resources.
        /// </summary>
        protected override void LoadContent()
        {
            try
            {
                // Configure ContentManager to load the SpriteFont.
                var titleStorage = new TitleStorage("Content");
                var vfsStorage   = new VfsStorage();
                vfsStorage.MountInfos.Add(new VfsMountInfo(titleStorage, null));
#if MONOGAME
                var assetsStorage = new ZipStorage(titleStorage, "Content.zip");
                vfsStorage.MountInfos.Add(new VfsMountInfo(assetsStorage, null));
                var drStorage = new ZipStorage(titleStorage, "DigitalRune.zip");
                vfsStorage.MountInfos.Add(new VfsMountInfo(drStorage, null));
#endif
                Content = new StorageContentManager(Services, vfsStorage);

                // Load SpriteFont.
                _spriteFont  = Content.Load <SpriteFont>("SpriteFont1");
                _spriteBatch = new SpriteBatch(GraphicsDevice);
            }
            catch
            {
                // Failed to load sprite font.
            }
        }
示例#3
0
    protected override void Initialize()
    {
      base.Initialize();

      // Get the standard XNA window.
      _gameForm = Control.FromHandle(Window.Handle) as Form;


      // Create a "virtual file system" for reading game assets.
      var titleStorage = new TitleStorage("Content");
      var assetsStorage = new ZipStorage(titleStorage, "Content.zip");
      var drStorage = new ZipStorage(titleStorage, "DigitalRune.zip");
      var vfsStorage = new VfsStorage();
      vfsStorage.MountInfos.Add(new VfsMountInfo(titleStorage, null));
      vfsStorage.MountInfos.Add(new VfsMountInfo(assetsStorage, null));
      vfsStorage.MountInfos.Add(new VfsMountInfo(drStorage, null));

      Content = new StorageContentManager(Services, vfsStorage);
#else
      Content.RootDirectory = "Content";

      // Create the DigitalRune GraphicsManager.
      _graphicsManager = new GraphicsManager(GraphicsDevice, Window, Content);

      // Add graphics service to service provider
      Services.AddService(typeof(IGraphicsService), _graphicsManager);

      // Add a few GraphicsScreens that draw stuff.
      _graphicsManager.Screens.Add(new BackgroundGraphicsScreen(_graphicsManager));
      _graphicsManager.Screens.Add(new TriangleGraphicsScreen(_graphicsManager));
      _graphicsManager.Screens.Add(new TextGraphicsScreen(_graphicsManager, Content));
    }
        private static async Task <int> OnGetQuota(QuotaOptions options)
        {
            Console.WriteLine($"Getting global storage quota for scid : {options.ServiceConfigurationId}, sandbox {options.Sandbox}");
            GlobalStorageQuotaInfo result =
                await TitleStorage.GetGlobalStorageQuotaAsync(options.ServiceConfigurationId, options.Sandbox);

            Console.WriteLine($"Total bytes : {result.QuotaBytes}, used bytes {result.UsedBytes}");

            return(0);
        }
        private static async Task <int> OnDelete(DeleteOptions options)
        {
            Console.WriteLine(
                $"Deleting global storage blob list for scid : {options.ServiceConfigurationId}, sandbox {options.Sandbox}, path {options.Path}, type {options.Type}");

            await TitleStorage.DeleteGlobalStorageBlobAsync(options.ServiceConfigurationId, options.Sandbox,
                                                            options.Path, (TitleStorageBlobType)options.Type);

            Console.WriteLine("Global storage blob deleted");

            return(0);
        }
        private static async Task <int> OnUpload(UploadOptions options)
        {
            Console.WriteLine(
                $"Uploading global storage blob list for scid : {options.ServiceConfigurationId}, sandbox {options.Sandbox}, path {options.Path}, type {options.Type}");

            byte[] blobData = File.ReadAllBytes(options.File);

            await TitleStorage.UploadGlobalStorageBlobAsync(options.ServiceConfigurationId, options.Sandbox, options.Path,
                                                            (TitleStorageBlobType)options.Type, blobData);

            Console.WriteLine("Global storage blob uploaded.");

            return(0);
        }
        private static async Task <int> OnGetBlobMetadata(BlobMetadataOptions options)
        {
            Console.WriteLine(
                $"Getting global storage blob list for scid : {options.ServiceConfigurationId}, sandbox {options.Sandbox}, path {options.Path}");
            TitleStorageBlobMetadataResult result = await TitleStorage.GetGlobalStorageBlobMetaDataAsync(
                options.ServiceConfigurationId, options.Sandbox, options.Path, options.MaxItems, options.SkipItems);

            Console.WriteLine(
                $"Total {result.TotalItems} items found, Displaying item {options.SkipItems} to {options.SkipItems + result.Items.Count()}");
            foreach (var metadata in result.Items)
            {
                Console.WriteLine($"\t{metadata.Path}, \t{metadata.Type}, \t{metadata.Size}");
            }

            return(0);
        }
        public async Task DeleteBlob()
        {
            SetUpMockAuth();
            SetupMockBytes();

            var uri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath},{DefaultFileType}");

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Delete, uri.ToString())
            .Respond("application/json", "{}");

            TestHook.MockHttpHandler = mockHttp;

            TitleStorageBlobType fileType = (TitleStorageBlobType)Enum.Parse(typeof(TitleStorageBlobType), DefaultFileType, true);
            await TitleStorage.DeleteGlobalStorageBlob(DefaultScid, DefaultSandbox, DefaultGlobalStoragePath, fileType);
        }
示例#9
0
        public async Task UploadBlob()
        {
            this.SetUpMockAuth();
            this.SetupMockBytes();

            var uri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath},{DefaultFileType}");

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Put, uri.ToString())
            .WithHeaders("Authorization", this.ExpectedToken(DefaultScid, DefaultSandbox))
            .Respond("application/json", "{}");

            TestHook.MockHttpHandler = mockHttp;

            TitleStorageBlobType fileType = (TitleStorageBlobType)Enum.Parse(typeof(TitleStorageBlobType), DefaultFileType, true);
            await TitleStorage.UploadGlobalStorageBlobAsync(DefaultScid, DefaultSandbox, DefaultGlobalStoragePath, fileType, this.defaultBytes);
        }
示例#10
0
        public async Task GetBlobMetadata()
        {
            this.SetUpMockAuth();

            string response =
                "{'blobs':[" +
                "{'fileName':'test1.txt,config','etag':'','size':2}," +
                "{'fileName':'test11.txt,binary','etag':'','size':2}," +
                "{'fileName':'test2.txt,config','etag':'','size':2}," +
                "{'fileName':'test3.txt,config','etag':'','size':2}," +
                "{'fileName':'test4.txt,config','etag':'','size':2}," +
                "{'fileName':'test5.txt,config','etag':'','size':2}" +
                "]," +
                "'pagingInfo':{'totalItems':8,'continuationToken':'123456'}}";

            var uri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath}?maxItems={DefaultMaxItems}&skipItems={DefaultSkipItems}");

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(uri.ToString())
            .WithHeaders("Authorization", this.ExpectedToken(DefaultScid, DefaultSandbox))
            .Respond("application/json", response);

            TestHook.MockHttpHandler = mockHttp;

            var metadataResult = await TitleStorage.GetGlobalStorageBlobMetaDataAsync(DefaultScid, DefaultSandbox, DefaultGlobalStoragePath, DefaultMaxItems, DefaultSkipItems);

            Assert.AreEqual((uint)8, metadataResult.TotalItems);
            Assert.AreEqual(6, metadataResult.Items.Count());
            Assert.IsTrue(metadataResult.HasNext);

            // GetNextAsync
            var nextPageUri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath}?maxItems={DefaultMaxItems}&continuationToken=123456");

            mockHttp.Expect(nextPageUri.ToString())
            .WithHeaders("Authorization", this.ExpectedToken(DefaultScid, DefaultSandbox))
            .Respond("application/json", response);

            var metaResult1 = await metadataResult.GetNextAsync(DefaultMaxItems);

            Assert.AreEqual((uint)8, metadataResult.TotalItems);
            Assert.AreEqual(6, metadataResult.Items.Count());
            Assert.IsTrue(metadataResult.HasNext);
        }
        public async Task GetBlobMetadataNotFound()
        {
            SetUpMockAuth();

            var uri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath}");

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(uri.ToString())
            .Respond(HttpStatusCode.NotFound);

            TestHook.MockHttpHandler = mockHttp;

            var metadataResult = await TitleStorage.GetGlobalStorageBlobMetaData(DefaultScid, DefaultSandbox, DefaultGlobalStoragePath, DefaultMaxItems, DefaultSkipItems);

            Assert.AreEqual((uint)0, metadataResult.TotalItems);
            Assert.AreEqual(0, metadataResult.Items.Count());
            Assert.IsFalse(metadataResult.HasNext);
        }
        public async Task GetQuota()
        {
            SetUpMockAuth();

            string quotaResponse = $"{{'quotaInfo':{{'usedBytes':{DefaultUsedQuota},'quotaBytes':{DefaultQuota}}}}}";

            var uri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), "/global/scids/" + DefaultScid);

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(uri.ToString())
            .Respond("application/json", quotaResponse);

            TestHook.MockHttpHandler = mockHttp;

            var quotaInfo = await TitleStorage.GetGlobalStorageQuotaAsync(DefaultScid, DefaultSandbox);

            Assert.AreEqual(DefaultQuota, quotaInfo.QuotaBytes);
            Assert.AreEqual(DefaultUsedQuota, quotaInfo.UsedBytes);
        }
        private static async Task <int> OnDownload(DownloadOptions options)
        {
            // Check if file exist if no ForceOverWrite present.
            if (!options.ForceOverwrite && File.Exists(options.OutputFile))
            {
                Console.Error.WriteLine($"OutFile {options.OutputFile} already exist, pass in ForceOverwrite if you would like to overwrite");
                return(-1);
            }

            Console.WriteLine(
                $"Download global storage blob list for scid : {options.ServiceConfigurationId}, sandbox {options.Sandbox}, path {options.Path}, type {options.Type}");

            byte[] blobData = await TitleStorage.DownloadGlobalStorageBlobAsync(
                options.ServiceConfigurationId, options.Sandbox, options.Path, (TitleStorageBlobType)options.Type);

            File.WriteAllBytes(options.OutputFile, blobData);

            Console.WriteLine($"Global storage blob saved as {options.OutputFile}.");

            return(0);
        }
        public async Task DownloadBlob()
        {
            SetUpMockAuth();
            SetupMockBytes();

            var uri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath},{DefaultFileType}");

            var mockHttp = new MockHttpMessageHandler();

            Stream stream = new MemoryStream(this.defaultBytes);

            mockHttp.Expect(HttpMethod.Get, uri.ToString())
            .Respond("application/json", stream);

            TestHook.MockHttpHandler = mockHttp;

            TitleStorageBlobType fileType = (TitleStorageBlobType)Enum.Parse(typeof(TitleStorageBlobType), DefaultFileType, true);

            byte[] bytes = await TitleStorage.DownloadGlobalStorageBlob(DefaultScid, DefaultSandbox, DefaultGlobalStoragePath, fileType);

            Assert.AreEqual(bytes.Length, this.defaultBytes.Length);
        }
示例#15
0
        private void AddGraphicsService()
        {
            // ----- Storage
            // Create a "virtual file system" for reading game assets.
            var titleStorage       = new TitleStorage("Content");
            var assetsStorage      = new ZipStorage(titleStorage, "DigitalRune.Editor.Game.zip");
            var digitalRuneStorage = new ZipStorage(titleStorage, "DigitalRune.zip");
            var vfsStorage         = new VfsStorage();

            vfsStorage.MountInfos.Add(new VfsMountInfo(titleStorage, null));
            vfsStorage.MountInfos.Add(new VfsMountInfo(assetsStorage, null));
            vfsStorage.MountInfos.Add(new VfsMountInfo(digitalRuneStorage, null));

            // ----- Content
            _contentManager = new StorageContentManager(Editor.Services, vfsStorage);
            //_contentManager = new ContentManager(serviceContainer, "Content");
            Editor.Services.Register(typeof(ContentManager), null, _contentManager);

            // ----- Animations
            _animationManager = new AnimationManager();
            Editor.Services.Register(typeof(IAnimationService), null, _animationManager);

            // ----- Graphics
            // Create Direct3D 11 device.
            var presentationParameters = new PresentationParameters
            {
                BackBufferWidth    = 1,
                BackBufferHeight   = 1,
                DeviceWindowHandle = IntPtr.Zero
            };
            var graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, presentationParameters);

            Editor.Services.Register(typeof(IGraphicsDeviceService), null, new GraphicsDeviceManager(graphicsDevice));

            // Create and register the graphics manager.
            _graphicsManager = new GraphicsManager(graphicsDevice, _contentManager);
            Editor.Services.Register(typeof(IGraphicsService), null, _graphicsManager);
        }
示例#16
0
        public MyGame()
        {
            // ----- Service Container
            // The MyGame uses a ServiceContainer, which is a simple service locator
            // and Inversion of Control (IoC) container. (The ServiceContainer can be
            // replaced by any other container that implements System.IServiceProvider.)
            _serviceContainer = new ServiceContainer();
            ServiceLocator.SetLocatorProvider(() => _serviceContainer);

            // ----- Storage
            // Create a "virtual file system" for reading game assets.
            var titleStorage       = new TitleStorage("Content");
            var assetsStorage      = new ZipStorage(titleStorage, "Content.zip");
            var digitalRuneStorage = new ZipStorage(titleStorage, "DigitalRune.zip");
            var vfsStorage         = new VfsStorage();

            vfsStorage.MountInfos.Add(new VfsMountInfo(titleStorage, null));
            vfsStorage.MountInfos.Add(new VfsMountInfo(assetsStorage, null));
            vfsStorage.MountInfos.Add(new VfsMountInfo(digitalRuneStorage, null));

            // ----- Content
            _contentManager = new StorageContentManager(ServiceLocator.Current, vfsStorage);
            _serviceContainer.Register(typeof(ContentManager), null, _contentManager);

            // ----- Graphics
            // Create Direct3D 11 device.
            var presentationParameters = new PresentationParameters
            {
                BackBufferWidth  = 1,
                BackBufferHeight = 1,
                // Do not associate graphics device with any window.
                DeviceWindowHandle = IntPtr.Zero,
            };
            var graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, presentationParameters);

            // An IGraphicsDeviceService is required by the MonoGame/XNA content manager.
            _serviceContainer.Register(typeof(IGraphicsDeviceService), null, new DummyGraphicsDeviceManager(graphicsDevice));

            // Create and register the graphics manager.
            _graphicsManager = new GraphicsManager(graphicsDevice, _contentManager);
            _serviceContainer.Register(typeof(IGraphicsService), null, _graphicsManager);

            // ----- Timing
            // We can use the CompositionTarget.Rendering event to trigger our game loop.
            // The CompositionTarget.Rendering event is raised once per frame by WPF.

            // To measure the time that has passed, we use a HighPrecisionClock.
            _clock = new HighPrecisionClock();
            _clock.Start();
            CompositionTarget.Rendering += (s, e) => _clock.Update();

            // The FixedStepTimer reads the clock and triggers the game loop at 60 Hz.
            //_timer = new FixedStepTimer(_clock)
            //{
            //  StepSize = new TimeSpan(166667), // ~60 Hz
            //  AccumulateTimeSteps = false,
            //};
            // The VariableStepTimer reads the clock and triggers the game loop as often
            // as possible.
            _timer              = new VariableStepTimer(_clock);
            _timer.TimeChanged += (s, e) => GameLoop(e.DeltaTime);
            _timer.Start();
        }
示例#17
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        public MyGame()
        {
            Lock = new object();

            // ----- Service Container
            // MyGame uses a ServiceContainer, which is a simple service locator and
            // Inversion of Control (IoC) container. (The ServiceContainer can be
            // replaced by any other container that implements System.IServiceProvider.)
            _serviceContainer = new ServiceContainer();
            ServiceLocator.SetLocatorProvider(() => _serviceContainer);

            _serviceContainer.Register(typeof(MyGame), null, this);

            // ----- Storage
            // Create a "virtual file system" for reading game assets.
            _titleStorage       = new TitleStorage("Content");
            _assetsStorage      = new ZipStorage(_titleStorage, "Content.zip");
            _digitalRuneStorage = new ZipStorage(_titleStorage, "DigitalRune.zip");
            _vfsStorage         = new VfsStorage();
            _vfsStorage.MountInfos.Add(new VfsMountInfo(_assetsStorage, null));
            _vfsStorage.MountInfos.Add(new VfsMountInfo(_digitalRuneStorage, null));

            // ----- Content
            _contentManager = new StorageContentManager(ServiceLocator.Current, _vfsStorage);
            _serviceContainer.Register(typeof(ContentManager), null, _contentManager);

            // ----- Graphics
            // Create Direct3D 11 device.
            var presentationParameters = new PresentationParameters
            {
                BackBufferWidth  = 1,
                BackBufferHeight = 1,
                // Do not associate graphics device with any window.
                DeviceWindowHandle = IntPtr.Zero,
            };
            var graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, presentationParameters);

            // An IGraphicsDeviceService is required by the MonoGame/XNA content manager.
            _serviceContainer.Register(typeof(IGraphicsDeviceService), null, new DummyGraphicsDeviceManager(graphicsDevice));

            // Get DXGIOutput to call WaitForVerticalBlank() in the game loop.
            using (var dxgiFactory = new SharpDX.DXGI.Factory1())
                using (var dxgiAdapter = dxgiFactory.GetAdapter1(0))
                    _dxgiOutput = dxgiAdapter.GetOutput(0);

            // Create and register the graphics manager.
            _graphicsManager = new GraphicsManager(graphicsDevice, _contentManager);
            _serviceContainer.Register(typeof(IGraphicsService), null, _graphicsManager);

            // ----- Timing
            // The game loop runs in a parallel thread to keep the UI thread responsive.
            // To measure the time that has passed, we use a HighPrecisionClock.
            _clock = new HighPrecisionClock();
            _clock.Start();
            _gameLoopTask = ThreadPool.RunAsync(GameLoopTaskAction, WorkItemPriority.High, WorkItemOptions.TimeSliced)
                            .AsTask();

            // The FixedStepTimer reads the clock and triggers the game loop at 60 Hz.
            //_timer = new FixedStepTimer(_clock)
            //{
            //  StepSize = new TimeSpan(166667), // ~60 Hz
            //  AccumulateTimeSteps = false,
            //};

            // The VariableStepTimer reads the clock and triggers the game loop as often as possible.
            _timer = new VariableStepTimer(_clock);

            _timer.TimeChanged += (s, e) => GameLoop(e.DeltaTime);
            _timer.Start();

            CoreApplication.Suspending += OnCoreApplicationSuspending;

            // DirectX buffers only a limit amount of Present calls per frame which is controlled by
            // the MaximumFrameLatency property. The default value is usually 3. If the application
            // uses more SwapChainPresentationTargets we must increase this property.
            //var d3dDevice = (SharpDX.Direct3D11.Device)_graphicsManager.GraphicsDevice.Handle;
            //using (var dxgiDevice2 = d3dDevice.QueryInterface<SharpDX.DXGI.Device2>())
            //  dxgiDevice2.MaximumFrameLatency = numberOfSwapChainPanels;
        }
示例#18
0
        // Initializes services and adds game components.
        protected override void Initialize()
        {
#if WINDOWS || WINDOWS_UWP || XBOX
            if (GraphicsDevice.GraphicsProfile == GraphicsProfile.Reach)
            {
                throw new NotSupportedException(
                          "The DigitalRune Samples and Content for Windows, Universal Windows Apps and Xbox 360 are " +
                          "designed for the HiDef graphics profile. A graphics cards supporting DirectX 10.0 or better " +
                          "is required.");
            }
#endif

            // ----- Service Container
            // The DigitalRune ServiceContainer is an "inversion of control" container.
            // All game services (such as input, graphics, physics, etc.) are registered
            // in this container. Other game components can access these services via lookup
            // in the service container.
            // The DigitalRune ServiceContainer replaces the XNA GameServiceContainer (see
            // property Game.Services).

            // Note: The DigitalRune libraries do not require the use of the ServiceContainer
            // or any other IoC container. The ServiceContainer is only used in the sample
            // for convenience - but it is not mandatory.
            _services = new ServiceContainer();

            // The service container is either passed directly to the game components
            // or accessed through the global variable ServiceLocator.Current.
            // The following call makes the service container publicly available in
            // ServiceLocator.Current.
            ServiceLocator.SetLocatorProvider(() => _services);

            // ----- Storage
            // For XNA the assets are stored in the following folders:
            //
            //   <gameLocation>/
            //     Content/
            //       DigitalRune/
            //         ... DigitalRune assets ...
            //       ... other assets ...
            //
            // For MonoGame the assets (*.xnb files) are stored in ZIP packages. The
            // sample assets are stored in "Content/Content.zip" and the DigitalRune
            // assets are stored in "Content/DigitalRune.zip".
            //
            //   <gameLocation>/
            //     Content/
            //       Content.zip
            //       DigitalRune.zip
            //
            // DigitalRune introduces the concept of "storages". Storages can be used
            // to access files on disk or files stored in packages (e.g. ZIP archives).
            // These storages can be mapped into a "virtual file system", which makes
            // it easier to write portable code. (The game logic can read the files
            // from the virtual file system and does not need to know the specifics
            // about the platform.)
            //
            // The virtual files system should look like this:
            //
            //   /                                     <-- root of virtual file system
            //       DigitalRune/
            //           ... DigitalRune assets ...
            //       ... other assets ...

            // The VfsStorage creates a virtual file system.
            var vfsStorage = new VfsStorage();

            // The TitleStorage reads files from the game's default storage location.
            // --> Create a TitleStorage that reads files from "<gameLocation>/Content".
            var titleStorage = new TitleStorage("Content");

#if MONOGAME
            // A ZipStorage can be used to access files inside a ZIP archive.
            // --> Mount the sample assets to the root of the virtual file system.
            var assetsStorage = new ZipStorage(titleStorage, "Content.zip");
            vfsStorage.MountInfos.Add(new VfsMountInfo(assetsStorage, null));

#if !ANDROID && !IOS && !LINUX && !MACOS
            // --> Mount the DigitalRune assets to the root of the virtual file system.
            var drStorage = new ZipStorage(titleStorage, "DigitalRune.zip");
            vfsStorage.MountInfos.Add(new VfsMountInfo(drStorage, null));
#endif
#endif

            // Finally, map the TitleStorage to the root of the virtual file system.
            // (The TitleStorage is added as the last mount point. The ZIP archives
            // have priority.)
            vfsStorage.MountInfos.Add(new VfsMountInfo(titleStorage, null));

            // Register the virtual file system as a service.
            _services.Register(typeof(IStorage), null, vfsStorage);

            // ----- Content Managers
            // The GraphicsDeviceManager needs to be registered in the service container.
            // (This is required by the XNA content managers.)
            _services.Register(typeof(IGraphicsDeviceService), null, _graphicsDeviceManager);
            _services.Register(typeof(GraphicsDeviceManager), null, _graphicsDeviceManager);

            // Register a default, shared content manager.
            // The new StorageContentManager can be used to read assets from the virtual
            // file system. (Replaces the content manager stored in Game.Content.)
            Content = new StorageContentManager(_services, vfsStorage);
            _services.Register(typeof(ContentManager), null, Content);

            // Create and register content manager that will be used to load the GUI.
#if !MONOGAME
            var uiContentManager = new ContentManager(_services, "Content");
#else
            var uiContentManager = new StorageContentManager(_services, assetsStorage);
#endif
            _services.Register(typeof(ContentManager), "UIContent", uiContentManager);

            // Create content manager that will be used exclusively by the graphics service
            // to load the pre-built effects and resources of DigitalRune.Graphics. (We
            // could use Game.Content, but it is recommended to separate the content. This
            // allows to unload the content of the samples without unloading the other
            // content.)
            var graphicsContentManager = new StorageContentManager(_services, vfsStorage);

            // ----- Initialize Services
            // Register the game class.
            _services.Register(typeof(Microsoft.Xna.Framework.Game), null, this);
            _services.Register(typeof(SampleGame), null, this);

#if XBOX
            // On Xbox, we use the XNA gamer services (e.g. for text input).
            Components.Add(new GamerServicesComponent(this));
#endif

            // Input
#if XBOX
            const bool useGamerServices = true;
#else
            const bool useGamerServices = false;
#endif
            _inputManager = new InputManager(useGamerServices);
            _services.Register(typeof(IInputService), null, _inputManager);

            // Graphics
            _graphicsManager = new GraphicsManager(GraphicsDevice, Window, graphicsContentManager);
            _services.Register(typeof(IGraphicsService), null, _graphicsManager);

            // GUI
            _uiManager = new UIManager(this, _inputManager);
            _services.Register(typeof(IUIService), null, _uiManager);

            // Animation
            _animationManager = new AnimationManager();
            _services.Register(typeof(IAnimationService), null, _animationManager);

            // Particle simulation
            _particleSystemManager = new ParticleSystemManager();
            _services.Register(typeof(IParticleSystemService), null, _particleSystemManager);

            // Physics simulation
            ResetPhysicsSimulation();

            // Game logic
            _gameObjectManager = new GameObjectManager();
            _services.Register(typeof(IGameObjectService), null, _gameObjectManager);

            // Profiler
            _profiler = new HierarchicalProfiler("Main");
            _services.Register(typeof(HierarchicalProfiler), "Main", _profiler);

            // Initialize delegates for running tasks in parallel.
            // (Creating delegates allocates memory, therefore we do this only once and
            // cache the delegates.)
            _updateAnimation = () => _animationManager.Update(_deltaTime);
            _updatePhysics   = () => _simulation.Update(_deltaTime);
            _updateParticles = () => _particleSystemManager.Update(_deltaTime);

            // SampleFramework
            // The SampleFramework automatically discovers all samples using reflection, provides
            // controls for switching samples and starts the initial sample.
#if KINECT
            var initialSample = typeof(Kinect.KinectSkeletonMappingSample);
#elif WINDOWS || WINDOWS_UWP
            var initialSample = typeof(Graphics.DeferredLightingSample);
#else
            var initialSample = typeof(Graphics.BasicEffectSample);
#endif
            _sampleFramework = new SampleFramework(this, initialSample);
            _services.Register(typeof(SampleFramework), null, _sampleFramework);

            base.Initialize();
        }