public void CreateProviderTest() { string providerName = "YahooProvider"; IProvider expected = new YahooProvider(); IProvider actual; actual = _providerFactory.Create(providerName); Assert.AreEqual(expected.ToString(), actual.ToString()); Assert.IsInstanceOfType(actual, typeof(YahooProvider)); Assert.AreNotSame(expected, actual); }
/// <summary> /// Creates the provider by using the factory (if present) or directly instantiating by type name /// </summary> /// <returns></returns> public T CreateInstance() { //check if we have a factory if (this.factoryInstance == null) { var type = this.Factory; if (type != null) { this.factoryInstance = (IProviderFactory <T>)FastActivator.Create(type); this.factoryInstance.Initialize(this.parameters); } } // no factory, use the provider type if (this.factoryInstance == null) { var type = this.Type; if (type == null) { return(null); } return((T)FastActivator.Create(type)); } return(factoryInstance.Create()); }
private int CreateProvider(TProviderResource providerResource) { var provider = GetDefinition(providerResource); provider = _providerFactory.Create(provider); return(provider.Id); }
public JsonResult Index(InputInfo info) { if (info.Provider == null || info.Company == null) { return(null); } IEnumerable <Quote> quotes = new List <Quote>(); try { var data = _providerFactory.Create(info.Provider).GetData(info.DateFrom, info.DateTo, info.Company); quotes = _converterFactory.Create(info.Provider).Convert(data); } catch (NullReferenceException exception) { Debug.WriteLine("{1} - {0}", exception.Message, exception.Data); } //var quotes = new List<Quote> { // new Quote { Date = DateTime.Parse("11.06.2012"), Close = 29.09, High = 12.12, Low = 121.12, Open = 35.1, Volume = 1412412 }, // new Quote { Date = DateTime.Parse("10.06.2012"), Close = 29.09, High = 12.12, Low = 121.12, Open = 35.1, Volume = 1412412 }, // new Quote { Date = DateTime.Parse("09.06.2012"), Close = 29.09, High = 12.12, Low = 121.12, Open = 35.1, Volume = 1412412 }, //}; return(Json(quotes.Select(elem => new { Date = elem.Date.ToString("MMM dd, yyyy"), elem.Close, elem.High, elem.Low, elem.Open, elem.Volume }))); }
private int CreateProvider(TProviderResource indexerResource) { var indexer = GetDefinition(indexerResource); indexer = _providerFactory.Create(indexer); return(indexer.Id); }
public Widget Create() { var provider = _factory.Create <IDataProvider>(); provider.AddInput("name", "name"); provider.AddInput("path", "path"); provider.AddInput("dateCreated", DateTime.UtcNow); //..... }
private int CreateProvider(TProviderResource providerResource) { var providerDefinition = GetDefinition(providerResource, false); Test(providerDefinition, false); providerDefinition = _providerFactory.Create(providerDefinition); return(providerDefinition.Id); }
public ActionResult <TProviderResource> CreateProvider(TProviderResource providerResource) { var providerDefinition = GetDefinition(providerResource, true, false, false); if (providerDefinition.Enable) { Test(providerDefinition, false); } providerDefinition = _providerFactory.Create(providerDefinition); return(Created(providerDefinition.Id)); }
private int CreateProvider(TProviderResource providerResource) { var providerDefinition = GetDefinition(providerResource); if (providerDefinition.Enable) { Test(providerDefinition); } providerDefinition = _providerFactory.Create(providerDefinition); return(providerDefinition.Id); }
private void OnMatchmakingFoundMatchup(object sender, Matchmaking.MatchCreatedArgs matchCreatedArgs) { lock (_runningGames) { _gameIdentifier++; var game = new ServerGame(this, _supervisorFactory.Create(matchCreatedArgs.GameMode), matchCreatedArgs.Users, _settingsFactory.Create(matchCreatedArgs.GameMode), _gameIdentifier, _logger); foreach (var serverUser in matchCreatedArgs.Users) { matchCreatedArgs.Source.LeaveQueue(serverUser); game.HandleReconnect(serverUser); } _runningGames.TryAdd(_gameIdentifier, game); } }
/// <inheritdoc /> public void Start() { if (_disposed) { throw new ObjectDisposedException(nameof(DefaultGameServer)); } if (_running) { throw new InvalidOperationException("The server is already running."); } _running = true; _logger.LogInformation("Starting game server ..."); _cancellation = new CancellationTokenSource(); _server = new EvadersServer(_serverSupervisorFactory.Create(_settings.SupervisorProviderId), _matchmakingFactory.Create(_settings.MatchmakingProviderId), _loggerFactory.CreateLogger <EvadersServer>(), _serverConfigurationFactory.Create(_settings.ServerConfigurationProviderId)); _gameServerLoop = new Task(GameLoop, _cancellation.Token, _cancellation.Token, TaskCreationOptions.LongRunning); _gameServerLoop.Start(); }
public EvadersServer([NotNull] IProviderFactory <IServerSupervisor> supervisorFactoryFactory, [NotNull] IProviderFactory <GameSettings> settingsFactory, [NotNull] IProviderFactory <IMatchmaking> matchmakingFactory, [NotNull] ILogger logger, [NotNull] ServerSettings config) { if (supervisorFactoryFactory == null) { throw new ArgumentNullException(nameof(supervisorFactoryFactory)); } if (settingsFactory == null) { throw new ArgumentNullException(nameof(settingsFactory)); } if (matchmakingFactory == null) { throw new ArgumentNullException(nameof(matchmakingFactory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } if (!config.IsValid) { throw new ArgumentException("Invalid config", nameof(config)); } _supervisorFactory = supervisorFactoryFactory; _settingsFactory = settingsFactory; _logger = logger; _matchmaking = new ConcurrentDictionary <string, IMatchmaking>(config.GameModes.ToDictionary(item => item, matchmakingFactory.Create)); foreach (var keyValuePair in _matchmaking) { keyValuePair.Value.Supervisor = _supervisorFactory.Create(keyValuePair.Key); keyValuePair.Value.OnSuggested += OnMatchmakingFoundMatchup; } _config = config; }
/// <summary> /// Creates the provider by using the factory (if present) or directly instantiating by type name /// </summary> /// <returns></returns> public T CreateInstance() { //check if we have a factory if (this.factoryInstance == null) { var type = this.Factory; if (type != null) { try { var instance = (IProviderFactory <T>)FastActivator.Create(type); instance.Initialize(this.parameters); this.factoryInstance = instance; } catch (Exception e) { throw new InvalidOperationException(String.Format("Could not initialize the provider factory {0}. Check the InnerException for details.", type), e); } } } // no factory, use the provider type if (this.factoryInstance == null) { var type = this.Type; if (type == null) { return(null); } return((T)FastActivator.Create(type)); } return(factoryInstance.Create()); }