Esempio n. 1
0
        public async Task <IEnumerable <GitCommitRef> > GetLastCommitsAsync(
            Guid serviceId,
            Guid repositoryId,
            string branch,
            int top = 10,
            CancellationToken cancellationToken = default)
        {
            AzureDevOpsConnectedService service = await ClientFactory.ConnectAsync(
                serviceId,
                cancellationToken);

            GitHttpClient client = ClientFactory.CreateClient <GitHttpClient>(serviceId);

            return(await client.GetCommitsAsync(
                       service.DefaultProject,
                       repositoryId,
                       new GitQueryCommitsCriteria()
            {
                ItemVersion = new GitVersionDescriptor()
                {
                    VersionType = GitVersionType.Branch,
                    VersionOptions = GitVersionOptions.None,
                    Version = branch
                },
                IncludeLinks = true
            },
                       top : top,
                       cancellationToken : cancellationToken)
                   .ConfigureAwait(false));
        }
Esempio n. 2
0
        public async Task <GitRepository> GetByIdAsync(
            Guid serviceId,
            Guid id,
            CancellationToken cancellationToken)
        {
            await ClientFactory.ConnectAsync(
                serviceId,
                cancellationToken);

            GitHttpClient client = ClientFactory.CreateClient <GitHttpClient>(serviceId);

            return(await client.GetRepositoryAsync(
                       repositoryId : id,
                       cancellationToken));
        }
Esempio n. 3
0
        public async Task <IEnumerable <GitRepository> > GetAllAsync(
            Guid serviceId,
            CancellationToken cancellationToken)
        {
            AzureDevOpsConnectedService service = await ClientFactory.ConnectAsync(
                serviceId,
                cancellationToken);

            GitHttpClient client = ClientFactory
                                   .CreateClient <GitHttpClient>(serviceId);

            return(await client.GetRepositoriesAsync(
                       service.DefaultProject,
                       cancellationToken : cancellationToken));
        }
Esempio n. 4
0
        static async Task Main(string[] args)
        {
            string host = "127.0.0.1";
            int    port = 8080;


            Server server = new Server();

            server.Register <IArith>(new Arith());
            _ = Task.Run(async() =>
            {
                try
                {
                    await server.ServeAsync(host, port);
                }
                catch (Exception e)
                {
                    Console.WriteLine("RPC Server exit with exception {0}", e.ToString());
                }
            });

            ClientFactory clientFactory = new ClientFactory();

            clientFactory.Register(typeof(IArith));
            clientFactory.Finish();
            Client client = await clientFactory.ConnectAsync(host, port);

            IArith service = client.Get <IArith>();

            Args arg = new Args
            {
                A = 9,
                B = 9,
            };
            int result = await service.Multiply(arg);

            Console.WriteLine($"{arg.A} * {arg.B} = {result}");

            int result2 = await service.Add(arg);

            Console.WriteLine($"{arg.A} + {arg.B} = {result2}");
            await client.StopAsync();
        }
Esempio n. 5
0
        public async Task <GitRemoteRepository?> GetByRemoteReference(
            Guid serviceId,
            IGitRemoteReference reference,
            string name,
            CancellationToken cancellationToken)
        {
            if (reference is AzureDevOpsGitRemoteReference adoRef)
            {
                AzureDevOpsConnectedService service = await ClientFactory.ConnectAsync(
                    serviceId,
                    cancellationToken);

                GitHttpClient client = ClientFactory.CreateClient <GitHttpClient>(serviceId);

                GitRepository?repo = await client.GetRepositoryAsync(
                    adoRef.Project,
                    name,
                    cancellationToken : cancellationToken);

                if (repo is { })
Esempio n. 6
0
        public async Task <IEnumerable <BuildDefinition> > GetPipelinesByRepositoryAsync(
            Guid serviceId,
            Guid repositoryId,
            CancellationToken cancellationToken)
        {
            AzureDevOpsConnectedService service = await ClientFactory.ConnectAsync(
                serviceId,
                cancellationToken);

            BuildHttpClient client = ClientFactory.CreateClient <BuildHttpClient>(serviceId);

            IPagedList <BuildDefinition> pipelines = await client
                                                     .GetFullDefinitionsAsync2(
                project : service.DefaultProject,
                repositoryType : "TfsGit",
                repositoryId : repositoryId.ToString(),
                cancellationToken : cancellationToken);

            return(pipelines.ToList());
        }