Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json.net dependency and refit dependency #24

Closed
luisrudge opened this issue Apr 7, 2014 · 2 comments
Closed

json.net dependency and refit dependency #24

luisrudge opened this issue Apr 7, 2014 · 2 comments
Labels

Comments

@luisrudge
Copy link

This is my 'Client' project

public interface IClientApi {
    [Get("/")]
    Task<string> Home();

    [Get("/{id}")]
    Task<string> GetById(int id);
}

public class ClientApi : IClientApi {
    private IClientApi _client;

    public ClientApi() {
        var c = new HttpClient {BaseAddress = new Uri("http://localhost:7820")};
        _client = RestService.For<IClientApi>(c);
    }

    public async Task<string> Home() {
        return await _client.Home();
    }

    public async Task<string> GetById(int id) {
        return await _client.GetById(id);
    }
}

This is my 'Consumer' project:

private static void Main(string[] args) {
    var client = new ClientApi();
    Console.WriteLine(client.Home().Result);
    Console.WriteLine(client.GetById(1).Result);
}

Why i have to install json.net and refit in my consumer project? And why isn't json.net a dependency of refit nuget package?

@anaisbetts
Copy link
Member

Why i have to install json.net and refit in my consumer project?

You have to do this in C# for any library, it doesn't do static linking. The easy way is to make your Client lib a NuGet package and have it depend on Refit.

And why isn't json.net a dependency of refit nuget package?

That's a bug, fixed!

@luisrudge
Copy link
Author

Thanks!

@lock lock bot added the outdated label Jun 25, 2019
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants