Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions Activout.RestClient/DomainExceptions/DomainHttpErrorAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
#nullable disable
using System;
using System;
using System.Net;

namespace Activout.RestClient.DomainExceptions
{
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = true)]
public class DomainHttpErrorAttribute : Attribute
{
public HttpStatusCode HttpStatusCode { get; }
public object DomainErrorValue { get; }
namespace Activout.RestClient.DomainExceptions;

public DomainHttpErrorAttribute(HttpStatusCode httpStatusCode, object domainErrorValue)
{
HttpStatusCode = httpStatusCode;
DomainErrorValue = domainErrorValue;
}
}
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = true)]
public class DomainHttpErrorAttribute(HttpStatusCode httpStatusCode, object domainErrorValue) : Attribute
{
public HttpStatusCode HttpStatusCode { get; } = httpStatusCode;
public object DomainErrorValue { get; } = domainErrorValue;
}
17 changes: 5 additions & 12 deletions Activout.RestClient/ErrorResponseAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
#nullable disable
using System;

namespace Activout.RestClient
{
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method)]
public class ErrorResponseAttribute : Attribute
{
public ErrorResponseAttribute(Type type)
{
Type = type;
}
namespace Activout.RestClient;

public Type Type { get; }
}
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method)]
public class ErrorResponseAttribute(Type type) : Attribute
{
public Type Type { get; } = type;
}
15 changes: 4 additions & 11 deletions Activout.RestClient/FormParamAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#nullable disable
using System;

namespace Activout.RestClient
{
[AttributeUsage(AttributeTargets.Parameter)]
public class FormParamAttribute : NamedParamAttribute
{
public FormParamAttribute(string name = null) : base(name)
{
}
}
}
namespace Activout.RestClient;

[AttributeUsage(AttributeTargets.Parameter)]
public class FormParamAttribute(string? name = null) : NamedParamAttribute(name);
19 changes: 6 additions & 13 deletions Activout.RestClient/HeaderParamAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
#nullable disable
using System;
using System;

namespace Activout.RestClient
{
[AttributeUsage(AttributeTargets.Parameter)]
public class HeaderParamAttribute : NamedParamAttribute
{
public bool Replace { get; }
namespace Activout.RestClient;

public HeaderParamAttribute(string name = null, bool replace = true) : base(name)
{
Replace = replace;
}
}
[AttributeUsage(AttributeTargets.Parameter)]
public class HeaderParamAttribute(string? name = null, bool replace = true) : NamedParamAttribute(name)
{
public bool Replace { get; } = replace;
}
56 changes: 11 additions & 45 deletions Activout.RestClient/HttpMethodAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,20 @@
#nullable disable
using System;
using System.Net.Http;

namespace Activout.RestClient
{
[AttributeUsage(AttributeTargets.Method)]
public abstract class HttpMethodAttribute : TemplateAttribute
{
public HttpMethod HttpMethod { get; }

protected HttpMethodAttribute(HttpMethod httpMethod, string template) : base(template)
{
HttpMethod = httpMethod;
}
}
namespace Activout.RestClient;

public class DeleteAttribute : HttpMethodAttribute
{
public DeleteAttribute(string template = null) : base(HttpMethod.Delete, template)
{
}
}

public class GetAttribute : HttpMethodAttribute
{
public GetAttribute(string template = null) : base(HttpMethod.Get, template)
{
}
}
[AttributeUsage(AttributeTargets.Method)]
public abstract class HttpMethodAttribute(HttpMethod httpMethod, string? template) : TemplateAttribute(template)
{
public HttpMethod HttpMethod { get; } = httpMethod;
}

public class DeleteAttribute(string? template = null) : HttpMethodAttribute(HttpMethod.Delete, template);

public class PostAttribute : HttpMethodAttribute
{
public PostAttribute(string template = null) : base(HttpMethod.Post, template)
{
}
}
public class GetAttribute(string? template = null) : HttpMethodAttribute(HttpMethod.Get, template);

public class PostAttribute(string? template = null) : HttpMethodAttribute(HttpMethod.Post, template);

public class PutAttribute : HttpMethodAttribute
{
public PutAttribute(string template = null) : base(HttpMethod.Put, template)
{
}
}
public class PutAttribute(string? template = null) : HttpMethodAttribute(HttpMethod.Put, template);

public class PatchAttribute : HttpMethodAttribute
{
public PatchAttribute(string template = null) : base(HttpMethod.Patch, template)
{
}
}
}
public class PatchAttribute(string? template = null) : HttpMethodAttribute(HttpMethod.Patch, template);
17 changes: 5 additions & 12 deletions Activout.RestClient/NamedParamAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
#nullable disable
using System;

namespace Activout.RestClient
{
[AttributeUsage(AttributeTargets.Parameter)]
public abstract class NamedParamAttribute : Attribute
{
public string Name { get; }
namespace Activout.RestClient;

protected NamedParamAttribute(string name)
{
Name = name;
}
}
[AttributeUsage(AttributeTargets.Parameter)]
public abstract class NamedParamAttribute(string? name) : Attribute
{
public string? Name { get; } = name;
}
21 changes: 7 additions & 14 deletions Activout.RestClient/PartParamAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
#nullable disable
using System;

namespace Activout.RestClient
{
[AttributeUsage(AttributeTargets.Parameter)]
public class PartParamAttribute : NamedParamAttribute
{
public string FileName { get; }
public MediaType ContentType { get; }
namespace Activout.RestClient;

public PartParamAttribute(string name = null, string fileName = null, string contentType = null) : base(name)
{
FileName = fileName;
ContentType = MediaType.ValueOf(contentType);
}
}
[AttributeUsage(AttributeTargets.Parameter)]
public class PartParamAttribute(string? name = null, string? fileName = null, string? contentType = null)
: NamedParamAttribute(name)
{
public string? FileName { get; } = fileName;
public MediaType? ContentType { get; } = MediaType.ValueOf(contentType);
}
15 changes: 4 additions & 11 deletions Activout.RestClient/PathAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#nullable disable
using System;

namespace Activout.RestClient
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Interface)]
public class PathAttribute : TemplateAttribute
{
public PathAttribute(string template) : base(template)
{
}
}
}
namespace Activout.RestClient;

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Interface)]
public class PathAttribute(string template) : TemplateAttribute(template);
13 changes: 3 additions & 10 deletions Activout.RestClient/PathParamAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#nullable disable
namespace Activout.RestClient
{
public class PathParamAttribute : NamedParamAttribute
{
public PathParamAttribute(string name = null) : base(name)
{
}
}
}
namespace Activout.RestClient;

public class PathParamAttribute(string? name = null) : NamedParamAttribute(name);
13 changes: 3 additions & 10 deletions Activout.RestClient/QueryParamAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#nullable disable
namespace Activout.RestClient
{
public class QueryParamAttribute : NamedParamAttribute
{
public QueryParamAttribute(string name = null) : base(name)
{
}
}
}
namespace Activout.RestClient;

public class QueryParamAttribute(string? name = null) : NamedParamAttribute(name);
13 changes: 0 additions & 13 deletions Activout.RestClient/RouteAttribute.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Activout.RestClient/RouteParamAttribute.cs

This file was deleted.

15 changes: 4 additions & 11 deletions Activout.RestClient/TemplateAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#nullable disable
using System;

namespace Activout.RestClient
{
public abstract class TemplateAttribute : Attribute
{
protected TemplateAttribute(string template = null)
{
Template = template;
}
namespace Activout.RestClient;

public string Template { get; set; }
}
public abstract class TemplateAttribute(string? template = null) : Attribute
{
public string? Template { get; } = template;
}
Loading