public GameRepository(IAzureBlobContainer<Game> gameContainer, IAzureBlobContainer<GameQueue> gameQueueContainer, IAzureBlobContainer<UserProfile> userContainer, IAzureQueue<InviteMessage> inviteQueue)
        {
            if (gameContainer == null)
            {
                throw new ArgumentNullException("gameContainer");
            }

            if (gameQueueContainer == null)
            {
                throw new ArgumentNullException("gameQueueContainer");
            }

            if (userContainer == null)
            {
                throw new ArgumentNullException("userContainer");
            }

            if (inviteQueue == null)
            {
                throw new ArgumentNullException("inviteQueue");
            }

            this.gameContainer = gameContainer;
            this.gameQueueContainer = gameQueueContainer;
            this.userContainer = userContainer;
            this.inviteQueue = inviteQueue;
        }
        public void AddOrUpdateUserSessionTest()
        {
            var users    = new AzureBlobContainer <UserProfile>(CloudStorageAccount.DevelopmentStorageAccount);
            var sessions = new AzureBlobContainer <UserSession>(CloudStorageAccount.DevelopmentStorageAccount);
            var friends  = new AzureBlobContainer <Friends>(CloudStorageAccount.DevelopmentStorageAccount);
            var target   = new UserRepository(users, sessions, friends);
            IAzureBlobContainer <UserSession> userSessionContainer = (IAzureBlobContainer <UserSession>)
                                                                     target.GetType().GetField("userSessionContainer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(target);

            UserSession userSessionFirstVersion = new UserSession()
            {
                UserId = "johnny", ActiveGameQueueId = Guid.NewGuid()
            };

            target.AddOrUpdateUserSession(userSessionFirstVersion);
            var result = userSessionContainer.Get(userSessionFirstVersion.UserId);

            Assert.AreEqual(userSessionFirstVersion, result);

            UserSession userSessionSecondVersion = new UserSession()
            {
                UserId = userSessionFirstVersion.UserId, ActiveGameQueueId = Guid.NewGuid()
            };

            target.AddOrUpdateUserSession(userSessionSecondVersion);
            result = userSessionContainer.Get(userSessionFirstVersion.UserId);
            Assert.AreEqual(userSessionSecondVersion, result);
            Assert.AreNotEqual(userSessionFirstVersion, result);
        }
        public GameRepository(IAzureBlobContainer <Game> gameContainer, IAzureBlobContainer <GameQueue> gameQueueContainer, IAzureBlobContainer <UserProfile> userContainer, IAzureQueue <InviteMessage> inviteQueue)
        {
            if (gameContainer == null)
            {
                throw new ArgumentNullException("gameContainer");
            }

            if (gameQueueContainer == null)
            {
                throw new ArgumentNullException("gameQueueContainer");
            }

            if (userContainer == null)
            {
                throw new ArgumentNullException("userContainer");
            }

            if (inviteQueue == null)
            {
                throw new ArgumentNullException("inviteQueue");
            }

            this.gameContainer      = gameContainer;
            this.gameQueueContainer = gameQueueContainer;
            this.userContainer      = userContainer;
            this.inviteQueue        = inviteQueue;
        }
 public TenantStore(IAzureBlobContainer <Tenant> tenantBlobContainer,
                    IAzureBlobContainer <byte[]> logosBlobContainer,
                    IInitializationStatusService initializationStatusService)
 {
     this.tenantBlobContainer = tenantBlobContainer;
     this.logosBlobContainer  = logosBlobContainer;
     this.CacheEnabled        = initializationStatusService.IsInitialized;
 }
Example #5
0
        public NotificationRepository(IAzureBlobContainer <NotificationStatus> notificationsContainer)
        {
            if (notificationsContainer == null)
            {
                throw new ArgumentNullException("notificationsContainer");
            }

            this.notificationsContainer = notificationsContainer;
        }
        public NotificationRepository(IAzureBlobContainer<NotificationStatus> notificationsContainer)
        {
            if (notificationsContainer == null)
            {
                throw new ArgumentNullException("notificationsContainer");
            }

            this.notificationsContainer = notificationsContainer;          
        }
 public SurveyAnswerStore(
     ITenantStore tenantStore, 
     ISurveyAnswerContainerFactory surveyAnswerContainerFactory,
     IAzureQueue<SurveyAnswerStoredMessage> standardSurveyAnswerStoredQueue, 
     IAzureQueue<SurveyAnswerStoredMessage> premiumSurveyAnswerStoredQueue, 
     IAzureBlobContainer<List<string>> surveyAnswerIdsListContainer)
 {
     this.tenantStore = tenantStore;
     this.surveyAnswerContainerFactory = surveyAnswerContainerFactory;
     this.standardSurveyAnswerStoredQueue = standardSurveyAnswerStoredQueue;
     this.premiumSurveyAnswerStoredQueue = premiumSurveyAnswerStoredQueue;
     this.surveyAnswerIdsListContainer = surveyAnswerIdsListContainer;
 }
 public SurveyAnswerStore(
     ITenantStore tenantStore,
     ISurveyAnswerContainerFactory surveyAnswerContainerFactory,
     IAzureQueue <SurveyAnswerStoredMessage> standardSurveyAnswerStoredQueue,
     IAzureQueue <SurveyAnswerStoredMessage> premiumSurveyAnswerStoredQueue,
     IAzureBlobContainer <List <string> > surveyAnswerIdsListContainer)
 {
     this.tenantStore = tenantStore;
     this.surveyAnswerContainerFactory    = surveyAnswerContainerFactory;
     this.standardSurveyAnswerStoredQueue = standardSurveyAnswerStoredQueue;
     this.premiumSurveyAnswerStoredQueue  = premiumSurveyAnswerStoredQueue;
     this.surveyAnswerIdsListContainer    = surveyAnswerIdsListContainer;
 }
        private UserRepository CreateUserRepository()
        {
            var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

            this.userContainer        = new AzureBlobContainer <UserProfile>(account, ConfigurationConstants.UsersContainerName + "test" + this.suffix, true);
            this.userSessionContainer = new AzureBlobContainer <UserSession>(account, ConfigurationConstants.UserSessionsContainerName + "test" + this.suffix, true);
            this.friendContainer      = new AzureBlobContainer <Friends>(account, ConfigurationConstants.FriendsContainerName + "test" + this.suffix, true);

            this.userContainer.EnsureExist();
            this.userSessionContainer.EnsureExist(true);
            this.friendContainer.EnsureExist(true);

            return(new UserRepository(this.userContainer, this.userSessionContainer, this.friendContainer));
        }
Example #10
0
        public Guid CreateBlob(Blob blob)
        {
            if (blob.BlobId == Guid.Empty)
            {
                blob.BlobId = Guid.NewGuid();
            }

            IAzureBlobContainer <byte[]> container = GetBlobContainer(this.storageAccount, this.containerName);

            this.context.Blobs.AddObject(blob);
            this.context.SaveChanges();

            return(blob.BlobId);
        }
Example #11
0
        public Guid UploadBlob(Blob blob, Stream stream)
        {
            if (blob.BlobId == Guid.Empty)
            {
                blob.BlobId = Guid.NewGuid();
            }

            IAzureBlobContainer <byte[]> container = GetBlobContainer(this.storageAccount, this.containerName);

            container.SaveStream(this.GetBlobId(blob), stream, null);
            this.context.Blobs.AddObject(blob);
            this.context.SaveChanges();

            return(blob.BlobId);
        }
Example #12
0
        public Guid UploadBlob(Blob blob, string filePath)
        {
            if (blob.BlobId == Guid.Empty)
            {
                blob.BlobId = Guid.NewGuid();
            }

            IAzureBlobContainer <byte[]> container = GetBlobContainer(this.storageAccount, this.containerName);
            var contentType = this.GetContentType(blob);

            container.SaveFile(this.GetBlobId(blob), filePath, contentType);
            this.context.Blobs.AddObject(blob);
            this.context.SaveChanges();

            return(blob.BlobId);
        }
        private GameRepository CreateGameRepository()
        {
            CloudStorageAccount account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

            this.gameContainer            = new AzureBlobContainer <Game>(account, ConfigurationConstants.GamesContainerName + "test" + this.suffix, true);
            this.gameQueueContainer       = new AzureBlobContainer <GameQueue>(account, ConfigurationConstants.GamesQueuesContainerName + "test" + this.suffix, true);
            this.skirmishGameMessageQueue = new AzureQueue <SkirmishGameQueueMessage>(account, ConfigurationConstants.SkirmishGameQueue + this.suffix);
            this.leaveGameMessageQueue    = new AzureQueue <LeaveGameMessage>(account, ConfigurationConstants.LeaveGameQueue + "test" + this.suffix);
            this.inviteMessageQueue       = new AzureQueue <InviteMessage>(account, ConfigurationConstants.InvitesQueue + "test" + this.suffix);

            this.gameContainer.EnsureExist(true);
            this.gameQueueContainer.EnsureExist(true);

            var repo = new GameRepository(this.gameContainer, this.gameQueueContainer, this.skirmishGameMessageQueue, this.leaveGameMessageQueue, this.userContainer, this.inviteMessageQueue);

            repo.Initialize();

            return(repo);
        }
Example #14
0
        public UserRepository(IAzureBlobContainer <UserProfile> userContainer, IAzureBlobContainer <UserSession> userSessionContainer, IAzureBlobContainer <Friends> friendsContainer)
        {
            if (userContainer == null)
            {
                throw new ArgumentNullException("userContainer");
            }

            if (userSessionContainer == null)
            {
                throw new ArgumentNullException("userSessionContainer");
            }

            if (friendsContainer == null)
            {
                throw new ArgumentNullException("friendsContainer");
            }

            this.userContainer        = userContainer;
            this.userSessionContainer = userSessionContainer;
            this.friendsContainer     = friendsContainer;
        }
        public UserRepository(IAzureBlobContainer<UserProfile> userContainer, IAzureBlobContainer<UserSession> userSessionContainer, IAzureBlobContainer<Friends> friendsContainer)
        {
            if (userContainer == null)
            {
                throw new ArgumentNullException("userContainer");
            }

            if (userSessionContainer == null)
            {
                throw new ArgumentNullException("userSessionContainer");
            }

            if (friendsContainer == null)
            {
                throw new ArgumentNullException("friendsContainer");
            }

            this.userContainer = userContainer;
            this.userSessionContainer = userSessionContainer;
            this.friendsContainer = friendsContainer;
        }
 public SurveyAnswersSummaryStore(IAzureBlobContainer<SurveyAnswersSummary> surveyAnswersSummaryBlobContainer)
 {
     this.surveyAnswersSummaryBlobContainer = surveyAnswersSummaryBlobContainer;
 }
 public TenantStore(IAzureBlobContainer<Tenant> tenantBlobContainer, IAzureBlobContainer<byte[]> logosBlobContainer)
 {
     this.tenantBlobContainer = tenantBlobContainer;
     this.logosBlobContainer = logosBlobContainer;
     this.CacheEnabled = false;
 }
        private UserRepository CreateUserRepository()
        {
            var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
            this.userContainer = new AzureBlobContainer<UserProfile>(account, ConfigurationConstants.UsersContainerName + "test" + this.suffix, true);
            this.userSessionContainer = new AzureBlobContainer<UserSession>(account, ConfigurationConstants.UserSessionsContainerName + "test" + this.suffix, true);
            this.friendContainer = new AzureBlobContainer<Friends>(account, ConfigurationConstants.FriendsContainerName + "test" + this.suffix, true);

            this.userContainer.EnsureExist();
            this.userSessionContainer.EnsureExist(true);
            this.friendContainer.EnsureExist(true);

            return new UserRepository(this.userContainer, this.userSessionContainer, this.friendContainer);
        }
 public LogsSnapshotRepository(IAzureBlobContainer azureBlobContainer)
 {
     _azureBlobContainer = azureBlobContainer;
 }
Example #20
0
        public CloudBlob GetBlob(Blob blob)
        {
            IAzureBlobContainer <byte[]> container = GetBlobContainer(this.storageAccount, this.containerName);

            return(container.GetBlob(this.GetBlobId(blob)));
        }
 public SurveyAnswersSummaryStore(IAzureBlobContainer <SurveyAnswersSummary> surveyAnswersSummaryBlobContainer)
 {
     this.surveyAnswersSummaryBlobContainer = surveyAnswersSummaryBlobContainer;
 }
Example #22
0
 public AzureBlob(IConfiguration configuration, IAzureBlobContainer azureBlobContainer, ILogger <AzureBlob> logger)
 {
     _configuration      = configuration;
     _azureBlobContainer = azureBlobContainer;
     _logger             = logger;
 }
        private GameRepository CreateGameRepository()
        {
            CloudStorageAccount account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
            this.gameContainer = new AzureBlobContainer<Game>(account, ConfigurationConstants.GamesContainerName + "test" + this.suffix, true);
            this.gameQueueContainer = new AzureBlobContainer<GameQueue>(account, ConfigurationConstants.GamesQueuesContainerName + "test" + this.suffix, true);
            this.skirmishGameMessageQueue = new AzureQueue<SkirmishGameQueueMessage>(account, ConfigurationConstants.SkirmishGameQueue + this.suffix);
            this.leaveGameMessageQueue = new AzureQueue<LeaveGameMessage>(account, ConfigurationConstants.LeaveGameQueue + "test" + this.suffix);
            this.inviteMessageQueue = new AzureQueue<InviteMessage>(account, ConfigurationConstants.InvitesQueue + "test" + this.suffix);

            this.gameContainer.EnsureExist(true);
            this.gameQueueContainer.EnsureExist(true);

            var repo = new GameRepository(this.gameContainer, this.gameQueueContainer, this.skirmishGameMessageQueue, this.leaveGameMessageQueue, this.userContainer, this.inviteMessageQueue);
            repo.Initialize();

            return repo;
        }
Example #24
0
 public TenantStore(IAzureBlobContainer<Tenant> tenantBlobContainer, IAzureBlobContainer<byte[]> logosBlobContainer)
 {
     this.tenantBlobContainer = tenantBlobContainer;
     this.logosBlobContainer = logosBlobContainer;
     this.CacheEnabled = false;
 }