Exemplo n.º 1
0
        public UnitOfWork(string endpointUrl, string dbName, string documentCollectionName, string primaryKey)
        {
            DocumentClient client = new DocumentClient(new Uri(endpointUrl), primaryKey);

            client.CreateDatabaseIfNotExistsAsync(new Database {
                Id = dbName
            });
            client.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri(dbName), new DocumentCollection {
                Id = documentCollectionName
            });

            BlogRepository = new BlogRepository(client, UriFactory.CreateDocumentCollectionUri(dbName, documentCollectionName));
            var db = client.CreateDatabaseIfNotExistsAsync(new Database {
                Id = dbName
            });
            var collection = client.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri(dbName), new DocumentCollection {
                Id = documentCollectionName
            });
        }
Exemplo n.º 2
0
        public T initRepo <T>(T repo)
        {
            if (repo == null)
            {
                object newInstance;
                Type   t = typeof(T);
                switch (t.Name)
                {
                case "IAccountRepository": newInstance = new AccountRepository(RWrapr, _repoContext); break;

                case "IArticleRepository": newInstance = new ArticleRepository(RWrapr, _repoContext); break;

                case "ICredentialRepository": newInstance = new CredentialRepository(RWrapr, _repoContext); break;

                case "IBlogRepository": newInstance = new BlogRepository(RWrapr, _repoContext); break;

                case "ICommentRepository": newInstance = new CommentRepository(RWrapr, _repoContext); break;

                case "IConnexionRepository": newInstance = new ConnexionRepository(RWrapr, _repoContext); break;

                case "IReactRepository": newInstance = new ReactRepository(RWrapr, _repoContext); break;

                case "IShareRepository": newInstance = new ShareRepository(RWrapr, _repoContext); break;

                case "IFollowRepository": newInstance = new FollowRepository(RWrapr, _repoContext); break;

                case "IMessageRepository": newInstance = new MessageRepository(RWrapr, _repoContext); break;

                case "INotificationRepository": newInstance = new NotificationRepository(RWrapr, _repoContext); break;

                default: throw new RopositoryWrapperUnlistedException(typeof(T));
                }
                return((T)newInstance);
            }

            return(repo);
        }