Exemple #1
0
        public LinkedSyncableBuckets(IDataCreator <SyncableBucket> bucketcreator, IReadOnlyCollection <SyncableBucket> buckets)
        {
            if (buckets.Any() && buckets.Count(bucket => bucket.NextBiggerBucket == null) != 1)
            {
                throw new InvalidOperationException("There must be one and only one bucket with no NextBiggerBucket set");
            }

            foreach (var bucket in buckets)
            {
                int numberOfSmallerBuckets = buckets.Count(b => b.NextBiggerBucket == bucket);
                if (numberOfSmallerBuckets > 1)
                {
                    throw new InvalidOperationException("The bucket hierarchy must be linear: no single bucket can be the NextBiggerBucket for more than a single other bucket");
                }

                if (numberOfSmallerBuckets == 0)
                {
                    if (_smallestBucket != null)
                    {
                        throw new InvalidOperationException("There cannot be more than one smallest bucket!");
                    }

                    _smallestBucket = bucket;
                }

                if (bucket.NextBiggerBucket != null && !buckets.Contains(bucket.NextBiggerBucket))
                {
                    throw new InvalidOperationException("All NextBiggerBucket must be contained in the collection");
                }
            }

            _bucketcreator = bucketcreator;
            _buckets       = new HashSet <SyncableBucket>(buckets);
        }
Exemple #2
0
 public DataService(IConfigurationReader configurationReader,
                    IDataCreator dataCreator,
                    IDataRetriever dataRetriever)
 {
     _configurationReader = configurationReader;
     _dataCreator         = dataCreator;
     _dataRetriever       = dataRetriever;
 }
Exemple #3
0
        public DataSet RetrieveData(IDataCreator creator, string connectionString, string databaseType, string sql, int commandTimeout)
        {
            var type = databaseType.ToDatabaseType();

            using (var con = creator.CreateConnection(connectionString, type))
                using (var cmd = creator.CreateCommand(con, type, sql))
                    using (var da = creator.CreateAdapter(cmd, type))
                    {
                        cmd.CommandTimeout = commandTimeout;

                        var ds = new DataSet();

                        da.Fill(ds);

                        return(ds);
                    }
        }
Exemple #4
0
 public Engine(IRender renderer, IInterface userInterface, IGameInitializationStrategy gameInitializationStrategy, IGridViewFactory gridFactory, IHelpers helper,
               IPlayerFactory playerFactory, IDataCreator dataCreator, IDataLoader dataLoader, IContext context)
 {
     this.renderer      = renderer;                                //Grid builder
     this.userInterface = userInterface;                           // user interface.
     this.gameInitializationStrategy = gameInitializationStrategy; //Types of ships
     this.ships         = new List <IShip>();
     this.gridFactory   = gridFactory;
     this.visibleGrid   = gridFactory.CreateNewGrid();
     this.hiddenGrid    = gridFactory.CreateNewGrid();
     this.totalAttempts = 0; //
     this.helper        = helper;
     this.playerFactory = playerFactory;
     this.dataCreator   = dataCreator;
     this.dataLoader    = dataLoader;
     this.playerData    = dataLoader.LoadData(playerFactory);
     this.context       = context;
     this.gameStatus    = GameStatus.Play;
 }
 /// <summary><see cref="UriStringToXmlConverter"/>
 /// Get instance of
 /// </summary>
 /// <param name="dataReceiver">Data receiver</param>
 /// <param name="dataCreator">Data creator</param>
 public UriStringToXmlConverter(IDataReceiver <string> dataReceiver, IDataCreator <string, XElement> dataCreator)
 {
     this._dataReceiver = dataReceiver ?? throw new ArgumentNullException(nameof(dataReceiver));
     this._dataCreator  = dataCreator ?? throw new ArgumentNullException(nameof(dataCreator));
 }