Exemple #1
0
        private GameHostBuilderContext GetGameHostBuilderContext(HostBuilderContext context)
        {
            if (!context.Properties.TryGetValue(typeof(GameHostBuilderContext), out var contextVal))
            {
                var gameHostBuilderContext = new GameHostBuilderContext
                {
                    Configuration      = context.Configuration,
                    HostingEnvironment = new HostingEnvironment(),
                };

                // gameHostBuilderContext.HostingEnvironment.Initialize(context.HostingEnvironment.ContentRootPath, null);
                context.Properties[typeof(GameHostBuilderContext)] = gameHostBuilderContext;
                return(gameHostBuilderContext);
            }

            var gamehostBuilderContext = (GameHostBuilderContext)contextVal;

            gamehostBuilderContext.Configuration = context.Configuration;
            return(gamehostBuilderContext);
        }
        GameHostBuilderContext GetGameHostBuilderContext(HostBuilderContext context)
        {
            if (!context.Properties.TryGetValue(typeof(GameHostBuilderContext), out var contextVal))
            {
                var options = new GameHostOptions(context.Configuration, Assembly.GetEntryAssembly()?.GetName().Name);
                var gameHostBuilderContext = new GameHostBuilderContext
                {
                    Configuration      = context.Configuration,
                    HostingEnvironment = new HostingEnvironment(),
                };
                gameHostBuilderContext.HostingEnvironment.Initialize(context.HostingEnvironment.ContentRootPath, options);
                context.Properties[typeof(GameHostBuilderContext)] = gameHostBuilderContext;
                context.Properties[typeof(GameHostOptions)]        = options;
                return(gameHostBuilderContext);
            }

            // Refresh config, it's periodically updated/replaced
            var gameHostContext = (GameHostBuilderContext)contextVal;

            gameHostContext.Configuration = context.Configuration;
            return(gameHostContext);
        }
 public HostServiceProvider(GameHostBuilderContext context) =>