public async Task <long> CreateRepository(GitHubRepository repository)
      {
          var gitHubClient = this.GitHubClientProvider.GetGitHubClient();

          var autoInit = repository.InitializeWithReadMe;

          string licenseTemplate;

          switch (repository.License)
          {
          case GitHubRepositoryLicense.MIT:
              licenseTemplate = LicenseHelper.MitLicenseIdentifier;
              break;

          default:
              throw new Exception(EnumerationHelper.UnexpectedEnumerationValueMessage(repository.License));
          }

          var @private = repository.Visibility == GitHubRepositoryVisibility.Private ? true : false;   // Private if private, otherwise public.

          var newRepository = new NewRepository(repository.Name)
          {
              AutoInit        = true, // Create with README for immediate checkout.
              Description     = repository.Description,
              LicenseTemplate = licenseTemplate,
              Private         = @private, // Default is public (private = false).
          };

          var createdRepository = await gitHubClient.Repository.Create(newRepository);

          return(createdRepository.Id);
      }
Exemplo n.º 2
0
        public static string GetFileExtensionNoUnknown(FileFormat fileFormat)
        {
            switch (fileFormat)
            {
            case FileFormat.Bitmap:
                return(FileExtensions.Bitmap);

            case FileFormat.Jpg:
                return(FileExtensions.Jpg);

            case FileFormat.Png:
                return(FileExtensions.Png);

            default:
                var message = EnumerationHelper.UnexpectedEnumerationValueMessage <FileFormat>(fileFormat);
                throw new Exception(message);
            }
        }
        public static ConnectionString GetConnectionString(this DatabaseConfiguration databaseConfiguration, DatabaseServerAuthentications databaseServerAuthentications)
        {
            ConnectionString connectionString;

            switch (databaseConfiguration.LocalOrRemote)
            {
            case LocalOrRemote.Local:
                connectionString = databaseConfiguration.GetLocalConnectionString();
                break;

            case LocalOrRemote.Remote:
                connectionString = databaseConfiguration.GetRemoteConnectionString(databaseServerAuthentications);
                break;

            default:
                throw new Exception(EnumerationHelper.UnexpectedEnumerationValueMessage(databaseConfiguration.LocalOrRemote));
            }

            return(connectionString);
        }